Search in sources :

Example 61 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.

the class XtextValidationTest method testLeftRecursion_Bug_285605_16.

@Test
public void testLeftRecursion_Bug_285605_16() 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.getSeverity(), Diagnostic.OK);
    assertTrue(diag.getChildren().toString(), diag.getChildren().isEmpty());
}
Also used : Diagnostic(org.eclipse.emf.common.util.Diagnostic) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 62 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.

the class XtextValidationTest method testBug_283534_05.

@Test
public void testBug_283534_05() throws Exception {
    XtextResource resource = getResourceFromString("grammar org.foo.Bar with org.eclipse.xtext.common.Terminals\n" + "generate metamodel 'myURI'\n" + "enum EnumRule: Zonk;\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);
}
Also used : Diagnostic(org.eclipse.emf.common.util.Diagnostic) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 63 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.

the class XtextValidationTest method testLeftRecursion_Bug_285605_14.

@Test
public void testLeftRecursion_Bug_285605_14() 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);
}
Also used : Diagnostic(org.eclipse.emf.common.util.Diagnostic) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 64 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.

the class XtextValidationTest method testLeftRecursion_Bug_285605_13.

@Test
public void testLeftRecursion_Bug_285605_13() 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.getChildren().toString(), 4, diag.getChildren().size());
    assertEquals("diag.isError", diag.getSeverity(), Diagnostic.ERROR);
}
Also used : Diagnostic(org.eclipse.emf.common.util.Diagnostic) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 65 with Diagnostic

use of org.eclipse.emf.common.util.Diagnostic in project xtext-core by eclipse.

the class XtextValidationTest method testLeftRecursion_Bug_285605_17.

@Test
public void testLeftRecursion_Bug_285605_17() 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());
}
Also used : Diagnostic(org.eclipse.emf.common.util.Diagnostic) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Aggregations

Diagnostic (org.eclipse.emf.common.util.Diagnostic)73 Test (org.junit.Test)63 XtextResource (org.eclipse.xtext.resource.XtextResource)56 EObject (org.eclipse.emf.ecore.EObject)11 BasicDiagnostic (org.eclipse.emf.common.util.BasicDiagnostic)6 Resource (org.eclipse.emf.ecore.resource.Resource)6 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)5 LazyLinkingResource (org.eclipse.xtext.linking.lazy.LazyLinkingResource)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 EPackage (org.eclipse.emf.ecore.EPackage)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 StringInputStream (org.eclipse.xtext.util.StringInputStream)2 AbstractValidationDiagnostic (org.eclipse.xtext.validation.AbstractValidationDiagnostic)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 Generator (org.eclipse.emf.codegen.ecore.generator.Generator)1