Search in sources :

Example 21 with Diagnostic

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

Example 22 with Diagnostic

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

Example 23 with Diagnostic

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

Example 24 with Diagnostic

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

Example 25 with Diagnostic

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);
}
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