use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testBug_280413_01.
@Test
public void testBug_280413_01() throws Exception {
XtextResource resource = getResourceFromStringAndExpect("grammar org.foo.Bar with org.eclipse.xtext.testlanguages.SimpleExpressionsTestLanguage\n" + "import 'classpath:/org/eclipse/xtext/testlanguages/SimpleExpressionsTestLanguage.ecore' as mm\n" + "Atom returns mm::Atom: name = ID;", 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(), 2, diag.getChildren().size());
assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
ReferencedMetamodel metamodel = (ReferencedMetamodel) diag.getChildren().get(0).getData().get(0);
assertNotNull(metamodel);
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testLeftRecursion_Bug_285605_02.
@Test
public void testLeftRecursion_Bug_285605_02() 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 : ruleA=RuleA;");
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(), 3, 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_280413_02.
@Test
public void testBug_280413_02() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.Xtext\n" + "import 'http://www.eclipse.org/2008/Xtext' as xtext\n" + "@Override\n" + "ParserRule returns xtext::ParserRule: name = ID;");
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());
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testLeftRecursion_Bug_285605_18.
@Test
public void testLeftRecursion_Bug_285605_18() 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.toString(), diag.getSeverity(), Diagnostic.OK);
assertTrue(diag.getChildren().toString(), diag.getChildren().isEmpty());
}
use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testBug_283534_06.
@Test
public void testBug_283534_06() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "terminal TERMINAL: 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.getChildren().toString(), 0, diag.getChildren().size());
assertEquals("diag.isOk", diag.getSeverity(), Diagnostic.OK);
}
Aggregations