@Override public AbstractElement getRoot() { return GrammarUtil.containingRule(context).getAlternatives(); } }
@Override public StringBuilder caseParameterReference(ParameterReference object) { Parameter param = object.getParameter(); if (includeRuleName) { AbstractRule declaringRule = GrammarUtil.containingRule(param); result.append('$').append(getRuleName(declaringRule)).append('.'); } result.append("p_").append(param.getName()); return result; } @Override
protected Map<TreeConstState, Integer> getEndDistances() { AbstractElement rootEle = containingRule(element).getAlternatives(); TreeConstState root = builder.getState(rootEle); if (root.endDistances == null) root.endDistances = Maps.newLinkedHashMap(); return root.endDistances; }
/** * Returns the invocation of the element accessor method for a GrammarAccess * as Java statement. * Example: prStatemachine().ele1AssignmentStates() */ public String gaRuleElementAccessor(final AbstractElement ele) { String _gaElementsAccessor = this.gaElementsAccessor(GrammarUtil.containingRule(ele)); String _plus = (_gaElementsAccessor + "."); String _gaElementAccessor = this.gaElementAccessor(ele); return (_plus + _gaElementAccessor); }
protected CharSequence paramConfig(final AbstractElement it) { StringConcatenation _builder = new StringConcatenation(); { if ((((GrammarUtil.containingRule(it).getAlternatives() == it) && ParserRule.class.isInstance(GrammarUtil.containingRule(it))) && (!((ParserRule) AntlrGrammarGenUtil.<AbstractRule>getOriginalElement(GrammarUtil.containingRule(it))).getParameters().isEmpty()))) { _builder.append(", "); AbstractRule _containingRule = GrammarUtil.containingRule(it); int _parameterConfig = AntlrGrammarGenUtil.getParameterConfig(((ParserRule) _containingRule)); _builder.append(_parameterConfig); _builder.newLineIfNotEmpty(); } } return _builder; }
@SuppressWarnings({ "rawtypes", "unchecked" }) public List<T> getIncommingWithoutRuleCalls() { List<T> result = Lists.newArrayList(); AbstractElement rootEle = containingRule(element).getAlternatives(); ((AbstractNFAState) builder.getState(rootEle)).collectReferencesToThis(this, Sets.newHashSet(), result); return result; }
protected String _grammarElementIdentifier(final AbstractElement it) { String _grammarElementIdentifier = this.grammarElementIdentifier(GrammarUtil.containingRule(it)); String _plus = (_grammarElementIdentifier + "_"); String _gaElementIdentifier = this.gaElementIdentifier(it); return (_plus + _gaElementIdentifier); }
protected boolean filter(AbstractElement ele) { AbstractRule rule = GrammarUtil.containingRule(ele); if (rule == null || !(rule.getType().getClassifier() instanceof EClass)) return true; return builder.filter(ele); }
/** * Find the type of the current variable after an AbstractElement was consumed. * If the AbstractElement will instantiate a new type (e.g. is an Action), * the instantiated type will be returned. If the element may occur in a * path that leads to an unassigned current element, <code>null</code> may * be returned. If the element is optional and changes the type, this method * will return the changed type as if the element were consumed. */ public EClassifier findCurrentTypeAfter(AbstractElement element) { final AbstractRule rule = GrammarUtil.containingRule(element); Implementation implementation = new Implementation(); implementation.computeResult(rule, element); return implementation.getResult(); }
public Status getStatus() { if (distances == null) { AbstractElement rootEle = containingRule(element).getAlternatives(); builder.getState(rootEle).initStatus(); } return getStatusInternal(); }
public String serializeUnassignedValue(EObject context, RuleCall ruleCall, INode node) { String r = serializeUnassignedValueByRuleCall(ruleCall, context, node); if (r != null) return r; r = serializeUnassignedValueByRule(ruleCall.getRule(), context, node); if (r != null) return r; if (node != null) return ITokenSerializer.KEEP_VALUE_FROM_NODE_MODEL; throw new IllegalArgumentException("Could not determine the value for the unassigned rulecall of rule " + ruleCall.getRule().getName() + " from within rule " + GrammarUtil.containingRule(ruleCall).getName() + ". You might want to implement " + IValueSerializer.class.getName() + ".serializeUnassignedValue() or modify your implementation to handle this rulecall."); }
/** * @since 2.0 */ protected EClass getConstructedType(AbstractElement ele) { if (ele instanceof Action) return (EClass) ((Action) ele).getType().getClassifier(); if (GrammarUtil.containingAssignment(ele) != null) return (EClass) GrammarUtil.containingRule(ele).getType().getClassifier(); return null; }
@Override protected void _createProposals(final RuleCall ruleCall, final ContentAssistContext context, final IIdeContentProposalAcceptor acceptor) { AbstractRule _rule = ruleCall.getRule(); boolean _matched = false; ParserRule _xExpressionRule = this._xbaseGrammarAccess.getXExpressionRule(); if (Objects.equal(_rule, _xExpressionRule)) { _matched=true; if (((ruleCall.eContainer() instanceof Group) && Objects.equal(GrammarUtil.containingRule(ruleCall).getName(), "XParenthesizedExpression"))) { this.createLocalVariableAndImplicitProposals(context.getCurrentModel(), IExpressionScope.Anchor.WITHIN, context, acceptor); } } if (!_matched) { super._createProposals(ruleCall, context, acceptor); } }
public Set<EObject> collectConsumedEObjects() { Set<EObject> result = new HashSet<EObject>(); for (AbstractToken endToken : getDeadends()) { AbstractToken currentToken = endToken; while (currentToken.getNext() != null && currentToken.getNext().getLastRuleCallOrigin() != null && currentToken.getNext().getLastRuleCallOrigin().getGrammarElement() != null) { if (GrammarUtil.containingRule(currentToken.getNext().getLastRuleCallOrigin().getGrammarElement()) == GrammarUtil .containingRule(currentToken.getGrammarElement())) result.add(currentToken.getNext().getEObjectConsumer().getEObject()); currentToken = currentToken.getNext(); } } return result; }
protected void installAfter(IAfterElement pattern) { Set<MatcherState> states = getAllStates(pattern.matchAfter()); AbstractRule rule = GrammarUtil.containingRule(pattern.matchAfter()); for (MatcherState state : states) { state.getAfterPatterns().add(pattern); for (MatcherTransition out : state.isParserRuleCall() ? state.getOutgoingAfterReturn() : state .getOutgoing()) if (pattern.matchAfter() == out.getLoopCenter() || !states.contains(out.getTarget())) out.addPattern(pattern); if (state.isEndState()) for (MatcherState caller : findRuleCallsTo(rule, Sets.<AbstractRule> newHashSet())) for (MatcherTransition afterReturn : caller.getOutgoingAfterReturn()) afterReturn.addPattern(state, pattern); } }
public void inspectKeywordHidesTerminalRule(Keyword keyword) { AbstractRule container = GrammarUtil.containingRule(keyword); if (container instanceof TerminalRule) return; Grammar grammar = GrammarUtil.getGrammar(container); List<TerminalRule> rules = GrammarUtil.allTerminalRules(grammar); for(TerminalRule rule: rules) { AbstractElement element = rule.getAlternatives(); if (element instanceof Keyword && Strings.isEmpty(element.getCardinality())) { String value = ((Keyword) element).getValue(); if (value.equals(keyword.getValue())) acceptor.acceptError("The keyword '" + value + "' hides the terminal rule " + rule.getName()+ ".", keyword, XtextPackage.Literals.KEYWORD__VALUE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } } }
@Override protected String _ebnf2(final UnorderedGroup it, final AntlrOptions options, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); String _contentAssistRuleName = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it)); _builder.append(_contentAssistRuleName); _builder.append("__"); String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it)); _builder.append(_gaElementIdentifier); return _builder.toString(); }
@Override protected String _ebnf2(final Alternatives it, final AntlrOptions options, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); String _contentAssistRuleName = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it)); _builder.append(_contentAssistRuleName); _builder.append("__"); String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<Alternatives>getOriginalElement(it)); _builder.append(_gaElementIdentifier); return _builder.toString(); }
@Override protected String _ebnf2(final Assignment it, final AntlrOptions options, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); String _contentAssistRuleName = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it)); _builder.append(_contentAssistRuleName); _builder.append("__"); String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<Assignment>getOriginalElement(it)); _builder.append(_gaElementIdentifier); return _builder.toString(); }
@Override protected String _ebnf2(final Group it, final AntlrOptions options, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); String _contentAssistRuleName = AntlrGrammarGenUtil.getContentAssistRuleName(GrammarUtil.containingRule(it)); _builder.append(_contentAssistRuleName); _builder.append("__"); String _gaElementIdentifier = this._grammarAccessExtensions.gaElementIdentifier(AntlrGrammarGenUtil.<Group>getOriginalElement(it)); _builder.append(_gaElementIdentifier); _builder.append("__0"); return _builder.toString(); }