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