本文整理匯總了Java中org.eclipse.xtext.RuleCall.getRule方法的典型用法代碼示例。如果您正苦於以下問題:Java RuleCall.getRule方法的具體用法?Java RuleCall.getRule怎麽用?Java RuleCall.getRule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.xtext.RuleCall
的用法示例。
在下文中一共展示了RuleCall.getRule方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
if (ruleCall.getRule() == grammarAccess.getNOT_WORD_BOUNDARYRule())
return getNOT_WORD_BOUNDARYToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getWORD_BOUNDARYRule())
return getWORD_BOUNDARYToken(semanticObject, ruleCall, node);
return "";
}
示例2: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@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 "";
}
示例3: installProxies
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
/**
* Installs proxies for all non containment references and only if the node representing the EObject that contains
* the cross reference has got leaf nodes (as a leaf node represents the cross reference).
*
* @param resource
* the N4JSResource
* @param obj
* the EObject containing the cross reference
* @param producer
* the error/warning producer
* @param parentNode
* the node representing obj inside the node model
*/
private void installProxies(N4JSResource resource, EObject obj, IDiagnosticProducer producer,
ICompositeNode parentNode, boolean dontCheckParent) {
final EClass eClass = obj.eClass();
if (eClass.getEAllReferences().size() - eClass.getEAllContainments().size() == 0)
return;
for (INode node = parentNode.getFirstChild(); node != null; node = node.getNextSibling()) {
EObject grammarElement = node.getGrammarElement();
if (grammarElement instanceof CrossReference && hasLeafNodes(node)) {
producer.setNode(node);
CrossReference crossReference = (CrossReference) grammarElement;
final EReference eRef = GrammarUtil.getReference(crossReference, eClass);
if (eRef == null) {
ParserRule parserRule = GrammarUtil.containingParserRule(crossReference);
final String feature = GrammarUtil.containingAssignment(crossReference).getFeature();
throw new IllegalStateException("Couldn't find EReference for crossreference '" + eClass.getName()
+ "::" + feature + "' in parser rule '" + parserRule.getName() + "'.");
}
createAndSetProxy(resource, obj, node, eRef, crossReference, producer);
afterCreateAndSetProxy(obj, node, eRef, crossReference, producer);
} else if (grammarElement instanceof RuleCall && node instanceof ICompositeNode) {
RuleCall ruleCall = (RuleCall) grammarElement;
AbstractRule calledRule = ruleCall.getRule();
if (calledRule instanceof ParserRule && ((ParserRule) calledRule).isFragment()) {
installProxies(resource, obj, producer, (ICompositeNode) node, true);
}
}
}
if (!dontCheckParent && shouldCheckParentNode(parentNode)) {
installProxies(resource, obj, producer, parentNode.getParent(), dontCheckParent);
}
}
示例4: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@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.getCommentRule())
return getCommentToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getNEWLINERule())
return getNEWLINEToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getOpSingleAssignRule())
return getOpSingleAssignToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getWSRule())
return getWSToken(semanticObject, ruleCall, node);
return "";
}
示例5: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
if (ruleCall.getRule() == grammarAccess.getBLOCK_BEGINRule())
return getBLOCK_BEGINToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getBLOCK_ENDRule())
return getBLOCK_ENDToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getBRACKET_CLOSERule())
return getBRACKET_CLOSEToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getBRACKET_OPENRule())
return getBRACKET_OPENToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getEQRule())
return getEQToken(semanticObject, ruleCall, node);
return "";
}
示例6: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
if(ruleCall.getRule() == grammarAccess.getASRule())
return getASToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getDEFRule())
return getDEFToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getEXPORTRule())
return getEXPORTToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getGENERATERule())
return getGENERATEToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getIMPORTRule())
return getIMPORTToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getINCLUDERule())
return getINCLUDEToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getKRONUS_ASSIGNRule())
return getKRONUS_ASSIGNToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getPACKAGERule())
return getPACKAGEToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getRETURNRule())
return getRETURNToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getTYPERule())
return getTYPEToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getVALRule())
return getVALToken(semanticObject, ruleCall, node);
else if(ruleCall.getRule() == grammarAccess.getWITHRule())
return getWITHToken(semanticObject, ruleCall, node);
return "";
}
示例7: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
if (ruleCall.getRule() == grammarAccess.getSEPARATORRule())
return getSEPARATORToken(semanticObject, ruleCall, node);
else if (ruleCall.getRule() == grammarAccess.getSPACERule())
return getSPACEToken(semanticObject, ruleCall, node);
return "";
}
示例8: getRequiredRuleNames
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@SuppressWarnings("restriction")
@Override
public String[][] getRequiredRuleNames(Param param) {
if (isFiltered(param)) {
return EMPTY_ARRAY;
}
AbstractElement elementToParse = param.elementToParse;
String ruleName = param.ruleName;
if (ruleName == null) {
if (elementToParse instanceof RuleCall) {
RuleCall call = (RuleCall) elementToParse;
if (call.getRule() instanceof ParserRule) {
String antlrRuleName = getRuleNames().getAntlrRuleName(call.getRule());
if (!call.getArguments().isEmpty()) {
Set<Parameter> context = param.getAssignedParametes();
Set<Parameter> arguments = getAssignedArguments(call, context);
int config = getParameterConfig(arguments);
antlrRuleName = getRuleNames().getAntlrRuleName(call.getRule(), config);
}
return new String[][] { { antlrRuleName } };
}
}
return EMPTY_ARRAY;
}
String adjustedRuleName = adjustRuleName(ruleName, param);
if (!(GrammarUtil.isOptionalCardinality(elementToParse)
|| GrammarUtil.isOneOrMoreCardinality(elementToParse))) {
return new String[][] { { adjustedRuleName } };
}
if ((elementToParse.eContainer() instanceof Group)) {
List<AbstractElement> tokens = getFilteredElements(((Group) elementToParse.eContainer()).getElements(),
param);
int idx = tokens.indexOf(elementToParse) + 1;
if (idx != tokens.size()) {
String secondRule = param.getBaseRuleName((AbstractElement) elementToParse.eContainer());
secondRule = secondRule.substring(0, secondRule.lastIndexOf('_') + 1) + idx;
String adjustedSecondRule = adjustRuleName(secondRule, param);
if (GrammarUtil.isMultipleCardinality(elementToParse))
return new String[][] { { adjustedRuleName }, { adjustedRuleName, adjustedSecondRule } };
return new String[][] { { adjustedRuleName, adjustedSecondRule } };
}
}
// Fix is here. Original method returns the original ruleName instead of the adjusted rule name.
return new String[][] { { adjustedRuleName } };
}
示例9: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
if (ruleCall.getRule() == grammarAccess.getNavigationOperatorRule())
return getNavigationOperatorToken(semanticObject, ruleCall, node);
return "";
}
示例10: getUnassignedRuleCallToken
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
@Override
protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
if (ruleCall.getRule() == grammarAccess.getIDRule())
return getIDToken(semanticObject, ruleCall, node);
return "";
}
示例11: setRule
import org.eclipse.xtext.RuleCall; //導入方法依賴的package包/類
/**
* The method being overridden expects a rule of a certain form (body does not contain an alternative of keywords
* and a single rule) but the rules arriving here don't have this format.
* <p>
* Therefore pass to that method the first one of the two nested rules Some-Identifier that are expected in any of
* the rules arriving here.
*
* For more details see grammar rules
* <ul>
* <li><code>N4JSPropertyComputedName</code></li>
* <li><code>JsPropertyComputedName</code></li>
* <li><code>TypesComputedPropertyName</code></li>
* </ul>
*/
@Override
public void setRule(AbstractRule rule) {
// TODO make this safer / throw exceptions more informative exceptions
// rule: '[' (SymbolLiteralComputedName | StringLiteralComputedName) ']'
Group g = (Group) rule.getAlternatives();
Alternatives elem = (Alternatives) g.getElements().get(1);
// SymbolLiteralComputedName: N4JSIdentifier '.' N4JSIdentifier
AbstractRule symLitCompName = ((RuleCall) elem.getElements().get(0)).getRule();
Group g2 = (Group) symLitCompName.getAlternatives();
RuleCall identCall = (RuleCall) g2.getElements().get(0);
AbstractRule ident = identCall.getRule();
super.setRule(ident);
}