Search in sources :

Example 11 with Element

use of org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element in project xtext-core by eclipse.

the class Bug317840Test method getFirstElement.

public Element getFirstElement(String model) throws Exception {
    Model m = getModel(model);
    Element element = m.getElements().get(0);
    return element;
}
Also used : Element(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element) Model(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Model)

Example 12 with Element

use of org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element in project xtext-core by eclipse.

the class Bug317840Test method testSemanticModel_09.

@Test
public void testSemanticModel_09() throws Exception {
    Element element = getFirstElement("element a.a b.b c.c d.d");
    assertEquals("a.a", element.getFirst().getName());
    assertEquals("b.b", element.getSecond().getName());
    assertEquals(1, element.getThird().size());
    assertEquals("c.c", element.getThird().get(0).getName());
    assertEquals(1, element.getForth().size());
    assertEquals("d.d", element.getForth().get(0).getName());
}
Also used : Element(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element) Test(org.junit.Test)

Example 13 with Element

use of org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element in project xtext-core by eclipse.

the class Bug317840TestLanguageSemanticSequencer 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 == Bug317840TestLanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case Bug317840TestLanguagePackage.ELEMENT:
                sequence_Element(context, (Element) semanticObject);
                return;
            case Bug317840TestLanguagePackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
            case Bug317840TestLanguagePackage.NAMED:
                sequence_Named(context, (Named) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Named(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Named) Action(org.eclipse.xtext.Action) Element(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element) Model(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Model) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 14 with Element

use of org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element in project xtext-core by eclipse.

the class Bug317840Test method testSemanticModel_01.

@Test
public void testSemanticModel_01() throws Exception {
    Element element = getFirstElement("element a");
    assertEquals("a", element.getFirst().getName());
    assertNull(element.getSecond());
    assertTrue(element.getThird().isEmpty());
    assertTrue(element.getForth().isEmpty());
}
Also used : Element(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element) Test(org.junit.Test)

Example 15 with Element

use of org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element in project xtext-core by eclipse.

the class Bug317840Test method testSemanticModel_07.

@Test
public void testSemanticModel_07() throws Exception {
    Element element = getFirstElement("element a.a b.b");
    assertEquals("a.a", element.getFirst().getName());
    assertEquals("b.b", element.getSecond().getName());
    assertTrue(element.getThird().isEmpty());
    assertTrue(element.getForth().isEmpty());
}
Also used : Element(org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element) Test(org.junit.Test)

Aggregations

Element (org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Element)22 Test (org.junit.Test)20 INode (org.eclipse.xtext.nodemodel.INode)10 Model (org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Model)2 EPackage (org.eclipse.emf.ecore.EPackage)1 Action (org.eclipse.xtext.Action)1 Parameter (org.eclipse.xtext.Parameter)1 ParserRule (org.eclipse.xtext.ParserRule)1 Named (org.eclipse.xtext.parser.terminalrules.bug317840TestLanguage.Named)1