Search in sources :

Example 16 with LineRange

use of org.eclipse.jface.text.source.LineRange in project eclipse.platform.text by eclipse.

the class ChangeRegion method getAdjustedCoverage.

/**
 * 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());
}
Also used : ILineRange(org.eclipse.jface.text.source.ILineRange) LineRange(org.eclipse.jface.text.source.LineRange) ILineRange(org.eclipse.jface.text.source.ILineRange) LineRange(org.eclipse.jface.text.source.LineRange)

Example 17 with LineRange

use of org.eclipse.jface.text.source.LineRange in project eclipse.platform.text by eclipse.

the class JFaceTextUtil method getVisibleModelLines.

/**
 * Returns the range of lines that is visible in the viewer, including any partially visible
 * lines.
 *
 * @param viewer the viewer
 * @return the range of lines that is visible in the viewer, <code>null</code> if no lines are
 *         visible
 */
public static ILineRange getVisibleModelLines(ITextViewer viewer) {
    int top = getPartialTopIndex(viewer);
    int bottom = getPartialBottomIndex(viewer);
    if (top == -1 || bottom == -1)
        return null;
    return new LineRange(top, bottom - top + 1);
}
Also used : ILineRange(org.eclipse.jface.text.source.ILineRange) LineRange(org.eclipse.jface.text.source.LineRange) Point(org.eclipse.swt.graphics.Point)

Example 18 with LineRange

use of org.eclipse.jface.text.source.LineRange in project linuxtools by eclipse.

the class STPIndenterTest method assertIndenterResult.

protected void assertIndenterResult(String before, String expected) throws Exception {
    IDocument document = new Document(before);
    new MockSTPDocumentProvider(document);
    int numLines = document.getNumberOfLines();
    if (document.getLineLength(numLines - 1) == 0) {
        // Exclude an empty line at the end.
        numLines--;
    }
    IndentUtil.indentLines(document, new LineRange(0, numLines), null, null);
    assertEquals(expected, document.get());
}
Also used : Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) LineRange(org.eclipse.jface.text.source.LineRange) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

LineRange (org.eclipse.jface.text.source.LineRange)18 Test (org.junit.Test)12 ChangeRegion (org.eclipse.jface.internal.text.revisions.ChangeRegion)11 Hunk (org.eclipse.jface.internal.text.revisions.Hunk)10 ILineRange (org.eclipse.jface.text.source.ILineRange)5 Range (org.eclipse.jface.internal.text.revisions.Range)3 IDocument (org.eclipse.jface.text.IDocument)3 Point (org.eclipse.swt.graphics.Point)3 IRangeComparator (org.eclipse.compare.rangedifferencer.IRangeComparator)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 Document (org.eclipse.jface.text.Document)1 IRegion (org.eclipse.jface.text.IRegion)1 ITextViewerExtension5 (org.eclipse.jface.text.ITextViewerExtension5)1 RevisionRange (org.eclipse.jface.text.revisions.RevisionRange)1 DocEquivalenceComparator (org.eclipse.ui.internal.texteditor.quickdiff.compare.equivalence.DocEquivalenceComparator)1 DocumentEquivalenceClass (org.eclipse.ui.internal.texteditor.quickdiff.compare.equivalence.DocumentEquivalenceClass)1