Search in sources :

Example 66 with Position

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

the class ProjectionDocumentTest method test21_6.

@Test
public void test21_6() {
    // test removing a range from the slave document beginning in a segment gap and ending in a segment
    createProjectionA();
    try {
        fSlaveDocument.removeMasterDocumentRange(70, 20);
    } catch (BadLocationException e) {
        assertTrue(false);
    }
    Position[] expected = { new Position(0, 20), new Position(40, 20), new Position(90, 10), new Position(120, 20), new Position(160, 20) };
    assertFragmentation(expected);
    StringBuffer buffer = new StringBuffer(getProjectionASlaveContents());
    buffer.delete(40, 50);
    assertSlaveContents(buffer.toString());
}
Also used : Position(org.eclipse.jface.text.Position) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Example 67 with Position

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

the class ProjectionDocumentTest method test21_9.

@Test
public void test21_9() {
    // test removing a range from the slave document using identical projection
    createIdenticalProjection();
    try {
        fSlaveDocument.removeMasterDocumentRange(50, 40);
    } catch (BadLocationException e) {
        assertTrue(false);
    }
    Position[] expected = { new Position(0, 50), new Position(90, 90) };
    assertFragmentation(expected);
    StringBuffer buffer = new StringBuffer(getOriginalMasterContents());
    buffer.delete(50, 90);
    assertSlaveContents(buffer.toString());
}
Also used : Position(org.eclipse.jface.text.Position) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Example 68 with Position

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

the class ProjectionDocumentTest method test21_8.

@Test
public void test21_8() {
    // test removing a range from the slave document beginning in a segment and ending in a segment
    createProjectionA();
    try {
        fSlaveDocument.removeMasterDocumentRange(50, 40);
    } catch (BadLocationException e) {
        assertTrue(false);
    }
    Position[] expected = { new Position(0, 20), new Position(40, 10), new Position(90, 10), new Position(120, 20), new Position(160, 20) };
    assertFragmentation(expected);
    StringBuffer buffer = new StringBuffer(getProjectionASlaveContents());
    buffer.delete(30, 50);
    assertSlaveContents(buffer.toString());
}
Also used : Position(org.eclipse.jface.text.Position) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Example 69 with Position

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

the class ProjectionDocumentTest method test11.

@Test
public void test11() {
    // test deleting an unprojected region of the master document
    createProjectionA();
    try {
        fMasterDocument.replace(60, 20, "");
    } catch (BadLocationException e) {
        assertTrue(false);
    }
    Position[] expected = { new Position(0, 20), new Position(40, 40), new Position(100, 20), new Position(140, 20) };
    assertFragmentation(expected);
    assertSlaveContents(getProjectionASlaveContents());
}
Also used : Position(org.eclipse.jface.text.Position) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Example 70 with Position

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

the class ProjectionDocumentTest method test24_7.

@Test
public void test24_7() {
    // test auto expand mode when manipulating the master document
    // master event starts left of a fragment and ends right of a fragment
    createProjectionB();
    fSlaveDocument.setAutoExpandMode(true);
    try {
        DocumentEvent event = new DocumentEvent(fMasterDocument, 50, 40, "~");
        fSlaveDocument.adaptProjectionToMasterChange2(event);
    } catch (BadLocationException e) {
        assertTrue(false);
    }
    Position[] expected = { new Position(20, 20), new Position(50, 40), new Position(100, 20), new Position(140, 20) };
    assertFragmentation(expected);
}
Also used : Position(org.eclipse.jface.text.Position) DocumentEvent(org.eclipse.jface.text.DocumentEvent) BadLocationException(org.eclipse.jface.text.BadLocationException) Test(org.junit.Test)

Aggregations

Position (org.eclipse.jface.text.Position)421 BadLocationException (org.eclipse.jface.text.BadLocationException)145 Annotation (org.eclipse.jface.text.source.Annotation)110 IDocument (org.eclipse.jface.text.IDocument)80 ArrayList (java.util.ArrayList)75 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)57 IRegion (org.eclipse.jface.text.IRegion)55 Test (org.junit.Test)54 HashMap (java.util.HashMap)49 BadPositionCategoryException (org.eclipse.jface.text.BadPositionCategoryException)46 Point (org.eclipse.swt.graphics.Point)40 List (java.util.List)39 Iterator (java.util.Iterator)31 TypedPosition (org.eclipse.jface.text.TypedPosition)31 Region (org.eclipse.jface.text.Region)27 IFile (org.eclipse.core.resources.IFile)22 IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)21 ProjectionAnnotation (org.eclipse.jface.text.source.projection.ProjectionAnnotation)21 Map (java.util.Map)15 CoreException (org.eclipse.core.runtime.CoreException)15