use of org.eclipse.xtext.resource.XtextResource in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testBug_272566_2.
@Test
public void testBug_272566_2() throws Exception {
String grammar = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate test 'http://test'\n" + "Model:\n" + " test=Test\n" + ";\n" + "\n" + "Test:\n" + " 'keyword' FooBar name=ID\n" + ";\n" + "FooBar:\n" + "\t'zonk' WS WS INT WS;\n";
XtextResource resource = getResourceFromString(grammar);
Assert.assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
}
use of org.eclipse.xtext.resource.XtextResource in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testBug_287550_01.
@Test
public void testBug_287550_01() throws Exception {
String grammar = "grammar language with org.eclipse.xtext.common.Terminals\n" + "generate myDsl 'http://example.xtext.org/MyDsl'\n" + "Model: Left | Right;\n" + "Left: Delegate;\n" + "Right returns Model: Delegate '=';\n" + "Delegate returns Left: value=ID;\n";
XtextResource resource = getResourceFromString(grammar);
Assert.assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size());
}
use of org.eclipse.xtext.resource.XtextResource in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testEclipseIssue1547.
@Test
public void testEclipseIssue1547() throws Exception {
String grammarAsString = "grammar test with org.eclipse.xtext.common.Terminals\n" + "generate myDsl 'uri'\n" + "Model: element=Element;\n" + "enum Element : //das ist ein test\n^false='false' | true='true';\n";
XtextResource resource = getResourceFromString(grammarAsString);
Grammar g = (Grammar) resource.getContents().get(0);
EnumRule enumRule = (EnumRule) g.getRules().get(1);
EnumLiteralDeclaration eld1 = (EnumLiteralDeclaration) ((Alternatives) enumRule.getAlternatives()).getElements().get(0);
EnumLiteralDeclaration eld2 = (EnumLiteralDeclaration) ((Alternatives) enumRule.getAlternatives()).getElements().get(1);
Assert.assertEquals("false", eld1.getEnumLiteral().getName());
Assert.assertEquals("true", eld2.getEnumLiteral().getName());
}
use of org.eclipse.xtext.resource.XtextResource in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testContainmentVsReference_05.
@Test
public void testContainmentVsReference_05() throws Exception {
String grammar = "grammar test with org.eclipse.xtext.common.Terminals import 'http://www.eclipse.org/emf/2002/Ecore' EReference: name=ID eContainingClass=[EClass];";
XtextResource resource = getResourceFromStringAndExpect(grammar, 1);
Assert.assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
}
use of org.eclipse.xtext.resource.XtextResource in project xtext-core by eclipse.
the class Xtext2EcoreTransformerTest method testContainmentVsReference_01.
@Test
public void testContainmentVsReference_01() throws Exception {
String grammar = "grammar test with org.eclipse.xtext.common.Terminals import 'http://www.eclipse.org/emf/2002/Ecore' EClass: name=ID eSuperTypes+=EClass;";
XtextResource resource = getResourceFromStringAndExpect(grammar, 1);
Assert.assertEquals(resource.getErrors().toString(), 1, resource.getErrors().size());
}
Aggregations