Search in sources :

Example 1 with Import

use of org.eclipse.xtext.example.arithmetics.arithmetics.Import in project xtext-eclipse by eclipse.

the class ArithmeticsSemanticSequencer 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 == ArithmeticsPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case ArithmeticsPackage.DECLARED_PARAMETER:
                sequence_DeclaredParameter(context, (DeclaredParameter) semanticObject);
                return;
            case ArithmeticsPackage.DEFINITION:
                sequence_Definition(context, (Definition) semanticObject);
                return;
            case ArithmeticsPackage.DIV:
                sequence_Multiplication(context, (Div) semanticObject);
                return;
            case ArithmeticsPackage.EVALUATION:
                sequence_Evaluation(context, (Evaluation) semanticObject);
                return;
            case ArithmeticsPackage.FUNCTION_CALL:
                sequence_PrimaryExpression(context, (FunctionCall) semanticObject);
                return;
            case ArithmeticsPackage.IMPORT:
                sequence_Import(context, (Import) semanticObject);
                return;
            case ArithmeticsPackage.MINUS:
                sequence_Addition(context, (Minus) semanticObject);
                return;
            case ArithmeticsPackage.MODULE:
                sequence_Module(context, (org.eclipse.xtext.example.arithmetics.arithmetics.Module) semanticObject);
                return;
            case ArithmeticsPackage.MULTI:
                sequence_Multiplication(context, (Multi) semanticObject);
                return;
            case ArithmeticsPackage.NUMBER_LITERAL:
                sequence_PrimaryExpression(context, (NumberLiteral) semanticObject);
                return;
            case ArithmeticsPackage.PLUS:
                sequence_Addition(context, (Plus) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Evaluation(org.eclipse.xtext.example.arithmetics.arithmetics.Evaluation) Action(org.eclipse.xtext.Action) Import(org.eclipse.xtext.example.arithmetics.arithmetics.Import) Definition(org.eclipse.xtext.example.arithmetics.arithmetics.Definition) Multi(org.eclipse.xtext.example.arithmetics.arithmetics.Multi) EPackage(org.eclipse.emf.ecore.EPackage) Div(org.eclipse.xtext.example.arithmetics.arithmetics.Div) DeclaredParameter(org.eclipse.xtext.example.arithmetics.arithmetics.DeclaredParameter) Parameter(org.eclipse.xtext.Parameter) FunctionCall(org.eclipse.xtext.example.arithmetics.arithmetics.FunctionCall) DeclaredParameter(org.eclipse.xtext.example.arithmetics.arithmetics.DeclaredParameter) Plus(org.eclipse.xtext.example.arithmetics.arithmetics.Plus) Minus(org.eclipse.xtext.example.arithmetics.arithmetics.Minus) NumberLiteral(org.eclipse.xtext.example.arithmetics.arithmetics.NumberLiteral)

Example 2 with Import

use of org.eclipse.xtext.example.arithmetics.arithmetics.Import in project xtext-eclipse by eclipse.

the class ArithmeticsScopeProvider method getScope.

@Override
public IScope getScope(EObject context, EReference reference) {
    if (reference == ArithmeticsPackage.Literals.IMPORT__MODULE) {
        return super.getGlobalScope(context.eResource(), reference);
    }
    Module module = EcoreUtil2.getContainerOfType(context, Module.class);
    IScope result = IScope.NULLSCOPE;
    for (Import i : module.getImports()) {
        if (!i.getModule().eIsProxy()) {
            result = getModuleScope(context, reference, i.getModule(), result);
        }
    }
    result = getModuleScope(context, reference, module, result);
    return getDefinitionScope(context, reference, result);
}
Also used : Import(org.eclipse.xtext.example.arithmetics.arithmetics.Import) IScope(org.eclipse.xtext.scoping.IScope) Module(org.eclipse.xtext.example.arithmetics.arithmetics.Module)

Aggregations

Import (org.eclipse.xtext.example.arithmetics.arithmetics.Import)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 DeclaredParameter (org.eclipse.xtext.example.arithmetics.arithmetics.DeclaredParameter)1 Definition (org.eclipse.xtext.example.arithmetics.arithmetics.Definition)1 Div (org.eclipse.xtext.example.arithmetics.arithmetics.Div)1 Evaluation (org.eclipse.xtext.example.arithmetics.arithmetics.Evaluation)1 FunctionCall (org.eclipse.xtext.example.arithmetics.arithmetics.FunctionCall)1 Minus (org.eclipse.xtext.example.arithmetics.arithmetics.Minus)1 Module (org.eclipse.xtext.example.arithmetics.arithmetics.Module)1 Multi (org.eclipse.xtext.example.arithmetics.arithmetics.Multi)1 NumberLiteral (org.eclipse.xtext.example.arithmetics.arithmetics.NumberLiteral)1 Plus (org.eclipse.xtext.example.arithmetics.arithmetics.Plus)1 IScope (org.eclipse.xtext.scoping.IScope)1