/** * Returns the revision range that contains the given line, or * <code>null</code> if there is none. * * @param line the line of interest * @return the corresponding <code>RevisionRange</code> or <code>null</code> */ private RevisionRange getRange(int line) { List<RevisionRange> ranges= getRangeCache(); if (ranges.isEmpty() || line == -1) return null; for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) { RevisionRange range= it.next(); if (contains(range, line)) return range; } // line may be right after the last region RevisionRange lastRegion= ranges.get(ranges.size() - 1); if (line == end(lastRegion)) return lastRegion; return null; }
/** * Returns the revision range that contains the given line, or * <code>null</code> if there is none. * * @param line the line of interest * @return the corresponding <code>RevisionRange</code> or <code>null</code> */ private RevisionRange getRange(int line) { List<RevisionRange> ranges= getRangeCache(); if (ranges.isEmpty() || line == -1) return null; for (RevisionRange range : ranges) { if (contains(range, line)) return range; } // line may be right after the last region RevisionRange lastRegion= ranges.get(ranges.size() - 1); if (line == end(lastRegion)) return lastRegion; return null; }
/** * 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 */ private 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 rangeEnd= end(range); if (first == -1 && rangeEnd > 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 ranges.subList(first, last + 1); }
/** * 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 */ private 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 rangeEnd= end(range); if (first == -1 && rangeEnd > 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 ranges.subList(first, last + 1); }