Search in sources :

Example 41 with Assignment

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

the class SequenceFeeder method accept.

public void accept(Keyword keyword, Object value, String token, ILeafNode node) {
    Assignment ass = getAssignment(keyword);
    EStructuralFeature feature = getFeature(ass.getFeature());
    assertIndex(feature);
    assertValue(feature, value);
    acceptKeyword(ass, keyword, value, token, ISemanticSequenceAcceptor.NO_INDEX, node);
}
Also used : Assignment(org.eclipse.xtext.Assignment) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature)

Example 42 with Assignment

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

the class SequenceFeeder method accept.

public void accept(Keyword keyword, Object value, String token, int index, ILeafNode node) {
    Assignment ass = getAssignment(keyword);
    EStructuralFeature feature = getFeature(ass.getFeature());
    assertIndex(feature, index);
    assertValue(feature, value);
    acceptKeyword(ass, keyword, value, token, index, node);
}
Also used : Assignment(org.eclipse.xtext.Assignment) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature)

Example 43 with Assignment

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

the class ContentAssistFragment2 method handleAssignment.

private StringConcatenationClient handleAssignment(final Assignment assignment) {
    StringConcatenationClient _xblockexpression = null;
    {
        final Function1<Assignment, Boolean> _function = (Assignment it) -> {
            String _feature = it.getFeature();
            String _feature_1 = assignment.getFeature();
            return Boolean.valueOf(Objects.equal(_feature, _feature_1));
        };
        final Function1<Assignment, AbstractElement> _function_1 = (Assignment it) -> {
            return it.getTerminal();
        };
        final List<AbstractElement> terminals = IterableExtensions.<AbstractElement>toList(IterableExtensions.<Assignment, AbstractElement>map(IterableExtensions.<Assignment>filter(GrammarUtil.containedAssignments(GrammarUtil.containingParserRule(assignment)), _function), _function_1));
        final Function1<AbstractElement, EClass> _function_2 = (AbstractElement it) -> {
            return it.eClass();
        };
        final Set<EClass> terminalTypes = IterableExtensions.<EClass>toSet(ListExtensions.<AbstractElement, EClass>map(terminals, _function_2));
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("public void complete");
                String _fQFeatureName = ContentAssistFragment2.this.getFQFeatureName(assignment);
                _builder.append(_fQFeatureName);
                _builder.append("(");
                _builder.append(EObject.class);
                _builder.append(" model, ");
                _builder.append(Assignment.class);
                _builder.append(" assignment, ");
                TypeReference _contentAssistContextClass = ContentAssistFragment2.this.getContentAssistContextClass();
                _builder.append(_contentAssistContextClass);
                _builder.append(" context, ");
                TypeReference _iCompletionProposalAcceptorClass = ContentAssistFragment2.this.getICompletionProposalAcceptorClass();
                _builder.append(_iCompletionProposalAcceptorClass);
                _builder.append(" acceptor) {");
                _builder.newLineIfNotEmpty();
                {
                    int _size = terminalTypes.size();
                    boolean _greaterThan = (_size > 1);
                    if (_greaterThan) {
                        _builder.append("\t");
                        StringConcatenationClient _handleAssignmentOptions = ContentAssistFragment2.this.handleAssignmentOptions(terminals);
                        _builder.append(_handleAssignmentOptions, "\t");
                        _builder.newLineIfNotEmpty();
                    } else {
                        _builder.append("\t");
                        AbstractElement _terminal = assignment.getTerminal();
                        StringConcatenationClient _client = new StringConcatenationClient() {

                            @Override
                            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                                _builder.append("assignment.getTerminal()");
                            }
                        };
                        StringConcatenationClient _assignmentTerminal = ContentAssistFragment2.this.assignmentTerminal(_terminal, _client);
                        _builder.append(_assignmentTerminal, "\t");
                        _builder.newLineIfNotEmpty();
                    }
                }
                _builder.append("}");
                _builder.newLine();
            }
        };
        _xblockexpression = _client;
    }
    return _xblockexpression;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) AbstractElement(org.eclipse.xtext.AbstractElement) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) Assignment(org.eclipse.xtext.Assignment) EClass(org.eclipse.emf.ecore.EClass) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) List(java.util.List) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 44 with Assignment

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

the class XtextSemanticSequencer 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 == XtextPackage.eINSTANCE)
        switch(semanticObject.eClass().getClassifierID()) {
            case XtextPackage.ACTION:
                if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
                    sequence_AbstractTokenWithCardinality_Action(context, (Action) semanticObject);
                    return;
                } else if (rule == grammarAccess.getActionRule()) {
                    sequence_Action(context, (Action) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.ALTERNATIVES:
                if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
                    sequence_AbstractTokenWithCardinality_Alternatives(context, (Alternatives) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0()) {
                    sequence_AssignableAlternatives(context, (Alternatives) semanticObject);
                    return;
                } else if (rule == grammarAccess.getEnumLiteralsRule()) {
                    sequence_EnumLiterals(context, (Alternatives) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_TerminalAlternatives_TerminalToken(context, (Alternatives) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.ANNOTATION:
                sequence_Annotation(context, (Annotation) semanticObject);
                return;
            case XtextPackage.ASSIGNMENT:
                if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
                    sequence_AbstractTokenWithCardinality_Assignment(context, (Assignment) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAssignmentRule()) {
                    sequence_Assignment(context, (Assignment) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.CHARACTER_RANGE:
                if (rule == grammarAccess.getCharacterRangeRule()) {
                    sequence_CharacterRange(context, (CharacterRange) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_CharacterRange_TerminalToken(context, (CharacterRange) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.CONJUNCTION:
                sequence_Conjunction(context, (Conjunction) semanticObject);
                return;
            case XtextPackage.CROSS_REFERENCE:
                sequence_CrossReference(context, (CrossReference) semanticObject);
                return;
            case XtextPackage.DISJUNCTION:
                sequence_Disjunction(context, (Disjunction) semanticObject);
                return;
            case XtextPackage.EOF:
                if (rule == grammarAccess.getEOFRule()) {
                    sequence_EOF(context, (EOF) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_EOF_TerminalToken(context, (EOF) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.ENUM_LITERAL_DECLARATION:
                sequence_EnumLiteralDeclaration(context, (EnumLiteralDeclaration) semanticObject);
                return;
            case XtextPackage.ENUM_RULE:
                sequence_EnumRule(context, (EnumRule) semanticObject);
                return;
            case XtextPackage.GENERATED_METAMODEL:
                sequence_GeneratedMetamodel(context, (GeneratedMetamodel) semanticObject);
                return;
            case XtextPackage.GRAMMAR:
                sequence_Grammar(context, (Grammar) semanticObject);
                return;
            case XtextPackage.GROUP:
                if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
                    sequence_AbstractTokenWithCardinality_ConditionalBranch_Group_PredicatedGroup(context, (Group) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPredicatedGroupRule()) {
                    sequence_PredicatedGroup(context, (Group) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_TerminalGroup_TerminalToken(context, (Group) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.KEYWORD:
                if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
                    sequence_AbstractTokenWithCardinality_Keyword_PredicatedKeyword(context, (Keyword) semanticObject);
                    return;
                } else if (rule == grammarAccess.getKeywordRule() || rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getCrossReferenceableTerminalRule() || rule == grammarAccess.getCharacterRangeRule() || action == grammarAccess.getCharacterRangeAccess().getCharacterRangeLeftAction_1_0()) {
                    sequence_Keyword(context, (Keyword) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_Keyword_TerminalToken(context, (Keyword) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPredicatedKeywordRule()) {
                    sequence_PredicatedKeyword(context, (Keyword) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.LITERAL_CONDITION:
                sequence_LiteralCondition(context, (LiteralCondition) semanticObject);
                return;
            case XtextPackage.NAMED_ARGUMENT:
                sequence_NamedArgument(context, (NamedArgument) semanticObject);
                return;
            case XtextPackage.NEGATED_TOKEN:
                if (rule == grammarAccess.getAbstractNegatedTokenRule() || rule == grammarAccess.getNegatedTokenRule()) {
                    sequence_NegatedToken(context, (NegatedToken) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_NegatedToken_TerminalToken(context, (NegatedToken) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.NEGATION:
                sequence_Negation(context, (Negation) semanticObject);
                return;
            case XtextPackage.PARAMETER:
                sequence_Parameter(context, (Parameter) semanticObject);
                return;
            case XtextPackage.PARAMETER_REFERENCE:
                sequence_ParameterReference(context, (ParameterReference) semanticObject);
                return;
            case XtextPackage.PARSER_RULE:
                sequence_ParserRule_RuleNameAndParams(context, (ParserRule) semanticObject);
                return;
            case XtextPackage.REFERENCED_METAMODEL:
                sequence_ReferencedMetamodel(context, (ReferencedMetamodel) semanticObject);
                return;
            case XtextPackage.RULE_CALL:
                if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
                    sequence_AbstractTokenWithCardinality_PredicatedRuleCall_RuleCall(context, (RuleCall) semanticObject);
                    return;
                } else if (rule == grammarAccess.getPredicatedRuleCallRule()) {
                    sequence_PredicatedRuleCall(context, (RuleCall) semanticObject);
                    return;
                } else if (rule == grammarAccess.getRuleCallRule() || rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getCrossReferenceableTerminalRule()) {
                    sequence_RuleCall(context, (RuleCall) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalRuleCallRule()) {
                    sequence_TerminalRuleCall(context, (RuleCall) semanticObject);
                    return;
                } else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_TerminalRuleCall_TerminalToken(context, (RuleCall) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.TERMINAL_RULE:
                sequence_TerminalRule(context, (TerminalRule) semanticObject);
                return;
            case XtextPackage.TYPE_REF:
                sequence_TypeRef(context, (TypeRef) semanticObject);
                return;
            case XtextPackage.UNORDERED_GROUP:
                sequence_AbstractTokenWithCardinality_UnorderedGroup(context, (UnorderedGroup) semanticObject);
                return;
            case XtextPackage.UNTIL_TOKEN:
                if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_TerminalToken_UntilToken(context, (UntilToken) semanticObject);
                    return;
                } else if (rule == grammarAccess.getAbstractNegatedTokenRule() || rule == grammarAccess.getUntilTokenRule()) {
                    sequence_UntilToken(context, (UntilToken) semanticObject);
                    return;
                } else
                    break;
            case XtextPackage.WILDCARD:
                if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
                    sequence_TerminalToken_Wildcard(context, (Wildcard) semanticObject);
                    return;
                } else if (rule == grammarAccess.getWildcardRule()) {
                    sequence_Wildcard(context, (Wildcard) semanticObject);
                    return;
                } else
                    break;
        }
    if (errorAcceptor != null)
        errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) Group(org.eclipse.xtext.Group) Action(org.eclipse.xtext.Action) EnumLiteralDeclaration(org.eclipse.xtext.EnumLiteralDeclaration) Negation(org.eclipse.xtext.Negation) TypeRef(org.eclipse.xtext.TypeRef) RuleCall(org.eclipse.xtext.RuleCall) EPackage(org.eclipse.emf.ecore.EPackage) Assignment(org.eclipse.xtext.Assignment) EnumRule(org.eclipse.xtext.EnumRule) GeneratedMetamodel(org.eclipse.xtext.GeneratedMetamodel) LiteralCondition(org.eclipse.xtext.LiteralCondition) Wildcard(org.eclipse.xtext.Wildcard) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) Conjunction(org.eclipse.xtext.Conjunction) NamedArgument(org.eclipse.xtext.NamedArgument) EOF(org.eclipse.xtext.EOF) ReferencedMetamodel(org.eclipse.xtext.ReferencedMetamodel) Keyword(org.eclipse.xtext.Keyword) ParameterReference(org.eclipse.xtext.ParameterReference) Grammar(org.eclipse.xtext.Grammar) Alternatives(org.eclipse.xtext.Alternatives) Annotation(org.eclipse.xtext.Annotation) Disjunction(org.eclipse.xtext.Disjunction) Parameter(org.eclipse.xtext.Parameter) CrossReference(org.eclipse.xtext.CrossReference) CharacterRange(org.eclipse.xtext.CharacterRange) UntilToken(org.eclipse.xtext.UntilToken) NegatedToken(org.eclipse.xtext.NegatedToken) TerminalRule(org.eclipse.xtext.TerminalRule)

Example 45 with Assignment

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

the class Formatter2Fragment2 method getLocallyAssignedContainmentReferences.

protected void getLocallyAssignedContainmentReferences(final Grammar grammar, final Multimap<EClass, EReference> type2ref) {
    List<Assignment> _containedAssignments = GrammarUtil.containedAssignments(grammar);
    for (final Assignment assignment : _containedAssignments) {
        {
            final EClassifier type = GrammarUtil.findCurrentType(assignment);
            if ((type instanceof EClass)) {
                final EStructuralFeature feature = ((EClass) type).getEStructuralFeature(assignment.getFeature());
                if (((feature instanceof EReference) && ((EReference) feature).isContainment())) {
                    type2ref.put(((EClass) type), ((EReference) feature));
                }
            }
        }
    }
    List<Action> _containedActions = GrammarUtil.containedActions(grammar);
    for (final Action action : _containedActions) {
        {
            final String featureName = action.getFeature();
            if ((featureName != null)) {
                final EClassifier type = action.getType().getClassifier();
                if ((type instanceof EClass)) {
                    final EStructuralFeature feature = ((EClass) type).getEStructuralFeature(featureName);
                    if (((feature instanceof EReference) && ((EReference) feature).isContainment())) {
                        type2ref.put(((EClass) type), ((EReference) feature));
                    }
                }
            }
        }
    }
}
Also used : Assignment(org.eclipse.xtext.Assignment) EClass(org.eclipse.emf.ecore.EClass) Action(org.eclipse.xtext.Action) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) EClassifier(org.eclipse.emf.ecore.EClassifier) EReference(org.eclipse.emf.ecore.EReference)

Aggregations

Assignment (org.eclipse.xtext.Assignment)60 EObject (org.eclipse.emf.ecore.EObject)27 Test (org.junit.Test)25 RuleCall (org.eclipse.xtext.RuleCall)22 Grammar (org.eclipse.xtext.Grammar)21 AbstractElement (org.eclipse.xtext.AbstractElement)15 ParserRule (org.eclipse.xtext.ParserRule)15 ILeafNode (org.eclipse.xtext.nodemodel.ILeafNode)14 Action (org.eclipse.xtext.Action)13 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)12 AbstractRule (org.eclipse.xtext.AbstractRule)12 Group (org.eclipse.xtext.Group)11 UnorderedGroup (org.eclipse.xtext.UnorderedGroup)9 Alternatives (org.eclipse.xtext.Alternatives)8 CrossReference (org.eclipse.xtext.CrossReference)7 ArrayList (java.util.ArrayList)6 EClass (org.eclipse.emf.ecore.EClass)6 InternalEObject (org.eclipse.emf.ecore.InternalEObject)6 NamedArgument (org.eclipse.xtext.NamedArgument)6 LiteralCondition (org.eclipse.xtext.LiteralCondition)5