本文整理汇总了Java中org.eclipse.xtext.GrammarUtil.isMultipleCardinality方法的典型用法代码示例。如果您正苦于以下问题:Java GrammarUtil.isMultipleCardinality方法的具体用法?Java GrammarUtil.isMultipleCardinality怎么用?Java GrammarUtil.isMultipleCardinality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.GrammarUtil
的用法示例。
在下文中一共展示了GrammarUtil.isMultipleCardinality方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: caseCharacterRange
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseCharacterRange(CharacterRange object) {
boolean result = false;
if (object.getLeft().getValue().length() != 1 || object.getRight().getValue().length() != 1)
throw new IllegalStateException("ranges cannot use strings as left or right, that are longer then 1 character.");
OUTER: do {
if (eof())
break OUTER;
char left = object.getLeft().getValue().charAt(0);
char right = object.getRight().getValue().charAt(0);
char candidate = input.charAt(input.getOffset());
if (left <= candidate && right >= candidate) {
input.incOffset();
result = true;
continue OUTER;
}
break OUTER;
} while(GrammarUtil.isMultipleCardinality(object));
return result || GrammarUtil.isOptionalCardinality(object);
}
示例2: caseKeyword
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseKeyword(Keyword object) {
boolean result = false;
String value = object.getValue();
OUTER: do {
if (input.getOffset() + value.length() > input.length())
break OUTER;
if (value.equals(input.subSequence(input.getOffset(), input.getOffset() + value.length()).toString())) {
input.incOffset(value.length());
result = true;
continue OUTER;
}
break OUTER;
} while(GrammarUtil.isMultipleCardinality(object));
return result || GrammarUtil.isOptionalCardinality(object);
}
示例3: caseNegatedToken
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseNegatedToken(NegatedToken object) {
boolean result = false;
OUTER: do {
if (eof())
break OUTER;
IMarker marker = markerFactory.mark();
if (!doSwitch(object.getTerminal())) {
result = true;
input.incOffset();
continue OUTER;
}
marker.rollback();
break OUTER;
} while(GrammarUtil.isMultipleCardinality(object));
return result || GrammarUtil.isOptionalCardinality(object);
}
示例4: caseRuleCall
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseRuleCall(RuleCall object) {
AbstractRule calledRule = object.getRule();
if (calledRule == null || calledRule.eIsProxy() || calledRule instanceof TerminalRule || calledRule instanceof EnumRule)
return Boolean.FALSE;
ParserRule parserRule = (ParserRule) calledRule;
if (GrammarUtil.isDatatypeRule(parserRule))
return Boolean.FALSE;
if (parserRule.isFragment()) {
visitFragment(object);
if (GrammarUtil.isMultipleCardinality(object))
visitFragment(object);
}
if (!addVisited(parserRule))
return Boolean.FALSE;
Multimap<String, AbstractElement> prevAssignedFeatures = assignedFeatures;
assignedFeatures = newMultimap();
doSwitch(parserRule.getAlternatives());
for (String feature : assignedFeatures.keySet())
prevAssignedFeatures.put(feature, object);
assignedFeatures = prevAssignedFeatures;
removeVisited(parserRule);
return Boolean.FALSE;
}
示例5: shouldUseParent
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected boolean shouldUseParent(ICompositeNode result, int offset, ILeafNode leaf) {
if (leaf.getTotalEndOffset() == offset) {
return true;
}
if (result.getGrammarElement() instanceof RuleCall) {
RuleCall rc = (RuleCall) result.getGrammarElement();
if (!rc.getArguments().isEmpty()) {
return true;
}
Assignment assignment = GrammarUtil.containingAssignment(rc);
if (assignment != null
&& (GrammarUtil.isMultipleCardinality(assignment) || (assignment.eContainer() instanceof AbstractElement && GrammarUtil
.isMultipleCardinality((AbstractElement) assignment.eContainer())))) {
return true;
}
}
return false;
}
示例6: getEntryGrammarElement
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
protected AbstractElement getEntryGrammarElement(ICompositeNode entryPoint) {
EObject grammarElement = entryPoint.getGrammarElement();
if (grammarElement instanceof RuleCall) {
AbstractRule rule = ((RuleCall) grammarElement).getRule();
if (rule instanceof ParserRule) {
if (!GrammarUtil.isMultipleCardinality(rule.getAlternatives())) {
grammarElement = rule.getAlternatives();
}
}
} else if (grammarElement instanceof ParserRule) {
grammarElement = ((ParserRule) grammarElement).getAlternatives();
} else if (grammarElement instanceof CrossReference) {
grammarElement = GrammarUtil.containingAssignment(grammarElement);
}
AbstractElement result = (AbstractElement) grammarElement;
if (result instanceof Action) {
return getEntryGrammarElement((ICompositeNode) entryPoint.getFirstChild());
}
return result;
}
示例7: caseAlternatives
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseAlternatives(Alternatives object) {
boolean result = false;
OUTER: do {
for (AbstractElement element: object.getElements()) {
if (doSwitch(element)) {
result = true;
continue OUTER;
}
}
break OUTER;
} while(GrammarUtil.isMultipleCardinality(object));
return result || GrammarUtil.isOptionalCardinality(object);
}
示例8: caseRuleCall
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseRuleCall(RuleCall object) {
if (!checkFurther(object))
return result;
if (doSwitch(object.getRule()))
return true;
if (GrammarUtil.isMultipleCardinality(object)) {
if (!checkFurther(object))
return result;
if (doSwitch(object.getRule()))
return true;
}
return Boolean.FALSE;
}
示例9: caseWildcard
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseWildcard(Wildcard object) {
boolean result = false;
OUTER: do {
if (eof())
break OUTER;
input.incOffset();
result = true;
continue OUTER;
} while(GrammarUtil.isMultipleCardinality(object));
return result || GrammarUtil.isOptionalCardinality(object);
}
示例10: caseRuleCall
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseRuleCall(RuleCall object) {
boolean result = false;
OUTER: do {
if (doSwitch(object.getRule())) {
result = true;
continue OUTER;
}
break OUTER;
} while(GrammarUtil.isMultipleCardinality(object));
return result || GrammarUtil.isOptionalCardinality(object);
}
示例11: caseUntilToken
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseUntilToken(UntilToken object) {
if (GrammarUtil.isOptionalCardinality(object) || GrammarUtil.isMultipleCardinality(object))
throw new IllegalStateException("cardinality has to be default for until tokens");
IMarker marker = markerFactory.mark();
while (!eof()) {
if (doSwitch(object.getTerminal())) {
return true;
}
input.incOffset();
}
marker.rollback();
return false;
}
示例12: caseAssignment
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseAssignment(Assignment object) {
if (GrammarUtil.isMultipleAssignment(object))
return Boolean.FALSE;
checkAssignment(object, object.getFeature());
if (GrammarUtil.isMultipleCardinality(object))
checkAssignment(object, object.getFeature());
return Boolean.FALSE;
}
示例13: getRuleNamesInGroup
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
* @since 2.14
*/
protected String[][] getRuleNamesInGroup(Param param, AbstractElement elementToParse, String adjustedFirstRule,
String adjustedSecondRule) {
if (GrammarUtil.isMultipleCardinality(elementToParse))
return new String[][] { { adjustedFirstRule }, { adjustedFirstRule, adjustedSecondRule } };
return new String[][] { { adjustedFirstRule, adjustedSecondRule } };
}
示例14: getFollowElements
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
/**
* @since 2.14
*/
protected Collection<FE> getFollowElements(final InternalParser parser, final AbstractElement elementToParse,
String[] ruleNames, final int startIndex) {
try {
EofListener listener = createEofListener(parser, elementToParse);
int i = startIndex;
Collection<FE> result = null;
while (i < ruleNames.length && !listener.wasEof && listener.consumedSomething) {
listener.reset();
String ruleName = ruleNames[i];
result = getFollowElements(parser, ruleName, true);
if (i == ruleNames.length - 1 && !GrammarUtil.isMultipleCardinality(elementToParse)) {
if (listener.consumedSomething || listener.announcedEofWithLA)
return result;
return Collections.emptyList();
}
if (!listener.wasEof && ruleNames.length != 1)
i++;
if (ruleNames.length > 2)
throw new IllegalArgumentException(
"The following lines assume that we have at most two rules to call.");
}
return result;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例15: caseAlternatives
import org.eclipse.xtext.GrammarUtil; //导入方法依赖的package包/类
@Override
public Boolean caseAlternatives(Alternatives object) {
if (!checkFurther(object))
return result;
if (caseAlternatives(object.getElements()))
return true;
if (GrammarUtil.isMultipleCardinality(object)) {
if (!checkFurther(object))
return result;
return caseAlternatives(object.getElements());
}
return Boolean.FALSE;
}