use of org.eclipse.xtext.xtext.RuleWithParameterValues 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