use of org.eclipse.emf.ecore.resource.Resource.Diagnostic in project xtext-core by eclipse.
the class AbstractXtextTests method getResourceAndExpect.
public final XtextResource getResourceAndExpect(InputStream in, URI uri, int expectedErrors) throws Exception {
XtextResource resource = doGetResource(in, uri);
checkNodeModel(resource);
if (expectedErrors != UNKNOWN_EXPECTATION) {
if (expectedErrors == EXPECT_ERRORS)
assertFalse(Joiner.on('\n').join(resource.getErrors()), resource.getErrors().isEmpty());
else
assertEquals(Joiner.on('\n').join(resource.getErrors()), expectedErrors, resource.getErrors().size());
}
for (Diagnostic d : resource.getErrors()) {
if (d instanceof ExceptionDiagnostic)
fail(d.getMessage());
}
if (expectedErrors == 0 && resource.getContents().size() > 0 && shouldTestSerializer(resource)) {
SerializerTestHelper tester = get(SerializerTestHelper.class);
EObject obj = resource.getContents().get(0);
tester.assertSerializeWithNodeModel(obj);
tester.assertSerializeWithoutNodeModel(obj);
}
return resource;
}
use of org.eclipse.emf.ecore.resource.Resource.Diagnostic in project xtext-core by eclipse.
the class Bug362902Test method testNoExceptionUncaught.
@Test
public void testNoExceptionUncaught() throws Exception {
String modelAsString = "Hello max ! Hello peter! favourite peter";
Model model = (Model) getModelAndExpect(modelAsString, 2);
EList<Diagnostic> errors = model.eResource().getErrors();
Diagnostic diagnosticSyntax = errors.get(0);
Diagnostic diagnosticLinking = errors.get(1);
assertTrue(diagnosticSyntax instanceof XtextSyntaxDiagnostic);
assertTrue(diagnosticLinking instanceof XtextLinkingDiagnostic);
}
Aggregations