use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testRulenamesAreNotEqualIgnoreCase.
@Test
public void testRulenamesAreNotEqualIgnoreCase() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: name=ID ref=[Model|ID];\n" + "moDel: name=ID ref='foo';");
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 testTerminalAnnotation_1.
@Test
public void testTerminalAnnotation_1() throws Exception {
Resource resource = getResourceFromString("grammar org.xtext.Supergrammar with org.eclipse.xtext.common.Terminals\n" + "generate supergrammar \"http://org.xtext.supergrammar\"\n" + "Rule: name=ID;\n" + "@Exported\n" + "terminal TERMINAL: ID;");
Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
List<Diagnostic> issues = diag.getChildren();
assertEquals(issues.toString(), 1, issues.size());
assertEquals("TerminalRule cannot be exported!", issues.get(0).getMessage());
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_282852_02.
@Test
public void testBug_282852_02() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "Model: name=ID ref='bar';\n" + "terminal Id: 'a'..'z'+;");
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(), 2, 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 testEnumRuleReturnsEClass.
@Test
public void testEnumRuleReturnsEClass() throws Exception {
XtextResource resource = getResourceFromStringAndExpect("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "generate testLanguage 'http://www.eclipse.org/2011/xtext/bug348749'\n" + "Model: element=Enum;\n" + "enum Enum returns Model: A | B;", 1);
assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
assertTrue(resource.getWarnings().toString(), resource.getWarnings().isEmpty());
Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
assertNotNull("diag", diag);
assertEquals(diag.getChildren().toString(), 0, diag.getChildren().size());
assertEquals("diag.isOk", diag.getSeverity(), Diagnostic.OK);
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testLeftRecursion_Bug_285605_08.
@Test
public void testLeftRecursion_Bug_285605_08() 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 : '_' (ruleA+=RuleA)* name=ID;\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.getSeverity(), Diagnostic.OK);
assertTrue(diag.getChildren().toString(), diag.getChildren().isEmpty());
}
Aggregations