/** * Computes the end index of a line range. * * @param range a line range * @return the last line (exclusive) of <code>range</code> */ private static int end(ILineRange range) { return range.getStartLine() + range.getNumberOfLines(); }
/** * Returns <code>true</code> if <code>range</code> contains <code>line</code>. A line is * not contained in a range if it is the range's exclusive end line. * * @param range the range to check whether it contains <code>line</code> * @param line the line the line * @return <code>true</code> if <code>range</code> contains <code>line</code>, * <code>false</code> if not */ private static boolean contains(ILineRange range, int line) { return range.getStartLine() <= line && end(range) > line; }
/** * Computes the end index of a line range. * * @param range a line range * @return the last line (exclusive) of <code>range</code> */ private static int end(ILineRange range) { return range.getStartLine() + range.getNumberOfLines(); }
/** * Computes the end index of a line range. * * @param range a line range * @return the last line (exclusive) of <code>range</code> */ private static int end(ILineRange range) { return range.getStartLine() + range.getNumberOfLines(); }
/** * Computes the end index of a line range. * * @param range a line range * @return the last line (exclusive) of <code>range</code> */ private static int end(ILineRange range) { return range.getStartLine() + range.getNumberOfLines(); }
/** * Computes the end index of a line range. * * @param range a line range * @return the last line (exclusive) of <code>range</code> */ private static int end(ILineRange range) { return range.getStartLine() + range.getNumberOfLines(); }
/** * Returns <code>true</code> if <code>range</code> contains <code>line</code>. A line is * not contained in a range if it is the range's exclusive end line. * * @param range the range to check whether it contains <code>line</code> * @param line the line the line * @return <code>true</code> if <code>range</code> contains <code>line</code>, * <code>false</code> if not */ private static boolean contains(ILineRange range, int line) { return range.getStartLine() <= line && end(range) > line; }
@Override public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleNumberOfLines) { RevisionRange range= getRange(lineRange.getStartLine()); Object info= range == null ? null : range.getRevision().getHoverInfo(); return info; }
/** * Returns the line coverage of the adjusted ranges, an empty range if the coverage is empty. * * @return the line coverage of the adjusted ranges */ public ILineRange getAdjustedCoverage() { if (fAdjusted.isEmpty()) return new LineRange(fLines.getStartLine(), 0); Range first= fAdjusted.get(0); Range last= fAdjusted.get(fAdjusted.size() - 1); return Range.createAbsolute(first.start(), last.end()); }
@Override public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleNumberOfLines) { RevisionRange range= getRange(lineRange.getStartLine()); Object info= range == null ? null : range.getRevision().getHoverInfo(); return info; }
/** * Creates a new range with the same start and length as the passed line range. * * @param range the range to copy * @return a <code>Range</code> with the same start and length as <code>range</code> * @throws LineIndexOutOfBoundsException if the passed {@link ILineRange} does not adhere to the * contract of {@link Range} */ public static Range copy(ILineRange range) throws LineIndexOutOfBoundsException { return createRelative(range.getStartLine(), range.getNumberOfLines()); }
@Override public String toString() { return "ChangeRegion [" + fRevision.toString() + ", [" + fLines.getStartLine() + "+" + fLines.getNumberOfLines() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }
/** * Creates a new range with the same start and length as the passed line range. * * @param range the range to copy * @return a <code>Range</code> with the same start and length as <code>range</code> * @throws LineIndexOutOfBoundsException if the passed {@link ILineRange} does not adhere to the * contract of {@link Range} */ public static Range copy(ILineRange range) throws LineIndexOutOfBoundsException { return createRelative(range.getStartLine(), range.getNumberOfLines()); }
@Override public String toString() { return "ChangeRegion [" + fRevision.toString() + ", [" + fLines.getStartLine() + "+" + fLines.getNumberOfLines() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } }
@Override public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) { int first= adaptFirstLine(sourceViewer, lineRange.getStartLine()); int last= adaptLastLine(sourceViewer, lineRange.getStartLine() + lineRange.getNumberOfLines() - 1); String content= computeContent(sourceViewer, first, last, visibleLines); return formatSource(content); }
@Override public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) { int first= adaptFirstLine(sourceViewer, lineRange.getStartLine()); int last= adaptLastLine(sourceViewer, lineRange.getStartLine() + lineRange.getNumberOfLines() - 1); String content= computeContent(sourceViewer, first, last, visibleLines); return formatSource(content); }
/** * Returns <code>true</code> if the passed range has the same offset and length as the receiver. * * @param range another line range to compare the receiver to * @return <code>true</code> if <code>range</code> has the same offset and length as the receiver */ public boolean equalRange(ILineRange range) { if (range == this) return true; if (range == null) return false; return range.getStartLine() == start() && range.getNumberOfLines() == length(); }
public DocEquivalenceComparator(DocumentEquivalenceClass equivalenceClass, ILineRange range) { fEquivalenceClass= equivalenceClass; if (range == null) { fLineOffset= 0; fLines= fEquivalenceClass.getCount(); } else { fLineOffset= range.getStartLine(); fLines= range.getNumberOfLines(); Assert.isTrue(fLineOffset >= 0); Assert.isTrue(fLineOffset + fLines <= fEquivalenceClass.getCount()); } }
public DocEquivalenceComparator(DocumentEquivalenceClass equivalenceClass, ILineRange range) { fEquivalenceClass= equivalenceClass; if (range == null) { fLineOffset= 0; fLines= fEquivalenceClass.getCount(); } else { fLineOffset= range.getStartLine(); fLines= range.getNumberOfLines(); Assert.isTrue(fLineOffset >= 0); Assert.isTrue(fLineOffset + fLines <= fEquivalenceClass.getCount()); } }
private IRegion getRegion(IDocument document, ILineRange lineRange) throws BadLocationException { final int startLine= lineRange.getStartLine(); int offset= document.getLineOffset(startLine); final int numberOfLines= lineRange.getNumberOfLines(); if (numberOfLines < 1) return new Region(offset, 0); int endLine= startLine + numberOfLines - 1; int endOffset= document.getLineOffset(endLine) + document.getLineLength(endLine); return new Region(offset, endOffset - offset); }