protected String _localVar(final EnumLiteralDeclaration it) { EnumRule _containingEnumRule = GrammarUtil.containingEnumRule(it); AbstractElement _alternatives = _containingEnumRule.getAlternatives(); List<AbstractElement> _contentsAsList = this.contentsAsList(_alternatives); int _indexOf = _contentsAsList.indexOf(it); return ("enumLiteral_" + Integer.valueOf(_indexOf)); }
public class Enum1Elements extends AbstractEnumRuleElementFinder { private final EnumRule rule = (EnumRule) GrammarUtil.findRuleForName(getGrammar(), "Enum1"); private final Alternatives cAlternatives = (Alternatives) rule.eContents().get(1); private final EnumLiteralDeclaration cLit1EnumLiteralDeclaration_0 = (EnumLiteralDeclaration) cAlternatives.eContents().get(0); private final Keyword cLit1Lit1Keyword_0_0 = (Keyword) cLit1EnumLiteralDeclaration_0.eContents().get(0); private final EnumLiteralDeclaration cLit2EnumLiteralDeclaration_1 = (EnumLiteralDeclaration) cAlternatives.eContents().get(1); private final Keyword cLit2Lit2Keyword_1_0 = (Keyword) cLit2EnumLiteralDeclaration_1.eContents().get(0); private final EnumLiteralDeclaration cLit3EnumLiteralDeclaration_2 = (EnumLiteralDeclaration) cAlternatives.eContents().get(2); private final Keyword cLit3Lit3Keyword_2_0 = (Keyword) cLit3EnumLiteralDeclaration_2.eContents().get(0); // enum Enum1: // lit1 | lit2 | lit3; public EnumRule getRule() { return rule; } // lit1 | lit2 | lit3 public Alternatives getAlternatives() { return cAlternatives; } // lit1 public EnumLiteralDeclaration getLit1EnumLiteralDeclaration_0() { return cLit1EnumLiteralDeclaration_0; } // "lit1" public Keyword getLit1Lit1Keyword_0_0() { return cLit1Lit1Keyword_0_0; } // lit2 public EnumLiteralDeclaration getLit2EnumLiteralDeclaration_1() { return cLit2EnumLiteralDeclaration_1; } // "lit2" public Keyword getLit2Lit2Keyword_1_0() { return cLit2Lit2Keyword_1_0; } // lit3 public EnumLiteralDeclaration getLit3EnumLiteralDeclaration_2() { return cLit3EnumLiteralDeclaration_2; } // "lit3" public Keyword getLit3Lit3Keyword_2_0() { return cLit3Lit3Keyword_2_0; } }
public class GeneratedEnumElements extends AbstractEnumRuleElementFinder { private final EnumRule rule = (EnumRule) GrammarUtil.findRuleForName( getGrammar(), "org.eclipse.xtext.ui.tests.enumrules.EnumRulesUiTestLanguage.GeneratedEnum"); private final Alternatives cAlternatives = (Alternatives) rule.eContents().get(1); private final EnumLiteralDeclaration cSameNameEnumLiteralDeclaration_0 = (EnumLiteralDeclaration) cAlternatives.eContents().get(0); private final Keyword cSameNameSameNameKeyword_0_0 = (Keyword) cSameNameEnumLiteralDeclaration_0.eContents().get(0); private final EnumLiteralDeclaration cDifferentNameEnumLiteralDeclaration_1 = (EnumLiteralDeclaration) cAlternatives.eContents().get(1); private final Keyword cDifferentNameDifferentLiteralKeyword_1_0 = (Keyword) cDifferentNameEnumLiteralDeclaration_1.eContents().get(0); // enum GeneratedEnum: // SameName | DifferentName="DifferentLiteral"; public EnumRule getRule() { return rule; } // SameName | DifferentName="DifferentLiteral" public Alternatives getAlternatives() { return cAlternatives; } // SameName public EnumLiteralDeclaration getSameNameEnumLiteralDeclaration_0() { return cSameNameEnumLiteralDeclaration_0; } // "SameName" public Keyword getSameNameSameNameKeyword_0_0() { return cSameNameSameNameKeyword_0_0; } // DifferentName="DifferentLiteral" public EnumLiteralDeclaration getDifferentNameEnumLiteralDeclaration_1() { return cDifferentNameEnumLiteralDeclaration_1; } // "DifferentLiteral" public Keyword getDifferentNameDifferentLiteralKeyword_1_0() { return cDifferentNameDifferentLiteralKeyword_1_0; } }
private ArrayList<AbstractRule> copyRuleStubs( final RuleNames names, final Map<RuleWithParameterValues, AbstractRule> origToCopy, final List<AbstractRule> rulesToCopy, final boolean discardTypeRef) { final ArrayList<AbstractRule> result = CollectionLiterals.<AbstractRule>newArrayList(); for (final AbstractRule rule : rulesToCopy) { { String ruleName = names.getAntlrRuleName(rule); boolean _matched = false; if (rule instanceof ParserRule) { _matched = true; List<Parameter> params = ((ParserRule) rule).getParameters(); boolean _isEmpty = params.isEmpty(); if (_isEmpty) { ParserRule copy = this.<ParserRule>copy(((ParserRule) rule)); copy.setName(ruleName); boolean _isFragment = ((ParserRule) rule).isFragment(); copy.setFragment(_isFragment); boolean _isWildcard = ((ParserRule) rule).isWildcard(); copy.setWildcard(_isWildcard); if ((!discardTypeRef)) { TypeRef _type = ((ParserRule) rule).getType(); TypeRef _copyTypeRef = this.copyTypeRef(_type); copy.setType(_copyTypeRef); } this.attachTo(copy, rule, origToCopy); result.add(copy); } else { ImmutableSet<Parameter> _copyOf = ImmutableSet.<Parameter>copyOf(params); Set<Set<Parameter>> _powerSet = Sets.<Parameter>powerSet(_copyOf); final Procedure2<Set<Parameter>, Integer> _function = (Set<Parameter> parameterConfig, Integer i) -> { RuleWithParameterValues parameterValues = new RuleWithParameterValues(rule, parameterConfig); ParserRule copy_1 = this.<ParserRule>copy(((ParserRule) rule)); String _antlrRuleName = names.getAntlrRuleName(rule, (i).intValue()); copy_1.setName(_antlrRuleName); boolean _isFragment_1 = ((ParserRule) rule).isFragment(); copy_1.setFragment(_isFragment_1); boolean _isWildcard_1 = ((ParserRule) rule).isWildcard(); copy_1.setWildcard(_isWildcard_1); if ((!discardTypeRef)) { TypeRef _type_1 = ((ParserRule) rule).getType(); TypeRef _copyTypeRef_1 = this.copyTypeRef(_type_1); copy_1.setType(_copyTypeRef_1); } origToCopy.put(parameterValues, copy_1); parameterValues.attachToEmfObject(copy_1); result.add(copy_1); }; IterableExtensions.<Set<Parameter>>forEach(_powerSet, _function); } } if (!_matched) { if (rule instanceof TerminalRule) { _matched = true; TerminalRule orig = ((TerminalRule) rule); TerminalRule copy = this.<TerminalRule>copy(orig); copy.setName(ruleName); boolean _isFragment = orig.isFragment(); copy.setFragment(_isFragment); this.attachTo(copy, orig, origToCopy); result.add(copy); } } if (!_matched) { if (rule instanceof EnumRule) { _matched = true; EnumRule copy = this.<EnumRule>copy(((EnumRule) rule)); copy.setName(ruleName); this.attachTo(copy, rule, origToCopy); result.add(copy); } } } } return result; }
protected String _ruleName(final EnumRule it) { String _name = it.getName(); return ("rule" + _name); }
@Override public Boolean caseEnumRule(EnumRule object) { return doSwitch(object.getAlternatives()); }