use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class CrossContainmentTest method testCrossContainment_01.
@Test
public void testCrossContainment_01() {
XtextResourceSet resourceSet = get(XtextResourceSet.class);
resourceSet.setClasspathURIContext(getClass());
Resource resource = resourceSet.createResource(URI.createFileURI("container.xmi"));
Resource childResource = resourceSet.createResource(URI.createFileURI("child.xmi"));
CrossResourceContainerManyChildren container = PartialParsingTestUtilFactory.eINSTANCE.createCrossResourceContainerManyChildren();
resource.getContents().add(container);
Grammar grammar = XtextFactory.eINSTANCE.createGrammar();
childResource.getContents().add(grammar);
assertNull(grammar.eContainer());
container.getChildren().add(grammar);
assertSame(container, grammar.eContainer());
assertSame(childResource, grammar.eResource());
assertSame(resource, container.eResource());
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class CrossContainmentTest method testCrossContainment_02.
@Test
public void testCrossContainment_02() {
XtextResourceSet resourceSet = get(XtextResourceSet.class);
resourceSet.setClasspathURIContext(getClass());
Resource resource = resourceSet.createResource(URI.createFileURI("container.xmi"));
Resource childResource = resourceSet.createResource(URI.createFileURI("child.xmi"));
CrossResourceContainerOneChild container = PartialParsingTestUtilFactory.eINSTANCE.createCrossResourceContainerOneChild();
resource.getContents().add(container);
Grammar grammar = XtextFactory.eINSTANCE.createGrammar();
childResource.getContents().add(grammar);
assertNull(grammar.eContainer());
container.setChild(grammar);
assertSame(container, grammar.eContainer());
assertSame(childResource, grammar.eResource());
assertSame(resource, container.eResource());
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class Bug290919Test method testBug2900919.
@Test
public void testBug2900919() throws Exception {
String grammarAsString = "grammar org.xtext.example.MyDsl with org.eclipse.xtext.common.Terminals\n" + "generate myDsl \"http://www.xtext.org/example/MyDsl\"\n" + "\n" + "TModel :\n" + " element=TElement\n" + ";\n" + "\n" + "TElement :\n" + " TSimpleElement | TSimpleElement2\n" + ";\n" + "\n" + "TSimpleElement:\n" + "(annotations+=TAnnotation)*\n" + "'simpleElement' name=ID\n" + ";\n" + "\n" + "TSimpleElement2:\n" + "(annotations+=TAnnotation)*\n" + "'simpleElement2' name=ID ;\n" + "\n" + "\n" + "TAnnotation:\n" + " TDescriptionAnnotation | TUuidAnnotation\n" + ";\n" + "\n" + "TDescriptionAnnotation:\n" + " value = STRING \n" + ";\n" + "\n" + "TUuidAnnotation:\n" + " value = INT\n" + ";";
Grammar grammar = (Grammar) getModel(grammarAsString);
GrammarWithoutLeftRecursionInspector inspector = new GrammarWithoutLeftRecursionInspector(this);
inspector.inspect(grammar);
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class KeywordInspectorTest method testBug285146_02.
@Test
public void testBug285146_02() throws Exception {
String grammarAsString = "grammar org.xtext.example.MyDsl7 with org.eclipse.xtext.common.Terminals\n" + "generate myDsl \"http://www.xtext.org/example/MyDsl\"\n" + "Type : 'type' '#' name=ID;\n" + "terminal POUND: '#'?;";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "Type");
validateRule(rule);
assertEquals(errors.toString(), 0, errors.size());
}
use of org.eclipse.xtext.Grammar in project xtext-core by eclipse.
the class KeywordInspectorTest method testBug285146_04.
@Test
public void testBug285146_04() throws Exception {
String grammarAsString = "grammar org.xtext.example.MyDsl7 with org.eclipse.xtext.common.Terminals\n" + "generate myDsl \"http://www.xtext.org/example/MyDsl\"\n" + "Type : 'type' '#' name=ID;\n" + "terminal POUND: '#' '#';";
Grammar grammar = getGrammar(grammarAsString);
ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "Type");
validateRule(rule);
assertEquals(errors.toString(), 0, errors.size());
}
Aggregations