Search in sources :

Example 6 with Element

use of org.eclipse.xtext.grammarinheritance.inheritanceTest.Element in project xtext-core by eclipse.

the class InheritanceTest2LanguageSemanticSequencer method sequence.

@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
    EPackage epackage = semanticObject.eClass().getEPackage();
    ParserRule rule = context.getParserRule();
    Action action = context.getAssignedAction();
    Set<Parameter> parameters = context.getEnabledBooleanParameters();
    if (epackage == InheritanceTestPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case InheritanceTestPackage.ELEMENT:
                sequence_Element(context, (Element) semanticObject);
                return;
        }
    else if (epackage == InheritanceTest2Package.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case InheritanceTest2Package.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Element(org.eclipse.xtext.grammarinheritance.inheritanceTest.Element) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 7 with Element

use of org.eclipse.xtext.grammarinheritance.inheritanceTest.Element in project xtext-core by eclipse.

the class ParserTest method test_03.

@Test
public void test_03() throws Exception {
    Model model = (Model) getModel("model id { element 'string' }");
    assertEquals("id", model.getName());
    Element element = model.getElements().get(0);
    assertEquals("string", element.getName());
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
    assertTrue(nodesForFeature.size() == 1);
    assertEquals("'string'", nodesForFeature.get(0).getText());
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) Element(org.eclipse.xtext.grammarinheritance.inheritanceTest.Element) Model(org.eclipse.xtext.grammarinheritance.inheritanceTest.Model) Test(org.junit.Test)

Example 8 with Element

use of org.eclipse.xtext.grammarinheritance.inheritanceTest.Element in project xtext-core by eclipse.

the class ParserTest method test_04.

@Test
public void test_04() throws Exception {
    Model model = (Model) getModel("model id { element 'with spaces' }");
    assertEquals("id", model.getName());
    Element element = model.getElements().get(0);
    assertEquals("with spaces", element.getName());
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
    assertTrue(nodesForFeature.size() == 1);
    assertEquals("'with spaces'", nodesForFeature.get(0).getText());
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) Element(org.eclipse.xtext.grammarinheritance.inheritanceTest.Element) Model(org.eclipse.xtext.grammarinheritance.inheritanceTest.Model) Test(org.junit.Test)

Aggregations

Element (org.eclipse.xtext.grammarinheritance.inheritanceTest.Element)8 Model (org.eclipse.xtext.grammarinheritance.inheritanceTest.Model)7 INode (org.eclipse.xtext.nodemodel.INode)5 Test (org.junit.Test)5 EPackage (org.eclipse.emf.ecore.EPackage)3 Action (org.eclipse.xtext.Action)3 Parameter (org.eclipse.xtext.Parameter)3 ParserRule (org.eclipse.xtext.ParserRule)3