protected void clearErrorsAndWarnings() { getWarnings().clear(); getErrors().clear(); }
protected void doLinking() { if (parseResult == null || parseResult.getRootASTElement() == null) return; final ListBasedDiagnosticConsumer consumer = new ListBasedDiagnosticConsumer(); linker.linkModel(parseResult.getRootASTElement(), consumer); if (!validationDisabled) { getErrors().addAll(consumer.getResult(Severity.ERROR)); getWarnings().addAll(consumer.getResult(Severity.WARNING)); } }
public final XtextResource getResourceAndExpect(InputStream in, URI uri, int expectedErrors) throws Exception { XtextResource resource = doGetResource(in, uri); if (expectedErrors != UNKNOWN_EXPECTATION) { if (expectedErrors == EXPECT_ERRORS) assertFalse(resource.getErrors().toString(), resource.getErrors().isEmpty()); else assertEquals(resource.getErrors().toString(), expectedErrors, resource.getErrors().size()); } for(Diagnostic d: resource.getErrors()) { if (d instanceof ExceptionDiagnostic) fail(d.getMessage()); } for(Diagnostic d: resource.getWarnings()) System.out.println("Resource Warning: "+d); if (expectedErrors == 0 && resource.getContents().size() > 0 && shouldTestSerializer(resource)) { SerializerTester tester = get(SerializerTester.class); EObject obj = resource.getContents().get(0); tester.assertSerializeWithNodeModel(obj); tester.assertSerializeWithoutNodeModel(obj); } return resource; }
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(resource.getErrors().toString(), resource.getErrors().isEmpty()); else assertEquals(resource.getErrors().toString(), expectedErrors, resource.getErrors().size()); } for(Diagnostic d: resource.getErrors()) { if (d instanceof ExceptionDiagnostic) fail(d.getMessage()); } for(Diagnostic d: resource.getWarnings()) System.out.println("Resource Warning: "+d); if (expectedErrors == 0 && resource.getContents().size() > 0 && shouldTestSerializer(resource)) { SerializerTester tester = get(SerializerTester.class); EObject obj = resource.getContents().get(0); tester.assertSerializeWithNodeModel(obj); tester.assertSerializeWithoutNodeModel(obj); } return resource; }