Search in sources :

Example 36 with Parameter

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

the class NoJdtTestLanguageSemanticSequencer 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 == NoJdtPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case NoJdtPackage.GREETING:
                sequence_Greeting(context, (Greeting) semanticObject);
                return;
            case NoJdtPackage.MODEL:
                sequence_Model(context, (Model) semanticObject);
                return;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Greeting(org.eclipse.xtext.testlanguages.noJdt.noJdt.Greeting) Action(org.eclipse.xtext.Action) Model(org.eclipse.xtext.testlanguages.noJdt.noJdt.Model) Parameter(org.eclipse.xtext.Parameter) EPackage(org.eclipse.emf.ecore.EPackage)

Example 37 with Parameter

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

the class FollowElementCalculator method caseGroup.

@Override
public Boolean caseGroup(Group object) {
    boolean more = true;
    if (object.getGuardCondition() != null) {
        Set<Parameter> parameterValues = getParameterValues(object);
        more = new ConditionEvaluator(parameterValues).evaluate(object.getGuardCondition());
    }
    if (more) {
        for (AbstractElement element : object.getElements()) {
            more = more && doSwitch(element);
        }
    }
    return more || isOptional(object);
}
Also used : ConditionEvaluator(org.eclipse.xtext.xtext.ConditionEvaluator) AbstractElement(org.eclipse.xtext.AbstractElement) Parameter(org.eclipse.xtext.Parameter)

Example 38 with Parameter

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

the class RequiredRuleNameComputer method adjustRuleName.

protected String adjustRuleName(String ruleName, Param param) {
    AbstractElement elementToParse = param.elementToParse;
    Set<Parameter> context = getAssignedParameters(elementToParse, param.paramStack);
    if (!context.isEmpty()) {
        ParserRule containingRule = GrammarUtil.containingParserRule(elementToParse);
        String antlrRuleName = ruleNames.getAntlrRuleName(containingRule);
        int len = antlrRuleName.length();
        if (antlrRuleName.startsWith("rule")) {
            // rule__XYZ instead of ruleXYZ
            len += 2;
        }
        int config = getParameterConfig(context);
        String result = ruleNames.getAntlrRuleName(containingRule, config) + ruleName.substring(len);
        return result;
    }
    return ruleName;
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) AbstractElement(org.eclipse.xtext.AbstractElement) Parameter(org.eclipse.xtext.Parameter)

Example 39 with Parameter

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

the class RequiredRuleNameComputer method getRequiredRuleNames.

/**
 * @since 2.14
 */
protected String[][] getRequiredRuleNames(Param param, AbstractElement elementToParse) {
    if (elementToParse instanceof RuleCall) {
        RuleCall call = (RuleCall) elementToParse;
        if (call.getRule() instanceof ParserRule) {
            String antlrRuleName = ruleNames.getAntlrRuleName(call.getRule());
            if (!call.getArguments().isEmpty()) {
                Set<Parameter> context = param.getAssignedParametes();
                Set<Parameter> arguments = getAssignedArguments(call, context);
                int config = getParameterConfig(arguments);
                antlrRuleName = ruleNames.getAntlrRuleName(call.getRule(), config);
            }
            return new String[][] { { antlrRuleName } };
        }
    }
    return EMPTY_ARRAY;
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) Parameter(org.eclipse.xtext.Parameter) RuleCall(org.eclipse.xtext.RuleCall)

Example 40 with Parameter

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

the class PartialContentAssistTestLanguageSemanticSequencer 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 == PartialContentAssistTestLanguagePackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case PartialContentAssistTestLanguagePackage.PROPERTY:
                sequence_Property(context, (Property) semanticObject);
                return;
            case PartialContentAssistTestLanguagePackage.TYPE_DECLARATION:
                sequence_TypeDeclaration(context, (TypeDeclaration) 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) Property(org.eclipse.xtext.ide.tests.testlanguage.partialContentAssistTestLanguage.Property) TypeDeclaration(org.eclipse.xtext.ide.tests.testlanguage.partialContentAssistTestLanguage.TypeDeclaration) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

Parameter (org.eclipse.xtext.Parameter)146 ParserRule (org.eclipse.xtext.ParserRule)137 Action (org.eclipse.xtext.Action)127 EPackage (org.eclipse.emf.ecore.EPackage)123 NamedArgument (org.eclipse.xtext.NamedArgument)7 EClass (org.eclipse.emf.ecore.EClass)6 ISerializationContext (org.eclipse.xtext.serializer.ISerializationContext)6 AbstractElement (org.eclipse.xtext.AbstractElement)5 AbstractRule (org.eclipse.xtext.AbstractRule)5 RuleCall (org.eclipse.xtext.RuleCall)5 EObject (org.eclipse.emf.ecore.EObject)4 ParserRuleParameters (org.eclipse.xtext.parser.parameters.parametersTestLanguage.ParserRuleParameters)4 Scenario (org.eclipse.xtext.parser.parameters.parametersTestLanguage.Scenario)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 Group (org.eclipse.xtext.Group)3 ConditionEvaluator (org.eclipse.xtext.xtext.ConditionEvaluator)3 Set (java.util.Set)2 Assignment (org.eclipse.xtext.Assignment)2 EnumRule (org.eclipse.xtext.EnumRule)2 Grammar (org.eclipse.xtext.Grammar)2