Search in sources :

Example 11 with ParserRule

use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.

the class EcoreFragmentTestLanguageSemanticSequencer 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 == SecondPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case SecondPackage.SECOND:
                sequence_Second(context, (Second) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Second(org.eclipse.xtext.generator.ecore.second.Second) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 12 with ParserRule

use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.

the class SubTestLanguageSemanticSequencer 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 == SubPackagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case SubPackagePackage.ANOTHER_SUPER_MAIN:
                sequence_AnotherSuperMain(context, (AnotherSuperMain) semanticObject);
                return;
            case SubPackagePackage.SUB_MAIN:
                sequence_SubMain(context, (SubMain) semanticObject);
                return;
        }
    else if (epackage == SuperPackagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case SuperPackagePackage.SUPER_MAIN:
                sequence_SuperMain(context, (SuperMain) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) Parameter(org.eclipse.xtext.Parameter) SubMain(org.eclipse.xtext.generator.ecore.subPackage.SubMain) AnotherSuperMain(org.eclipse.xtext.generator.ecore.subPackage.AnotherSuperMain) EPackage(org.eclipse.emf.ecore.EPackage)

Example 13 with ParserRule

use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.

the class GrammarAccessTestLanguageSemanticSequencer 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 == AsubpackagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case AsubpackagePackage.AMODEL:
                sequence_Root(context, (AModel) semanticObject);
                return;
            case AsubpackagePackage.ATYPE:
                sequence_AType(context, (AType) semanticObject);
                return;
        }
    else if (epackage == SubsubpackagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case SubsubpackagePackage.ANOTHER_TYPE:
                sequence_AnotherType(context, (AnotherType) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : AType(org.eclipse.xtext.generator.grammarAccess.ametamodel.asubpackage.AType) ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) AModel(org.eclipse.xtext.generator.grammarAccess.ametamodel.asubpackage.AModel) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 14 with ParserRule

use of org.eclipse.xtext.ParserRule in project xtext-core by eclipse.

the class AbstractAbstractTestLanguageSemanticSequencer 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 == AmetamodelPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case AmetamodelPackage.AMODEL:
                if (rule == grammarAccess.getAbstractCallExtendedParserRuleRule()) {
                    sequence_AbstractCallExtendedParserRule(context, (AModel) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAbstractCallOverridenParserRuleRule()) {
                    sequence_AbstractCallOverridenParserRule(context, (AModel) semanticObject);
                    return;
                } else
                    break;
            case AmetamodelPackage.ATYPE:
                if (rule == grammarAccess.getExtendableParserRuleRule()) {
                    sequence_ExtendableParserRule(context, (AType) semanticObject);
                    return;
                } else if (rule == grammarAccess.getInheritedParserRuleRule()) {
                    sequence_InheritedParserRule(context, (AType) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOverridableParserRule2Rule()) {
                    sequence_OverridableParserRule2(context, (AType) semanticObject);
                    return;
                } else if (rule == grammarAccess.getOverridableParserRuleRule()) {
                    sequence_OverridableParserRule(context, (AType) semanticObject);
                    return;
                } else
                    break;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : AType(org.eclipse.xtext.grammarinheritance.ametamodel.AType) ParserRule(org.eclipse.xtext.ParserRule) Action(org.eclipse.xtext.Action) AModel(org.eclipse.xtext.grammarinheritance.ametamodel.AModel) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 15 with ParserRule

use of org.eclipse.xtext.ParserRule 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)

Aggregations

ParserRule (org.eclipse.xtext.ParserRule)380 Test (org.junit.Test)172 Grammar (org.eclipse.xtext.Grammar)151 Action (org.eclipse.xtext.Action)144 Parameter (org.eclipse.xtext.Parameter)137 EPackage (org.eclipse.emf.ecore.EPackage)126 AbstractRule (org.eclipse.xtext.AbstractRule)94 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)74 AbstractXtextRuleInspectorTest (org.eclipse.xtext.xtext.AbstractXtextRuleInspectorTest)49 RuleCall (org.eclipse.xtext.RuleCall)41 EObject (org.eclipse.emf.ecore.EObject)27 EnumRule (org.eclipse.xtext.EnumRule)21 TerminalRule (org.eclipse.xtext.TerminalRule)21 AbstractElement (org.eclipse.xtext.AbstractElement)18 Assignment (org.eclipse.xtext.Assignment)15 UnorderedGroup (org.eclipse.xtext.UnorderedGroup)12 EClass (org.eclipse.emf.ecore.EClass)11 Group (org.eclipse.xtext.Group)11 NamedArgument (org.eclipse.xtext.NamedArgument)11 TypeRef (org.eclipse.xtext.TypeRef)11