Search in sources :

Example 81 with IRegion

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

the class ProjectionDocumentTest method test29_33.

@Test
public void test29_33() {
    // test computation of unprojected  master regions
    // spanning multiple fragments
    // starting right of fragment
    // ending touching left fragment border
    IRegion[] expected = { new Region(50, 10), new Region(80, 20), new Region(120, 20) };
    assertUnprojectedMasterRegions(expected, 50, 90);
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Example 82 with IRegion

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

the class ProjectionDocumentTest method test29_30.

@Test
public void test29_30() {
    // test computation of unprojected  master regions
    // spanning multiple fragments
    // starting touching right fragment border
    // ending touching right fragment border
    IRegion[] expected = { new Region(40, 20), new Region(80, 20), new Region(120, 20) };
    assertUnprojectedMasterRegions(expected, 40, 120);
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Example 83 with IRegion

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

the class ProjectionDocumentTest method test29_19.

@Test
public void test29_19() {
    // test computation of unprojected  master regions
    // spanning multiple fragments
    // starting touching left fragment border
    // ending inside fragment
    IRegion[] expected = { new Region(80, 20) };
    assertUnprojectedMasterRegions(expected, 60, 50);
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Example 84 with IRegion

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

the class ProjectionMappingTest method test11g.

@Test
public void test11g() {
    // test toExactOriginRegions
    // test a region starting in the middle of a segment and ending in the middle of another fragment
    createStandardProjection();
    try {
        IRegion[] actual = fProjectionMapping.toExactOriginRegions(new Region(10, 20));
        IRegion[] expected = new IRegion[] { new Region(30, 10), new Region(60, 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 85 with IRegion

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

the class ProjectionMappingTest method test8b.

@Test
public void test8b() {
    // test toImageRegion
    createStandardProjection();
    try {
        // test a region contained by a fragment
        IRegion imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 10));
        assertEquals(new Region(5, 10), imageRegion);
        // test region of length 0
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 0));
        assertEquals(new Region(5, 0), imageRegion);
        // test a complete fragment
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(20, 20));
        assertEquals(new Region(0, 20), imageRegion);
        // test a region spanning multiple fragments incompletely
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 50));
        assertEquals(new Region(5, 30), imageRegion);
        // test a region spanning multiple fragments completely
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(20, 60));
        assertEquals(new Region(0, 40), imageRegion);
        // test a region non overlapping with a fragment
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(45, 10));
        assertEquals(new Region(20, 0), imageRegion);
        // test a zero-length region at the end of the last fragment
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(80, 0));
        assertEquals(new Region(40, 0), imageRegion);
        // test a region at the end of the last fragment
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(80, 10));
        assertEquals(new Region(40, 0), imageRegion);
        // test a region before the first fragment
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(10, 5));
        assertEquals(new Region(0, 0), imageRegion);
        // test a region surrounded by two fragments
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(40, 20));
        assertEquals(new Region(20, 0), imageRegion);
        // test a region starting in a fragment and ending outside a fragment
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(25, 30));
        assertEquals(new Region(5, 15), imageRegion);
        // test a region starting outside a fragment and ending inside a fragment
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(45, 30));
        assertEquals(new Region(20, 15), imageRegion);
        // test a region starting outside a fragment and ending outside a fragment (covering one)
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(45, 50));
        assertEquals(new Region(20, 20), imageRegion);
        // test a region starting outside a fragment and ending outside a fragment (covering two)
        imageRegion = fProjectionMapping.toClosestImageRegion(new Region(15, 70));
        assertEquals(new Region(0, 40), imageRegion);
    } 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)

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