use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test10_4.
@Test
public void test10_4() {
// test manipulations overlapping projected and unprojected regions of the master document
// replace range overlapping from an unprojected into a projected region
// -> replaced range will appear in slave document because of auto expansion of slave document in case of overlapping events
createProjectionA();
try {
fMasterDocument.replace(70, 20, "~~~~~");
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(0, 20), new Position(40, 20), new Position(70, 15), new Position(105, 20), new Position(145, 20) };
assertFragmentation(expected);
StringBuffer buffer = new StringBuffer(getProjectionASlaveContents());
buffer.replace(40, 50, "~~~~~");
assertSlaveContents(buffer.toString());
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test20_5.
@Test
public void test20_5() {
// test adding a range to the slave document beginning in a segment gap and ending in a segment
createProjectionA();
try {
fSlaveDocument.addMasterDocumentRange(70, 20);
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(0, 20), new Position(40, 20), new Position(70, 30), new Position(120, 20), new Position(160, 20) };
assertFragmentation(expected);
StringBuffer buffer = new StringBuffer(getProjectionASlaveContents());
String addition = getOriginalMasterContents().substring(70, 80);
buffer.insert(40, addition);
assertSlaveContents(buffer.toString());
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test21_a.
@Test
public void test21_a() {
// test removing a range from the slave document using identical projection
// the removed range includes the end of the master document - see bug 301023
createIdenticalProjection();
try {
fSlaveDocument.removeMasterDocumentRange(80, 100);
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(0, 80), new Position(180, 0) };
assertFragmentation(expected);
StringBuffer buffer = new StringBuffer(getOriginalMasterContents());
buffer.delete(80, 180);
assertSlaveContents(buffer.toString());
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test10_2.
@Test
public void test10_2() {
// test manipulations overlapping projected and unprojected regions of the master document
// replace range overlapping from a projected into an unprojected region
// => replaced range will appear in slave document because of auto expansion of slave document in case of overlapping events
createProjectionA();
try {
fMasterDocument.replace(50, 20, "~~~~~");
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(0, 20), new Position(40, 15), new Position(65, 20), new Position(105, 20), new Position(145, 20) };
assertFragmentation(expected);
StringBuffer buffer = new StringBuffer(getProjectionASlaveContents());
buffer.replace(30, 40, "~~~~~");
assertSlaveContents(buffer.toString());
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test24_8.
@Test
public void test24_8() {
// test auto expand mode when manipulating the master document
// complete replace of master document
createProjectionB();
fSlaveDocument.setAutoExpandMode(true);
try {
DocumentEvent event = new DocumentEvent(fMasterDocument, 0, fMasterDocument.getLength(), "x" + getOriginalMasterContents() + "y");
fSlaveDocument.adaptProjectionToMasterChange2(event);
} catch (BadLocationException x) {
assertTrue(false);
}
Position[] expected = { new Position(0, fMasterDocument.getLength()) };
assertFragmentation(expected);
}
Aggregations