use of org.eclipse.text.edits.DeleteEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testUndefinedMultiEdit6.
@Test
public void testUndefinedMultiEdit6() throws Exception {
DeleteEdit d1 = new DeleteEdit(1, 3);
MultiTextEdit m2 = new MultiTextEdit();
assertTrue(d1.covers(m2));
}
use of org.eclipse.text.edits.DeleteEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testDelete3.
@Test
public void testDelete3() throws Exception {
TextEdit e1 = new InsertEdit(3, "x");
TextEdit e2 = new DeleteEdit(3, 1);
fRoot.addChild(e1);
fRoot.addChild(e2);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(fRoot, 3, 1);
assertEquals(e1, 3, 1);
assertEquals(e2, 4, 0);
Assert.assertEquals("Buffer content", "012x456789", fDocument.get());
doUndoRedo(undo, "012x456789");
}
use of org.eclipse.text.edits.DeleteEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveWithTargetDelete.
@Test
public void testMoveWithTargetDelete() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(2, 3);
MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
TextEdit e2 = new DeleteEdit(6, 2);
e2.addChild(t1);
fRoot.addChild(s1);
fRoot.addChild(e2);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "01589", fDocument.get());
assertEquals(s1, 2, 0);
assertTrue(t1.isDeleted());
assertEquals(e2, 3, 0);
doUndoRedo(undo, "01589");
}
use of org.eclipse.text.edits.DeleteEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testComparator.
@Test
public void testComparator() throws Exception {
DeleteEdit d1 = new DeleteEdit(1, 3);
Accessor accessor = new Accessor(d1, TextEdit.class);
@SuppressWarnings("unchecked") Comparator<TextEdit> comparator = (Comparator<TextEdit>) accessor.get("INSERTION_COMPARATOR");
TextEdit edit1 = new InsertEdit(1, "test");
TextEdit edit2 = new InsertEdit(1, "test");
TextEdit edit3 = new InsertEdit(57, "test3");
assertTrue(edit1.equals(edit1));
Assert.assertEquals(0, comparator.compare(edit1, edit1));
Assert.assertEquals(0, comparator.compare(edit1, edit2));
Assert.assertEquals(0, comparator.compare(edit2, edit1));
assertTrue(comparator.compare(edit1, edit3) == -comparator.compare(edit3, edit1));
}
use of org.eclipse.text.edits.DeleteEdit in project AutoRefactor by JnRouvignac.
the class ASTCommentRewriter method addRemovalEdits.
private void addRemovalEdits(List<TextEdit> commentEdits, String source) {
if (this.removals.isEmpty()) {
return;
}
for (Comment node : this.removals) {
final int start = node.getStartPosition();
final int length = node.getLength();
// chomp from the end before the start variable gets modified
final int startToRemove = chompWhitespacesBefore(source, start);
final int endToRemove = chompWhitespacesAfter(source, start + length);
final int lengthToRemove = endToRemove - startToRemove;
commentEdits.add(new DeleteEdit(startToRemove, lengthToRemove));
}
}
Aggregations