Search in sources :

Example 1 with Element

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

the class InheritanceTest3LanguageSemanticSequencer 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:
                if (rule == grammarAccess.getInheritanceTestLanguageElementRule()) {
                    sequence_Element(context, (Element) semanticObject);
                    return;
                } else if (rule == grammarAccess.getElementRule()) {
                    sequence_Element_Element(context, (Element) semanticObject);
                    return;
                } else
                    break;
            case InheritanceTestPackage.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) Model(org.eclipse.xtext.grammarinheritance.inheritanceTest.Model) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 2 with Element

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

the class ParserTest method test_02.

@Test
public void test_02() throws Exception {
    Model model = (Model) getModel("model id { element inheritedIdSyntax }");
    assertEquals("id", model.getName());
    Element element = model.getElements().get(0);
    assertEquals("inheritedIdSyntax", element.getName());
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
    assertTrue(nodesForFeature.size() == 1);
    assertEquals("inheritedIdSyntax", 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 3 with Element

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

the class ParserTest method test_01.

@Test
public void test_01() throws Exception {
    Model model = (Model) getModel("model id { element id }");
    assertEquals("id", model.getName());
    Element element = model.getElements().get(0);
    assertEquals("id", element.getName());
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
    assertTrue(nodesForFeature.size() == 1);
    assertEquals("id", 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 4 with Element

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

the class ParserTest method test_05.

@Test
public void test_05() throws Exception {
    Model model = (Model) getModel("model id { element withNumbers01 }");
    assertEquals("id", model.getName());
    Element element = model.getElements().get(0);
    assertEquals("withNumbers01", element.getName());
    List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(element, InheritanceTestPackage.Literals.ELEMENT__NAME);
    assertTrue(nodesForFeature.size() == 1);
    assertEquals("withNumbers01", 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 5 with Element

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

the class AbstractInheritanceTestLanguageSemanticSequencer 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;
            case InheritanceTestPackage.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) Model(org.eclipse.xtext.grammarinheritance.inheritanceTest.Model) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

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