use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test18_2.
@Test
public void test18_2() {
// test manipulations overlapping multiple segments of the slave document
// replace range overlapping two neighboring segments
createProjectionA();
try {
fSlaveDocument.replace(30, 20, "~~~~~");
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(0, 20), new Position(40, 25), new Position(85, 20), new Position(125, 20) };
assertFragmentation(expected);
StringBuffer buffer = new StringBuffer(getProjectionASlaveContents());
buffer.replace(30, 50, "~~~~~");
assertSlaveContents(buffer.toString());
buffer = new StringBuffer(getOriginalMasterContents());
buffer.replace(50, 90, "~~~~~");
assertMasterContents(buffer.toString());
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test21_7.
@Test
public void test21_7() {
// test removing a range from the slave document beginning in a segment gap and ending in a segment gap
createProjectionA();
try {
fSlaveDocument.removeMasterDocumentRange(70, 40);
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(0, 20), new Position(40, 20), new Position(120, 20), new Position(160, 20) };
assertFragmentation(expected);
StringBuffer buffer = new StringBuffer(getProjectionASlaveContents());
buffer.delete(40, 60);
assertSlaveContents(buffer.toString());
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test24_5.
@Test
public void test24_5() {
// test auto expand mode when manipulating the master document
// master event starts left of fragment and ends inside of a fragment
createProjectionB();
fSlaveDocument.setAutoExpandMode(true);
try {
DocumentEvent event = new DocumentEvent(fMasterDocument, 50, 20, "~");
fSlaveDocument.adaptProjectionToMasterChange2(event);
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(20, 20), new Position(50, 30), new Position(100, 20), new Position(140, 20) };
assertFragmentation(expected);
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class ProjectionDocumentTest method test24_4.
@Test
public void test24_4() {
// test auto expand mode when manipulating the master document
// master event completely right of fragment
// -> is also left of the fragment in this setup
createProjectionB();
fSlaveDocument.setAutoExpandMode(true);
try {
DocumentEvent event = new DocumentEvent(fMasterDocument, 85, 10, "~");
fSlaveDocument.adaptProjectionToMasterChange2(event);
} catch (BadLocationException e) {
assertTrue(false);
}
Position[] expected = { new Position(20, 20), new Position(60, 20), new Position(85, 10), new Position(100, 20), new Position(140, 20) };
assertFragmentation(expected);
}
use of org.eclipse.jface.text.Position in project eclipse.platform.text by eclipse.
the class AnnotationModelStressTest method assertAdd.
private void assertAdd(AnnotationData data, ArrayList<AnnotationData> added) {
Annotation annotation = new Annotation(false);
Position position = new Position(data.offset, data.length);
IAnnotationModel model = getModel(data.annotationNumber);
model.addAnnotation(annotation, position);
assertTrue(model.getPosition(annotation) == position);
data.annotation = annotation;
data.position = position;
added.add(data);
}
Aggregations