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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations