Search in sources :

Example 91 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionMappingTest method test12c.

@Test
public void test12c() {
    // test toExactImageRegions
    // test a region completely comprised by a fragment at the beginning of a fragment
    createStandardProjection();
    try {
        IRegion[] actual = fProjectionMapping.toExactImageRegions(new Region(20, 10));
        IRegion[] expected = new IRegion[] { new Region(0, 10) };
        assertRegions(expected, actual);
    } catch (BadLocationException e) {
        assertTrue(false);
    }
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Example 92 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionMappingTest method test12a.

@Test
public void test12a() {
    // test toExactImageRegions
    // test the whole master document
    createStandardProjection();
    try {
        IRegion[] actual = fProjectionMapping.toExactImageRegions(new Region(0, fMasterDocument.getLength()));
        IRegion[] expected = new IRegion[] { new Region(0, 20), new Region(20, 20) };
        assertRegions(expected, actual);
    } catch (BadLocationException e) {
        assertTrue(false);
    }
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Example 93 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionMappingTest method test11d.

@Test
public void test11d() {
    // test toExactOriginRegions
    // test a region completely comprised by a segment at the end of a segment
    createStandardProjection();
    try {
        IRegion[] actual = fProjectionMapping.toExactOriginRegions(new Region(10, 10));
        IRegion[] expected = new IRegion[] { new Region(30, 10) };
        assertRegions(expected, actual);
    } catch (BadLocationException e) {
        assertTrue(false);
    }
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Example 94 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionMappingTest method test1.

@Test
public void test1() {
    // test getCoverage
    createStandardProjection();
    IRegion coverage = fProjectionMapping.getCoverage();
    assertTrue(coverage.getOffset() == 20);
    assertTrue(coverage.getLength() == 60);
}
Also used : IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Example 95 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ChildDocumentTest method checkLineInformationConsistency.

protected void checkLineInformationConsistency() {
    DefaultLineTracker textTracker = new DefaultLineTracker();
    textTracker.set(fDocument.get());
    int textLines = textTracker.getNumberOfLines();
    int trackerLines = fDocument.getNumberOfLines();
    assertEquals("Child document store and child line tracker are inconsistent", trackerLines, textLines);
    for (int i = 0; i < trackerLines; i++) {
        IRegion trackerLine = null;
        IRegion textLine = null;
        try {
            trackerLine = fDocument.getLineInformation(i);
            textLine = textTracker.getLineInformation(i);
        } catch (BadLocationException e) {
            assertTrue("BadLocationException thrown", false);
        }
        assertEquals("Child document store and child line tracker are inconsistent", trackerLine.getOffset(), textLine.getOffset());
        assertEquals("Child document store and child line tracker are inconsistent", trackerLine.getLength(), textLine.getLength());
    }
}
Also used : DefaultLineTracker(org.eclipse.jface.text.DefaultLineTracker) IRegion(org.eclipse.jface.text.IRegion) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

IRegion (org.eclipse.jface.text.IRegion)341 BadLocationException (org.eclipse.jface.text.BadLocationException)158 Region (org.eclipse.jface.text.Region)151 Test (org.junit.Test)94 IDocument (org.eclipse.jface.text.IDocument)68 Point (org.eclipse.swt.graphics.Point)49 Position (org.eclipse.jface.text.Position)38 ITextViewerExtension5 (org.eclipse.jface.text.ITextViewerExtension5)20 ITypedRegion (org.eclipse.jface.text.ITypedRegion)20 FindReplaceDocumentAdapter (org.eclipse.jface.text.FindReplaceDocumentAdapter)18 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)17 IEditorPart (org.eclipse.ui.IEditorPart)13 ArrayList (java.util.ArrayList)11 Document (org.eclipse.jface.text.Document)11 StyledText (org.eclipse.swt.custom.StyledText)10 ITextSelection (org.eclipse.jface.text.ITextSelection)9 IFile (org.eclipse.core.resources.IFile)8 Annotation (org.eclipse.jface.text.source.Annotation)7 HashMap (java.util.HashMap)6 CoreException (org.eclipse.core.runtime.CoreException)6