/** * Returns the line ranges of this revision information. The returned information is only valid * at the moment it is returned, and may change as the annotated document is modified. See * {@link IRevisionListener} for a way to be informed when the revision information changes. The * returned list is sorted by document offset. * * @return an unmodifiable view of the line ranges * @see IRevisionListener * @since 3.3 */ public List<RevisionRange> getRanges() { if (fRanges == null) { List<RevisionRange> ranges= new ArrayList<>(fRevisions.size() * 2); // wild size guess for (Revision revision : fRevisions) { ranges.addAll(revision.getRegions()); } // sort by start line Collections.sort(ranges, (r1, r2) -> r1.getStartLine() - r2.getStartLine()); fRanges= Collections.unmodifiableList(ranges); } return fRanges; }
/** * Returns the line ranges of this revision information. The returned information is only valid * at the moment it is returned, and may change as the annotated document is modified. See * {@link IRevisionListener} for a way to be informed when the revision information changes. The * returned list is sorted by document offset. * * @return an unmodifiable view of the line ranges * @see IRevisionListener * @since 3.3 */ public List<RevisionRange> getRanges() { if (fRanges == null) { List<RevisionRange> ranges= new ArrayList<>(fRevisions.size() * 2); // wild size guess for (Iterator<Revision> it= fRevisions.iterator(); it.hasNext();) { Revision revision= it.next(); ranges.addAll(revision.getRegions()); } // sort by start line Collections.sort(ranges, (r1, r2) -> r1.getStartLine() - r2.getStartLine()); fRanges= Collections.unmodifiableList(ranges); } return fRanges; }
@Override public String toString() { return "RevisionRange [" + fRevision.toString() + ", [" + getStartLine() + "+" + getNumberOfLines() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }
@Override public String toString() { return "RevisionRange [" + fRevision.toString() + ", [" + getStartLine() + "+" + getNumberOfLines() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }
/** * Returns the sublist of all <code>RevisionRange</code>s that intersect with the given lines. * * @param lines the model based lines of interest * @return elementType: RevisionRange */ public List<RevisionRange> getRanges(ILineRange lines) { List<RevisionRange> ranges= getRangeCache(); // return the interesting subset int end= end(lines); int first= -1, last= -1; for (int i= 0; i < ranges.size(); i++) { RevisionRange range= ranges.get(i); int rangeStart = range.getStartLine(); int rangeEnd= end(range); if (first == -1 && (rangeEnd > lines.getStartLine() && rangeStart <= lines.getStartLine())) first= i; if (first != -1 && rangeEnd > end) { last= i; break; } } if (first == -1) return Collections.emptyList(); if (last == -1) last= ranges.size() - 1; // bottom index may be one too much //return Collections.emptyList(); return ranges.subList(first, last + 1); }