use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testNonStructuralChange.
@Test
public void testNonStructuralChange() throws BadLocationException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
int methodBody = document.get().indexOf("{}") + 1;
assertNull("event is null before the document was modified", event);
try {
document.replace(methodBody, 0, "ignored.toString();");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNull(event);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testAddParam.
@Test
public void testAddParam() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
int idx = document.get().lastIndexOf("(");
assertNull("event is null before the document was modified", event);
try {
document.replace(idx + 1, 0, "int foobar");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 3, event.getDeltas().size());
Collection<String> allNames = getNames(event.getDeltas());
assertOriginalValues(allNames);
assertEquals("" + allNames, 3, allNames.size());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testCloseEditorAndDiscardWorkingCopy.
@Test
public void testCloseEditorAndDiscardWorkingCopy() throws InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
try {
compilationUnit.discardWorkingCopy();
((ITextEditor) editor).close(false);
} catch (JavaModelException e) {
throw new RuntimeException(e);
}
}
}, false);
assertNull(event);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testRemoveNestedClass.
@Test
public void testRemoveNestedClass() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
int idx = document.get().indexOf("public abstract class Inner");
assertNull("event is null before the document was modified", event);
try {
int closing = document.get().substring(idx).indexOf("\t}");
document.replace(idx, closing + 2, "");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 3, event.getDeltas().size());
assertNull(event.getDeltas().get(2).getNew());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(0).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(1).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(2).getUri().toString());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testNullChange.
@Test
public void testNullChange() throws BadLocationException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
try {
int lastBrace = document.get().lastIndexOf("}");
document.replace(lastBrace, 0, " ");
} catch (BadLocationException e) {
Assert.fail(e.getMessage());
}
}
});
assertNull(event);
}
Aggregations