Java Code Examples for org.eclipse.xtext.RuleCall#getRule()
The following examples show how to use
org.eclipse.xtext.RuleCall#getRule() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractUnassignedTextTestLanguageSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getCaseInsensitiveKeywordRule()) return getCaseInsensitiveKeywordToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getDatatypeRule()) return getDatatypeToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getGroupDataTypeRuleRule()) return getGroupDataTypeRuleToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getIDRule()) return getIDToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getINTRule()) return getINTToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getMultiRule()) return getMultiToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getPluralRule()) return getPluralToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getSTRINGRule()) return getSTRINGToken(semanticObject, ruleCall, node); return ""; }
Example 2
Source File: SequenceFeeder.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected void acceptRuleCall(RuleCall rc, Object value, String token, int index, INode node) { CrossReference crossRef = GrammarUtil.containingCrossReference(rc); if (crossRef != null) { if (rc.getRule() instanceof ParserRule) sequenceAcceptor.acceptAssignedCrossRefDatatype(rc, token, (EObject) value, index, getCompositeNode(node)); else if (rc.getRule() instanceof TerminalRule) sequenceAcceptor.acceptAssignedCrossRefTerminal(rc, token, (EObject) value, index, getLeafNode(node)); else if (rc.getRule() instanceof EnumRule) sequenceAcceptor.acceptAssignedCrossRefEnum(rc, token, (EObject) value, index, getCompositeNode(node)); } else { if (rc.getRule() instanceof ParserRule) { AbstractRule rule = rc.getRule(); if (rule.getType() != null && rule.getType().getClassifier() instanceof EClass) acceptEObjectRuleCall(rc, (EObject) value, getCompositeNode(node)); else sequenceAcceptor.acceptAssignedDatatype(rc, token, value, index, getCompositeNode(node)); } else if (rc.getRule() instanceof TerminalRule) sequenceAcceptor.acceptAssignedTerminal(rc, token, value, index, getLeafNode(node)); else if (rc.getRule() instanceof EnumRule) sequenceAcceptor.acceptAssignedEnum(rc, token, value, index, getCompositeNode(node)); } }
Example 3
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Check public void checkTerminalFragmentCalledFromTerminalRule(final RuleCall call) { if (call.getRule() != null && !call.getRule().eIsProxy()) { if (call.getRule() instanceof TerminalRule && ((TerminalRule) call.getRule()).isFragment()) { AbstractRule container = GrammarUtil.containingRule(call); if (!(container instanceof TerminalRule)) { getMessageAcceptor().acceptError( "Only terminal rules may use terminal fragments.", call, XtextPackage.Literals.RULE_CALL__RULE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } } } }
Example 4
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Check public void checkCallToDeprecatedParserRule(RuleCall ruleCall) { AbstractRule calledRule = ruleCall.getRule(); if(hasAnnotation(calledRule, AnnotationNames.DEPRECATED)) { addIssue("The called rule is marked as deprecated.", ruleCall, XtextPackage.eINSTANCE.getRuleCall_Rule(), XtextConfigurableIssueCodes.USAGE_OF_DEPRECATED_RULE); } }
Example 5
Source File: IndentationAwareUiTestLanguageSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getDEDENTRule()) return getDEDENTToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getINDENTRule()) return getINDENTToken(semanticObject, ruleCall, node); return ""; }
Example 6
Source File: CodetemplatesProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void completeNestedAssignment(Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor, TemplateData data) { String proposalText = "${" + assignment.getFeature() + "}"; StyledString displayText; if (assignment.getTerminal() instanceof RuleCall) { RuleCall ruleCall = (RuleCall) assignment.getTerminal(); AbstractRule calledRule = ruleCall.getRule(); displayText = new StyledString("${", StyledString.DECORATIONS_STYLER) .append(assignment.getFeature(), null) .append("}", StyledString.DECORATIONS_STYLER) .append(" - ", StyledString.QUALIFIER_STYLER) .append(calledRule.getName(), StyledString.COUNTER_STYLER) .append(" - Create a new template variable", StyledString.QUALIFIER_STYLER); } else { displayText = new StyledString("${", StyledString.DECORATIONS_STYLER) .append(assignment.getFeature(), null) .append("}", StyledString.DECORATIONS_STYLER) .append(" - Create a new template variable", StyledString.QUALIFIER_STYLER); } ICompletionProposal proposal = createCompletionProposal(proposalText, displayText, null, context); if (proposal instanceof ConfigurableCompletionProposal) { ConfigurableCompletionProposal configurable = (ConfigurableCompletionProposal) proposal; configurable.setSelectionStart(configurable.getReplacementOffset() + 2); configurable.setSelectionLength(proposalText.length() - 3); configurable.setAutoInsertable(false); configurable.setSimpleLinkedMode(context.getViewer(), '\t'); configurable.setPriority(configurable.getPriority() * 2); } acceptor.accept(proposal); }
Example 7
Source File: Bug301935ExTestLanguageSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getNLRule()) return getNLToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getWSRule()) return getWSToken(semanticObject, ruleCall, node); return ""; }
Example 8
Source File: UnassignedRuleCallTestLanguageSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getDataTypeRuleRule()) return getDataTypeRuleToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getINTRule()) return getINTToken(semanticObject, ruleCall, node); return ""; }
Example 9
Source File: SARLSyntacticSequencer.java From sarl with Apache License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getArrayBracketsRule()) return getArrayBracketsToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getOpSingleAssignRule()) return getOpSingleAssignToken(semanticObject, ruleCall, node); return ""; }
Example 10
Source File: GrammarElementTitleSwitch.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public String caseRuleCall(RuleCall object) { AbstractRule rule = object.getRule(); String ruleName; if (rule != null && !rule.eIsProxy()) ruleName = rule.getName(); else ruleName = "unresolved_rule"; return addCrossRefOrAssignemnt(ruleName, object) + card(object); }
Example 11
Source File: XbaseIdeContentProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@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); } }
Example 12
Source File: AbstractXbaseSyntacticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getArrayBracketsRule()) return getArrayBracketsToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getOpSingleAssignRule()) return getOpSingleAssignToken(semanticObject, ruleCall, node); return ""; }
Example 13
Source File: CurrentTypeFinder.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Boolean caseRuleCall(RuleCall object) { EClassifier wasType = currentType; AbstractRule calledRule = object.getRule(); if (currentType == null) { if (calledRule instanceof ParserRule && !GrammarUtil.isDatatypeRule((ParserRule) calledRule)) { ParserRule parserRule = (ParserRule) calledRule; if (parserRule.isFragment()) { if (context.getType() != null) currentType = context.getType().getClassifier(); if (!parserRule.isWildcard()) { doSwitch(parserRule); } } else { TypeRef returnType = calledRule.getType(); if (returnType != null) { currentType = returnType.getClassifier(); } } } } else if (isFragmentButNotWildcard(calledRule)) { doSwitch(calledRule); } if (object == stopElement) return true; if (GrammarUtil.isOptionalCardinality(object)) currentType = getCompatibleType(currentType, wasType, object); return false; }
Example 14
Source File: N4JSSyntacticSequencer.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getNO_LINE_TERMINATORRule()) return getNO_LINE_TERMINATORToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getSemiRule()) return getSemiToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getTemplateExpressionEndRule()) return getTemplateExpressionEndToken(semanticObject, ruleCall, node); return ""; }
Example 15
Source File: GH1462TestLanguageSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getINTRule()) return getINTToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getIntegerRule()) return getIntegerToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getMaybeEmptyRule()) return getMaybeEmptyToken(semanticObject, ruleCall, node); return ""; }
Example 16
Source File: Bug288760TestLanguageSyntacticSequencer.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getEND_TAG_SHORTRule()) return getEND_TAG_SHORTToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getEQRule()) return getEQToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getGTRule()) return getGTToken(semanticObject, ruleCall, node); return ""; }
Example 17
Source File: AbstractCheckSyntacticSequencer.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getArrayBracketsRule()) return getArrayBracketsToken(semanticObject, ruleCall, node); else if (ruleCall.getRule() == grammarAccess.getOpSingleAssignRule()) return getOpSingleAssignToken(semanticObject, ruleCall, node); return ""; }
Example 18
Source File: GenericSyntacticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected String getUnassignedRuleCallToken(RuleCall ruleCall, INode node) { if (node != null) return node.getText().trim(); AbstractRule rule = ruleCall.getRule(); if (GrammarUtil.isDatatypeRule(rule)) { if (rule.getAlternatives() instanceof Keyword) return ((Keyword) rule.getAlternatives()).getValue(); if (rule.getAlternatives() instanceof Alternatives) for (AbstractElement ele : ((Alternatives) rule.getAlternatives()).getElements()) if (ele instanceof Keyword) return ((Keyword) ele).getValue(); } return ""; }
Example 19
Source File: UsedRulesFinder.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public Void caseRuleCall(RuleCall object) { if (object.getRule() != null) return doSwitch(object.getRule()); return null; }
Example 20
Source File: SingleCodetemplateSyntacticSequencer.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) { if (ruleCall.getRule() == grammarAccess.getWSRule()) return getWSToken(semanticObject, ruleCall, node); return ""; }