use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testExplicitOverride02.
@Test
public void testExplicitOverride02() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "terminal ID: ('a'..'z'|'A'..'Z'|'_');");
Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
List<Diagnostic> issues = diag.getChildren();
assertEquals(issues.toString(), 1, issues.size());
assertEquals("This rule overrides ID in org.eclipse.xtext.common.Terminals and thus should be annotated with @Override.", issues.get(0).getMessage());
assertEquals("diag.isWarning", diag.getSeverity(), Diagnostic.WARNING);
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testLeftRecursion_Bug_285605_15.
@Test
public void testLeftRecursion_Bug_285605_15() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "generate foo 'http://foo/bar'\n" + "RuleA : ruleB=RuleB;\n" + "RuleB : ruleC=RuleC;\n" + "RuleC : (name=ID & value=STRING)? ruleA=RuleA;\n");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
assertNotNull("diag", diag);
assertEquals(diag.getChildren().toString(), 4, diag.getChildren().size());
assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testBug_286683.
@Test
public void testBug_286683() throws Exception {
XtextResource resource = getResourceFromString("grammar org.xtext.example.MyDsl with org.xtext.example.MyDsl\n" + "generate myDsl 'http://www.xtext.org/example/MyDsl'\n" + "Model : {Model} 'name';");
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
assertNotNull("diag", diag);
assertEquals(diag.getSeverity(), Diagnostic.ERROR);
assertEquals(diag.getChildren().toString(), 2, diag.getChildren().size());
}
Aggregations