use of org.eclipse.xtext.EnumRule in project xtext-core by eclipse.
the class PsiAntlrGrammarGenerator method crossrefEbnf.
@Override
protected String crossrefEbnf(final AbstractRule it, final RuleCall call, final CrossReference ref, final boolean supportActions) {
String _xifexpression = null;
if (supportActions) {
String _switchResult = null;
boolean _matched = false;
if (it instanceof EnumRule) {
_matched = true;
}
if (!_matched) {
if (it instanceof ParserRule) {
_matched = true;
}
}
if (_matched) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
CharSequence _markComposite = this.markComposite(ref);
_builder.append(_markComposite, "\t");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
String _crossrefEbnf = super.crossrefEbnf(it, call, ref, supportActions);
_builder.append(_crossrefEbnf);
_builder.newLineIfNotEmpty();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
CharSequence _doneComposite = this.doneComposite(ref);
_builder.append(_doneComposite, "\t");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
_switchResult = _builder.toString();
}
if (!_matched) {
if (it instanceof TerminalRule) {
_matched = true;
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("{");
_builder_1.newLine();
_builder_1.append("\t");
CharSequence _markLeaf = this.markLeaf(ref);
_builder_1.append(_markLeaf, "\t");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
_builder_1.newLine();
String _localVar = this._grammarAccessExtensions.localVar(GrammarUtil.containingAssignment(ref));
_builder_1.append(_localVar);
_builder_1.append("=");
String _crossrefEbnf_1 = super.crossrefEbnf(it, call, ref, supportActions);
_builder_1.append(_crossrefEbnf_1);
_builder_1.newLineIfNotEmpty();
_builder_1.append("{");
_builder_1.newLine();
_builder_1.append("\t");
CharSequence _doneLeaf = this.doneLeaf(ref, this._grammarAccessExtensions.localVar(GrammarUtil.containingAssignment(ref)));
_builder_1.append(_doneLeaf, "\t");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
_builder_1.newLine();
_switchResult = _builder_1.toString();
}
}
if (!_matched) {
throw new IllegalStateException(("crossrefEbnf is not supported for " + it));
}
_xifexpression = _switchResult;
} else {
_xifexpression = super.crossrefEbnf(it, call, ref, supportActions);
}
return _xifexpression;
}
use of org.eclipse.xtext.EnumRule in project xtext-core by eclipse.
the class XtextSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == XtextPackage.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case XtextPackage.ACTION:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Action(context, (Action) semanticObject);
return;
} else if (rule == grammarAccess.getActionRule()) {
sequence_Action(context, (Action) semanticObject);
return;
} else
break;
case XtextPackage.ALTERNATIVES:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Alternatives(context, (Alternatives) semanticObject);
return;
} else if (rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0()) {
sequence_AssignableAlternatives(context, (Alternatives) semanticObject);
return;
} else if (rule == grammarAccess.getEnumLiteralsRule()) {
sequence_EnumLiterals(context, (Alternatives) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalAlternatives_TerminalToken(context, (Alternatives) semanticObject);
return;
} else
break;
case XtextPackage.ANNOTATION:
sequence_Annotation(context, (Annotation) semanticObject);
return;
case XtextPackage.ASSIGNMENT:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Assignment(context, (Assignment) semanticObject);
return;
} else if (rule == grammarAccess.getAssignmentRule()) {
sequence_Assignment(context, (Assignment) semanticObject);
return;
} else
break;
case XtextPackage.CHARACTER_RANGE:
if (rule == grammarAccess.getCharacterRangeRule()) {
sequence_CharacterRange(context, (CharacterRange) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_CharacterRange_TerminalToken(context, (CharacterRange) semanticObject);
return;
} else
break;
case XtextPackage.CONJUNCTION:
sequence_Conjunction(context, (Conjunction) semanticObject);
return;
case XtextPackage.CROSS_REFERENCE:
sequence_CrossReference(context, (CrossReference) semanticObject);
return;
case XtextPackage.DISJUNCTION:
sequence_Disjunction(context, (Disjunction) semanticObject);
return;
case XtextPackage.EOF:
if (rule == grammarAccess.getEOFRule()) {
sequence_EOF(context, (EOF) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_EOF_TerminalToken(context, (EOF) semanticObject);
return;
} else
break;
case XtextPackage.ENUM_LITERAL_DECLARATION:
sequence_EnumLiteralDeclaration(context, (EnumLiteralDeclaration) semanticObject);
return;
case XtextPackage.ENUM_RULE:
sequence_EnumRule(context, (EnumRule) semanticObject);
return;
case XtextPackage.GENERATED_METAMODEL:
sequence_GeneratedMetamodel(context, (GeneratedMetamodel) semanticObject);
return;
case XtextPackage.GRAMMAR:
sequence_Grammar(context, (Grammar) semanticObject);
return;
case XtextPackage.GROUP:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_ConditionalBranch_Group_PredicatedGroup(context, (Group) semanticObject);
return;
} else if (rule == grammarAccess.getPredicatedGroupRule()) {
sequence_PredicatedGroup(context, (Group) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalGroup_TerminalToken(context, (Group) semanticObject);
return;
} else
break;
case XtextPackage.KEYWORD:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_Keyword_PredicatedKeyword(context, (Keyword) semanticObject);
return;
} else if (rule == grammarAccess.getKeywordRule() || rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getCrossReferenceableTerminalRule() || rule == grammarAccess.getCharacterRangeRule() || action == grammarAccess.getCharacterRangeAccess().getCharacterRangeLeftAction_1_0()) {
sequence_Keyword(context, (Keyword) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_Keyword_TerminalToken(context, (Keyword) semanticObject);
return;
} else if (rule == grammarAccess.getPredicatedKeywordRule()) {
sequence_PredicatedKeyword(context, (Keyword) semanticObject);
return;
} else
break;
case XtextPackage.LITERAL_CONDITION:
sequence_LiteralCondition(context, (LiteralCondition) semanticObject);
return;
case XtextPackage.NAMED_ARGUMENT:
sequence_NamedArgument(context, (NamedArgument) semanticObject);
return;
case XtextPackage.NEGATED_TOKEN:
if (rule == grammarAccess.getAbstractNegatedTokenRule() || rule == grammarAccess.getNegatedTokenRule()) {
sequence_NegatedToken(context, (NegatedToken) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_NegatedToken_TerminalToken(context, (NegatedToken) semanticObject);
return;
} else
break;
case XtextPackage.NEGATION:
sequence_Negation(context, (Negation) semanticObject);
return;
case XtextPackage.PARAMETER:
sequence_Parameter(context, (Parameter) semanticObject);
return;
case XtextPackage.PARAMETER_REFERENCE:
sequence_ParameterReference(context, (ParameterReference) semanticObject);
return;
case XtextPackage.PARSER_RULE:
sequence_ParserRule_RuleNameAndParams(context, (ParserRule) semanticObject);
return;
case XtextPackage.REFERENCED_METAMODEL:
sequence_ReferencedMetamodel(context, (ReferencedMetamodel) semanticObject);
return;
case XtextPackage.RULE_CALL:
if (rule == grammarAccess.getAlternativesRule() || action == grammarAccess.getAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getConditionalBranchRule() || rule == grammarAccess.getUnorderedGroupRule() || action == grammarAccess.getUnorderedGroupAccess().getUnorderedGroupElementsAction_1_0() || rule == grammarAccess.getGroupRule() || action == grammarAccess.getGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getAbstractTokenRule() || rule == grammarAccess.getAbstractTokenWithCardinalityRule() || rule == grammarAccess.getAbstractTerminalRule() || rule == grammarAccess.getParenthesizedElementRule()) {
sequence_AbstractTokenWithCardinality_PredicatedRuleCall_RuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getPredicatedRuleCallRule()) {
sequence_PredicatedRuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getRuleCallRule() || rule == grammarAccess.getAssignableTerminalRule() || rule == grammarAccess.getParenthesizedAssignableElementRule() || rule == grammarAccess.getAssignableAlternativesRule() || action == grammarAccess.getAssignableAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getCrossReferenceableTerminalRule()) {
sequence_RuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalRuleCallRule()) {
sequence_TerminalRuleCall(context, (RuleCall) semanticObject);
return;
} else if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalRuleCall_TerminalToken(context, (RuleCall) semanticObject);
return;
} else
break;
case XtextPackage.TERMINAL_RULE:
sequence_TerminalRule(context, (TerminalRule) semanticObject);
return;
case XtextPackage.TYPE_REF:
sequence_TypeRef(context, (TypeRef) semanticObject);
return;
case XtextPackage.UNORDERED_GROUP:
sequence_AbstractTokenWithCardinality_UnorderedGroup(context, (UnorderedGroup) semanticObject);
return;
case XtextPackage.UNTIL_TOKEN:
if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalToken_UntilToken(context, (UntilToken) semanticObject);
return;
} else if (rule == grammarAccess.getAbstractNegatedTokenRule() || rule == grammarAccess.getUntilTokenRule()) {
sequence_UntilToken(context, (UntilToken) semanticObject);
return;
} else
break;
case XtextPackage.WILDCARD:
if (rule == grammarAccess.getTerminalAlternativesRule() || action == grammarAccess.getTerminalAlternativesAccess().getAlternativesElementsAction_1_0() || rule == grammarAccess.getTerminalGroupRule() || action == grammarAccess.getTerminalGroupAccess().getGroupElementsAction_1_0() || rule == grammarAccess.getTerminalTokenRule() || rule == grammarAccess.getTerminalTokenElementRule() || rule == grammarAccess.getParenthesizedTerminalElementRule()) {
sequence_TerminalToken_Wildcard(context, (Wildcard) semanticObject);
return;
} else if (rule == grammarAccess.getWildcardRule()) {
sequence_Wildcard(context, (Wildcard) semanticObject);
return;
} else
break;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.EnumRule in project xtext-core by eclipse.
the class XtextScopeProvider method getScope.
@Override
public IScope getScope(final EObject context, EReference reference) {
if (reference == XtextPackage.eINSTANCE.getTypeRef_Classifier()) {
if (context instanceof TypeRef) {
final TypeRef typeRef = (TypeRef) context;
final AbstractMetamodelDeclaration metaModel = typeRef.getMetamodel();
if (metaModel != null) {
EPackage pack = metaModel.getEPackage();
if (pack != null)
return createClassifierScope(pack.getEClassifiers());
} else {
return createReferencedPackagesScope(GrammarUtil.getGrammar(context));
}
} else {
return createReferencedPackagesScope(GrammarUtil.getGrammar(context));
}
return IScope.NULLSCOPE;
}
if (reference == XtextPackage.eINSTANCE.getEnumLiteralDeclaration_EnumLiteral()) {
final EnumRule rule = GrammarUtil.containingEnumRule(context);
if (rule.getType() != null && rule.getType().getClassifier() != null && rule.getType().getClassifier() instanceof EEnum) {
return createEnumLiteralsScope((EEnum) rule.getType().getClassifier());
}
return IScope.NULLSCOPE;
}
if (reference == XtextPackage.eINSTANCE.getGrammar_UsedGrammars()) {
return globalScopeProvider.getScope(context.eResource(), reference, new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
return !input.getEObjectURI().equals(EcoreUtil.getURI(context));
}
});
}
if (reference == XtextPackage.eINSTANCE.getRuleCall_Rule()) {
return createScope(context.eResource(), reference.getEReferenceType(), new SuperCallScope(context));
}
if (reference == XtextPackage.eINSTANCE.getParameterReference_Parameter()) {
ParserRule rule = GrammarUtil.containingParserRule(context);
if (rule == null) {
return IScope.NULLSCOPE;
}
return Scopes.scopeFor(rule.getParameters());
}
if (reference == XtextPackage.eINSTANCE.getNamedArgument_Parameter()) {
RuleCall ruleCall = EcoreUtil2.getContainerOfType(context, RuleCall.class);
if (ruleCall == null) {
return IScope.NULLSCOPE;
}
AbstractRule referencedRule = ruleCall.getRule();
if (referencedRule instanceof ParserRule) {
return Scopes.scopeFor(((ParserRule) referencedRule).getParameters());
}
return IScope.NULLSCOPE;
}
return createScope(context.eResource(), reference.getEReferenceType(), IScope.NULLSCOPE);
}
use of org.eclipse.xtext.EnumRule in project xtext-core by eclipse.
the class XtextTransientValueService method isTransient.
@Override
public boolean isTransient(EObject owner, EStructuralFeature feature, int index) {
if (feature == XtextPackage.eINSTANCE.getTypeRef_Metamodel()) {
final TypeRef typeRef = (TypeRef) owner;
final AbstractMetamodelDeclaration m = typeRef.getMetamodel();
if (m == null || Strings.isEmpty(m.getAlias()))
return true;
} else if (feature == XtextPackage.eINSTANCE.getAbstractRule_Type()) {
final AbstractRule rule = (AbstractRule) owner;
if (rule instanceof ParserRule || rule instanceof EnumRule) {
final TypeRef returnType = rule.getType();
if (returnType == null || returnType.getClassifier() == null)
return true;
else if (rule.getName().equals(returnType.getClassifier().getName())) {
return isTransient(returnType, XtextPackage.eINSTANCE.getTypeRef_Metamodel(), -1);
} else if (GrammarUtil.isDatatypeRule(rule)) {
return NodeModelUtils.getNode(returnType) == null;
}
} else if (rule instanceof TerminalRule) {
final TypeRef returnType = rule.getType();
return ((TerminalRule) rule).isFragment() || returnType == null || GrammarUtil.findEString(GrammarUtil.getGrammar(owner)).equals(rule.getType().getClassifier());
}
} else if (feature == XtextPackage.eINSTANCE.getCrossReference_Terminal()) {
final CrossReference ref = (CrossReference) owner;
if (ref.getTerminal() instanceof RuleCall && ((RuleCall) ref.getTerminal()).getRule() != null && "ID".equals(((RuleCall) ref.getTerminal()).getRule().getName()))
return true;
} else if (feature == XtextPackage.eINSTANCE.getEnumLiteralDeclaration_Literal()) {
final EnumLiteralDeclaration decl = (EnumLiteralDeclaration) owner;
return decl.getEnumLiteral() != null && decl.getLiteral() != null && Strings.equal(decl.getLiteral().getValue(), decl.getEnumLiteral().getName());
} else if (feature == XtextPackage.eINSTANCE.getRuleCall_ExplicitlyCalled()) {
return true;
} else if (feature == XtextPackage.eINSTANCE.getNamedArgument_Parameter()) {
return !((NamedArgument) owner).isCalledByName();
}
return super.isTransient(owner, feature, index);
}
use of org.eclipse.xtext.EnumRule in project xtext-core by eclipse.
the class FlattenedGrammarAccess method copyRuleStubs.
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);
copy.setFragment(((ParserRule) rule).isFragment());
copy.setWildcard(((ParserRule) rule).isWildcard());
if ((!discardTypeRef)) {
copy.setType(this.copyTypeRef(((ParserRule) rule).getType()));
}
this.attachTo(copy, rule, origToCopy);
result.add(copy);
} else {
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));
copy_1.setName(names.getAntlrRuleName(rule, (i).intValue()));
copy_1.setFragment(((ParserRule) rule).isFragment());
copy_1.setWildcard(((ParserRule) rule).isWildcard());
if ((!discardTypeRef)) {
copy_1.setType(this.copyTypeRef(((ParserRule) rule).getType()));
}
origToCopy.put(parameterValues, copy_1);
parameterValues.attachToEmfObject(copy_1);
result.add(copy_1);
};
IterableExtensions.<Set<Parameter>>forEach(Sets.<Parameter>powerSet(ImmutableSet.<Parameter>copyOf(params)), _function);
}
}
if (!_matched) {
if (rule instanceof TerminalRule) {
_matched = true;
TerminalRule orig = ((TerminalRule) rule);
TerminalRule copy = this.<TerminalRule>copy(orig);
copy.setName(ruleName);
copy.setFragment(orig.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;
}
Aggregations