use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.
the class XtextValidationTest method testBug_281660.
@Test
public void testBug_281660() throws Exception {
XtextResource resource = getResourceFromStringAndExpect("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "generate foo 'http://foo/bar'\n" + "RuleA : foo += [RuleB] ('->' foo+=RuleB)*;\n" + "RuleB : 'holla' name=ID;", 1);
assertTrue(resource.getErrors().toString(), resource.getErrors().size() == 1);
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 testOverrideDeprecated_1.
@Test
public void testOverrideDeprecated_1() throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
getResourceFromString("grammar org.xtext.Supergrammar with org.eclipse.xtext.common.Terminals\n" + "generate supergrammar \"http://org.xtext.supergrammar\"\n" + "@Deprecated\n" + "RuleDeprecated: name=ID;\n" + "Rule: name=ID;", "superGrammar.xtext", rs);
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.xtext.Supergrammar\n" + "generate bar \"http://org.xtext.Bar\"\n" + "@Override RuleDeprecated: name=ID;", "foo.xtext", rs);
Diagnostic diag = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
List<Diagnostic> issues = diag.getChildren();
assertEquals(issues.toString(), 1, issues.size());
assertEquals("This rule overrides RuleDeprecated in org.xtext.Supergrammar which is deprecated.", 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 testExplicitOverride03.
@Test
public void testExplicitOverride03() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "@Override\n" + "terminal ID_2: ('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("The rule ID_2 does not override a rule from a super grammar.", 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 testEnumWithEmptyLiteralImported.
@Test
public void testEnumWithEmptyLiteralImported() throws Exception {
XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "import 'classpath:/org/eclipse/xtext/enumrules/enums.ecore'\n" + "generate test 'http://foo'\n" + "Model: name=ID;\n" + "enum ExistingEnum: SameName | DifferentName='Diff' | OverriddenLiteral='';");
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(), 1, 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_282852_01.
@Test
public void testBug_282852_01() 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" + "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(), 2, diag.getChildren().size());
assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
}
Aggregations