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;
 }