Search in sources :

Example 1 with TransformationDiagnostic

use of org.eclipse.xtext.xtext.ecoreInference.TransformationDiagnostic in project xtext-core by eclipse.

the class GrammarParserTest method testEnum_11.

@Test
public void testEnum_11() throws Exception {
    String modelAsString = "grammar TestLanguage with org.eclipse.xtext.enumrules.EnumRulesTestLanguage\n" + "import 'classpath:/org/eclipse/xtext/enumrules/enums.ecore' as existing\n" + "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/11'\n" + "Model: enumValue=ExistingEnum;\n" + "enum ExistingEnum: SameName;";
    Grammar grammar = (Grammar) getModelAndExpect(modelAsString, 1);
    assertEquals(grammar.eResource().getErrors().toString(), 1, grammar.eResource().getErrors().size());
    TransformationDiagnostic diag = (TransformationDiagnostic) grammar.eResource().getErrors().get(0);
    int offset = diag.getOffset();
    assertEquals(modelAsString.lastIndexOf("ExistingEnum"), offset);
}
Also used : TransformationDiagnostic(org.eclipse.xtext.xtext.ecoreInference.TransformationDiagnostic) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Example 2 with TransformationDiagnostic

use of org.eclipse.xtext.xtext.ecoreInference.TransformationDiagnostic in project xtext-core by eclipse.

the class Xtext2EcoreTransformerTest method testBug_280413_04.

@Test
public void testBug_280413_04() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("grammar test with org.eclipse.xtext.testlanguages.SimpleExpressionsTestLanguage");
    _builder.newLine();
    _builder.append("generate test \'http://test\'");
    _builder.newLine();
    _builder.append("import \'classpath:/org/eclipse/xtext/testlanguages/SimpleExpressionsTestLanguage.ecore\' as mm");
    _builder.newLine();
    _builder.append("Atom returns mm::Atom: name=ID;");
    _builder.newLine();
    final String grammar = _builder.toString();
    final XtextResource resource = this.getResourceFromStringAndExpect(grammar, 1);
    Assert.assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
    Resource.Diagnostic _get = resource.getErrors().get(0);
    TransformationDiagnostic diagnostic = ((TransformationDiagnostic) _get);
    Assert.assertEquals(grammar.indexOf("mm::Atom"), diagnostic.getOffset());
    Assert.assertEquals("mm::Atom".length(), diagnostic.getLength());
}
Also used : TransformationDiagnostic(org.eclipse.xtext.xtext.ecoreInference.TransformationDiagnostic) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 3 with TransformationDiagnostic

use of org.eclipse.xtext.xtext.ecoreInference.TransformationDiagnostic in project xtext-core by eclipse.

the class GrammarParserTest method testEnum_09.

@Test
public void testEnum_09() throws Exception {
    String modelAsString = "grammar TestLanguage with org.eclipse.xtext.common.Terminals\n" + "import 'classpath:/org/eclipse/xtext/enumrules/enums.ecore'\n" + "generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/9'\n" + "Model: enumValue=ExistingEnum;\n" + "enum ExistingEnum: SameName | Absent | SameName;";
    Grammar grammar = (Grammar) getModelAndExpect(modelAsString, 1);
    assertEquals(grammar.eResource().getErrors().toString(), 1, grammar.eResource().getErrors().size());
    TransformationDiagnostic diag = (TransformationDiagnostic) grammar.eResource().getErrors().get(0);
    int offset = diag.getOffset();
    assertEquals(modelAsString.lastIndexOf("Absent"), offset);
}
Also used : TransformationDiagnostic(org.eclipse.xtext.xtext.ecoreInference.TransformationDiagnostic) Grammar(org.eclipse.xtext.Grammar) Test(org.junit.Test)

Aggregations

TransformationDiagnostic (org.eclipse.xtext.xtext.ecoreInference.TransformationDiagnostic)3 Test (org.junit.Test)3 Grammar (org.eclipse.xtext.Grammar)2 Resource (org.eclipse.emf.ecore.resource.Resource)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1