protected CharSequence _compileInitHiddenTokens(final ParserRule it, final AntlrOptions options) {
   StringConcatenation _builder = new StringConcatenation();
   {
     boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens();
     if (_isDefinesHiddenTokens) {
       _builder.append(
           "HiddenTokens myHiddenTokenState = ((XtextTokenStream)input).setHiddenTokens(");
       {
         EList<AbstractRule> _hiddenTokens = it.getHiddenTokens();
         boolean _hasElements = false;
         for (final AbstractRule hidden : _hiddenTokens) {
           if (!_hasElements) {
             _hasElements = true;
           } else {
             _builder.appendImmediate(", ", "");
           }
           _builder.append("\"");
           String _ruleName = this._grammarAccessExtensions.ruleName(hidden);
           _builder.append(_ruleName, "");
           _builder.append("\"");
         }
       }
       _builder.append(");");
     }
   }
   return _builder;
 }
 protected CharSequence _compileInitUnorderedGroups(
     final ParserRule it, final AntlrOptions options) {
   StringConcatenation _builder = new StringConcatenation();
   {
     boolean _definesUnorderedGroups =
         this._grammarAccessExtensions.definesUnorderedGroups(it, options);
     if (_definesUnorderedGroups) {
       _builder.newLineIfNotEmpty();
       _builder.append(
           "UnorderedGroupState myUnorderedGroupState = getUnorderedGroupHelper().snapShot(");
       _builder.newLine();
       {
         List<EObject> _eAllContentsAsList = EcoreUtil2.eAllContentsAsList(it);
         Iterable<UnorderedGroup> _filter =
             Iterables.<UnorderedGroup>filter(_eAllContentsAsList, UnorderedGroup.class);
         boolean _hasElements = false;
         for (final UnorderedGroup group : _filter) {
           if (!_hasElements) {
             _hasElements = true;
           } else {
             _builder.appendImmediate(", ", "");
           }
           _builder.append("grammarAccess.");
           UnorderedGroup _originalElement =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(group);
           String _gaRuleElementAccessor =
               this._grammarAccess.gaRuleElementAccessor(_originalElement);
           _builder.append(_gaRuleElementAccessor, "");
           _builder.newLineIfNotEmpty();
         }
       }
       _builder.append(");");
     }
   }
   return _builder;
 }
 @Override
 protected String _ebnf2(
     final UnorderedGroup it, final AntlrOptions options, final boolean supportActions) {
   String _xifexpression = null;
   if (supportActions) {
     String _xblockexpression = null;
     {
       EList<AbstractElement> _elements = it.getElements();
       final Function1<AbstractElement, Boolean> _function =
           new Function1<AbstractElement, Boolean>() {
             @Override
             public Boolean apply(final AbstractElement it) {
               boolean _isOptionalCardinality = GrammarUtil.isOptionalCardinality(it);
               return Boolean.valueOf((!_isOptionalCardinality));
             }
           };
       Iterable<AbstractElement> _filter =
           IterableExtensions.<AbstractElement>filter(_elements, _function);
       final int mandatoryContent = IterableExtensions.size(_filter);
       StringConcatenation _builder = new StringConcatenation();
       _builder.append("(");
       _builder.newLine();
       _builder.append("\t");
       _builder.append("{ ");
       _builder.newLine();
       _builder.append("\t  ");
       _builder.append("getUnorderedGroupHelper().enter(grammarAccess.");
       UnorderedGroup _originalElement =
           AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
       String _gaRuleElementAccessor = this._grammarAccess.gaRuleElementAccessor(_originalElement);
       _builder.append(_gaRuleElementAccessor, "\t  ");
       _builder.append(");");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       _builder.append("}");
       _builder.newLine();
       _builder.append("\t");
       _builder.append("(");
       _builder.newLine();
       _builder.append("\t\t");
       _builder.append("(");
       _builder.newLine();
       {
         EList<AbstractElement> _elements_1 = it.getElements();
         Iterable<Pair<Integer, AbstractElement>> _indexed =
             IterableExtensions.<AbstractElement>indexed(_elements_1);
         boolean _hasElements = false;
         for (final Pair<Integer, AbstractElement> element : _indexed) {
           if (!_hasElements) {
             _hasElements = true;
           } else {
             _builder.appendImmediate("|", "");
           }
           _builder.append("(");
           _builder.newLine();
           _builder.append("\t");
           _builder.append("{getUnorderedGroupHelper().canSelect(grammarAccess.");
           UnorderedGroup _originalElement_1 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_1 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_1);
           _builder.append(_gaRuleElementAccessor_1, "\t");
           _builder.append(", ");
           Integer _key = element.getKey();
           _builder.append(_key, "\t");
           _builder.append(")}?=>(");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("{");
           _builder.newLine();
           _builder.append("\t\t\t");
           _builder.append("getUnorderedGroupHelper().select(grammarAccess.");
           UnorderedGroup _originalElement_2 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_2 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_2);
           _builder.append(_gaRuleElementAccessor_2, "\t\t\t");
           _builder.append(", ");
           Integer _key_1 = element.getKey();
           _builder.append(_key_1, "\t\t\t");
           _builder.append(");");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("}");
           _builder.newLine();
           _builder.append("\t\t\t\t\t");
           _builder.append("({true}?=>(");
           AbstractElement _value = element.getValue();
           String _ebnf2 = this.ebnf2(_value, options, supportActions);
           _builder.append(_ebnf2, "\t\t\t\t\t");
           _builder.append("))");
           {
             AbstractElement _value_1 = element.getValue();
             boolean _isMultipleCardinality = GrammarUtil.isMultipleCardinality(_value_1);
             if (_isMultipleCardinality) {
               _builder.append("+");
             }
           }
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("{ ");
           _builder.newLine();
           _builder.append("\t\t\t");
           _builder.append("getUnorderedGroupHelper().returnFromSelection(grammarAccess.");
           UnorderedGroup _originalElement_3 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_3 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_3);
           _builder.append(_gaRuleElementAccessor_3, "\t\t\t");
           _builder.append(");");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("}");
           _builder.newLine();
           _builder.append("\t");
           _builder.append(")");
           _builder.newLine();
           _builder.append(")");
           _builder.newLine();
         }
       }
       _builder.append("\t\t");
       _builder.append(")");
       {
         if ((mandatoryContent != 0)) {
           _builder.append("+");
           _builder.newLineIfNotEmpty();
           _builder.append("\t\t");
           _builder.append("{getUnorderedGroupHelper().canLeave(grammarAccess.");
           UnorderedGroup _originalElement_4 =
               AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
           String _gaRuleElementAccessor_4 =
               this._grammarAccess.gaRuleElementAccessor(_originalElement_4);
           _builder.append(_gaRuleElementAccessor_4, "\t\t");
           _builder.append(")}?");
         } else {
           _builder.append("*");
         }
       }
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       _builder.append(")");
       _builder.newLine();
       _builder.append(")");
       _builder.newLine();
       _builder.append("\t");
       _builder.append("{ ");
       _builder.newLine();
       _builder.append("\t  ");
       _builder.append("getUnorderedGroupHelper().leave(grammarAccess.");
       UnorderedGroup _originalElement_5 =
           AntlrGrammarGenUtil.<UnorderedGroup>getOriginalElement(it);
       String _gaRuleElementAccessor_5 =
           this._grammarAccess.gaRuleElementAccessor(_originalElement_5);
       _builder.append(_gaRuleElementAccessor_5, "\t  ");
       _builder.append(");");
       _builder.newLineIfNotEmpty();
       _builder.append("\t");
       _builder.append("}");
       _builder.newLine();
       _xblockexpression = _builder.toString();
     }
     _xifexpression = _xblockexpression;
   } else {
     _xifexpression = super._ebnf2(it, options, supportActions);
   }
   return _xifexpression;
 }
Example #4
0
 @Override
 public void generate(final Xtend2ExecutionContext ctx) {
   String _abstractValidatorName = this._validatorNaming.getAbstractValidatorName();
   String _asPath = this._naming.asPath(_abstractValidatorName);
   String _plus = (_asPath + ".java");
   StringConcatenation _builder = new StringConcatenation();
   String _fileHeader = this._naming.fileHeader();
   _builder.append(_fileHeader, "");
   _builder.newLineIfNotEmpty();
   _builder.append("package ");
   String _abstractValidatorName_1 = this._validatorNaming.getAbstractValidatorName();
   String _packageName = this._naming.packageName(_abstractValidatorName_1);
   _builder.append(_packageName, "");
   _builder.append(";");
   _builder.newLineIfNotEmpty();
   _builder.newLine();
   String _annotationImports = this._naming.annotationImports();
   _builder.append(_annotationImports, "");
   _builder.newLineIfNotEmpty();
   _builder.append("import java.util.ArrayList;");
   _builder.newLine();
   _builder.append("import java.util.List;");
   _builder.newLine();
   _builder.append("import org.eclipse.emf.ecore.EPackage;");
   _builder.newLine();
   {
     boolean _isEmpty = this.composedChecks.isEmpty();
     boolean _not = (!_isEmpty);
     if (_not) {
       _builder.append("import org.eclipse.xtext.validation.ComposedChecks;");
       _builder.newLine();
     }
   }
   _builder.newLine();
   {
     boolean _isEmpty_1 = this.composedChecks.isEmpty();
     boolean _not_1 = (!_isEmpty_1);
     if (_not_1) {
       _builder.append("@ComposedChecks(validators= {");
       {
         boolean _hasElements = false;
         for (final String validator : this.composedChecks) {
           if (!_hasElements) {
             _hasElements = true;
           } else {
             _builder.appendImmediate(", ", "");
           }
           _builder.append(validator, "");
           _builder.append(".class");
         }
       }
       _builder.append("})");
       _builder.newLineIfNotEmpty();
     }
   }
   String _classAnnotations = this._naming.classAnnotations();
   _builder.append(_classAnnotations, "");
   _builder.append("public class ");
   String _abstractValidatorName_2 = this._validatorNaming.getAbstractValidatorName();
   String _simpleName = this._naming.toSimpleName(_abstractValidatorName_2);
   _builder.append(_simpleName, "");
   _builder.append(" extends ");
   boolean _isInheritImplementation = this.isInheritImplementation();
   String _validatorSuperClassName =
       this._validatorNaming.getValidatorSuperClassName(_isInheritImplementation);
   _builder.append(_validatorSuperClassName, "");
   _builder.append(" {");
   _builder.newLineIfNotEmpty();
   _builder.newLine();
   _builder.append("\t");
   _builder.append("@Override");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("protected List<EPackage> getEPackages() {");
   _builder.newLine();
   _builder.append("\t    ");
   _builder.append("List<EPackage> result = new ArrayList<EPackage>(");
   {
     if ((this.isInheritImplementation()
         && (IInheriting.Util.getNonTerminalsSuperGrammar(this.grammar) != null))) {
       _builder.append("super.getEPackages()");
     }
   }
   _builder.append(");");
   _builder.newLineIfNotEmpty();
   {
     Iterable<EPackage> _generatedPackagesToValidate = this.getGeneratedPackagesToValidate();
     for (final EPackage e : _generatedPackagesToValidate) {
       _builder.append("\t    ");
       _builder.append("result.add(");
       String _generatedEPackageName = this._validatorNaming.getGeneratedEPackageName(e);
       _builder.append(_generatedEPackageName, "\t    ");
       _builder.append(".eINSTANCE);");
       _builder.newLineIfNotEmpty();
     }
   }
   {
     Collection<EPackage> _registryPackagesToValidate = this.getRegistryPackagesToValidate();
     for (final EPackage e_1 : _registryPackagesToValidate) {
       _builder.append("\t    ");
       _builder.append("result.add(EPackage.Registry.INSTANCE.getEPackage(\"");
       String _nsURI = e_1.getNsURI();
       _builder.append(_nsURI, "\t    ");
       _builder.append("\"));");
       _builder.newLineIfNotEmpty();
     }
   }
   _builder.append("\t\t");
   _builder.append("return result;");
   _builder.newLine();
   _builder.append("\t");
   _builder.append("}");
   _builder.newLine();
   _builder.append("}");
   _builder.newLine();
   ctx.writeFile(Generator.SRC_GEN, _plus, _builder);
   if (this.generateStub) {
     String _validatorName = this._validatorNaming.getValidatorName(this.grammar);
     String _asPath_1 = this._naming.asPath(_validatorName);
     String _plus_1 = (_asPath_1 + ".xtend");
     StringConcatenation _builder_1 = new StringConcatenation();
     String _fileHeader_1 = this._naming.fileHeader();
     _builder_1.append(_fileHeader_1, "");
     _builder_1.newLineIfNotEmpty();
     _builder_1.append("package ");
     String _validatorName_1 = this._validatorNaming.getValidatorName(this.grammar);
     String _packageName_1 = this._naming.packageName(_validatorName_1);
     _builder_1.append(_packageName_1, "");
     _builder_1.newLineIfNotEmpty();
     _builder_1.newLine();
     _builder_1.append("//import org.eclipse.xtext.validation.Check");
     _builder_1.newLine();
     _builder_1.newLine();
     _builder_1.append("/**");
     _builder_1.newLine();
     _builder_1.append(" ");
     _builder_1.append("* This class contains custom validation rules. ");
     _builder_1.newLine();
     _builder_1.append(" ");
     _builder_1.append("*");
     _builder_1.newLine();
     _builder_1.append(" ");
     _builder_1.append(
         "* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation");
     _builder_1.newLine();
     _builder_1.append(" ");
     _builder_1.append("*/");
     _builder_1.newLine();
     _builder_1.append("class ");
     String _validatorName_2 = this._validatorNaming.getValidatorName(this.grammar);
     String _simpleName_1 = this._naming.toSimpleName(_validatorName_2);
     _builder_1.append(_simpleName_1, "");
     _builder_1.append(" extends ");
     String _abstractValidatorName_3 = this._validatorNaming.getAbstractValidatorName();
     String _simpleName_2 = this._naming.toSimpleName(_abstractValidatorName_3);
     _builder_1.append(_simpleName_2, "");
     _builder_1.append(" {");
     _builder_1.newLineIfNotEmpty();
     _builder_1.newLine();
     _builder_1.append("//  public static val INVALID_NAME = \'invalidName\'");
     _builder_1.newLine();
     _builder_1.append("//");
     _builder_1.newLine();
     _builder_1.append("//\t@Check");
     _builder_1.newLine();
     _builder_1.append("//\tdef checkGreetingStartsWithCapital(Greeting greeting) {");
     _builder_1.newLine();
     _builder_1.append("//\t\tif (!Character.isUpperCase(greeting.name.charAt(0))) {");
     _builder_1.newLine();
     _builder_1.append("//\t\t\twarning(\'Name should start with a capital\', ");
     _builder_1.newLine();
     _builder_1.append("//\t\t\t\t\tMyDslPackage.Literals.GREETING__NAME,");
     _builder_1.newLine();
     _builder_1.append("//\t\t\t\t\tINVALID_NAME)");
     _builder_1.newLine();
     _builder_1.append("//\t\t}");
     _builder_1.newLine();
     _builder_1.append("//\t}");
     _builder_1.newLine();
     _builder_1.append("}");
     _builder_1.newLine();
     ctx.writeFile(Generator.SRC, _plus_1, _builder_1);
   }
 }
 @Override
 public CharSequence getFileContents(final SerializerGenFileNames.GenFileName filename) {
   String _xblockexpression = null;
   {
     String _packageName = filename.getPackageName();
     String _fileHeader = this._naming.fileHeader();
     final JavaFile file = new JavaFile(_packageName, _fileHeader);
     file.imported(org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer.class);
     file.imported(RuleCall.class);
     file.imported(INode.class);
     file.imported(ISyntacticSequencerPDAProvider.ISynTransition.class);
     file.imported(Inject.class);
     file.imported(IGrammarAccess.class);
     file.imported(EObject.class);
     file.imported(List.class);
     file.imported(GrammarAlias.AbstractElementAlias.class);
     String _annotationImports = this._naming.annotationImports();
     boolean _notEquals = (!Objects.equal(_annotationImports, null));
     if (_notEquals) {
       String _annotationImports_1 = this._naming.annotationImports();
       String[] _split = _annotationImports_1.split("(import)|;");
       final Function1<String, String> _function =
           new Function1<String, String>() {
             @Override
             public String apply(final String it) {
               return it.trim();
             }
           };
       List<String> _map =
           ListExtensions.<String, String>map(
               ((List<String>) Conversions.doWrapArray(_split)), _function);
       final Function1<String, Boolean> _function_1 =
           new Function1<String, Boolean>() {
             @Override
             public Boolean apply(final String it) {
               boolean _isEmpty = it.isEmpty();
               return Boolean.valueOf((!_isEmpty));
             }
           };
       Iterable<String> _filter = IterableExtensions.<String>filter(_map, _function_1);
       final Procedure1<String> _function_2 =
           new Procedure1<String>() {
             @Override
             public void apply(final String it) {
               file.imported(it);
             }
           };
       IterableExtensions.<String>forEach(_filter, _function_2);
     }
     String _xifexpression = null;
     boolean _isAbstract = filename.isAbstract();
     if (_isAbstract) {
       _xifexpression = "abstract ";
     } else {
       _xifexpression = "";
     }
     final String _abstract = _xifexpression;
     StringConcatenation _builder = new StringConcatenation();
     String _classAnnotations = this._naming.classAnnotations();
     _builder.append(_classAnnotations, "");
     _builder.append("@SuppressWarnings(\"all\")");
     _builder.newLineIfNotEmpty();
     _builder.append("public ");
     _builder.append(_abstract, "");
     _builder.append("class ");
     String _simpleName = filename.getSimpleName();
     _builder.append(_simpleName, "");
     _builder.append(" extends AbstractSyntacticSequencer {");
     _builder.newLineIfNotEmpty();
     _builder.newLine();
     _builder.append("\t");
     _builder.append("protected ");
     String _gaFQName = this.grammarAccess.gaFQName(this.grammar);
     String _imported = file.imported(_gaFQName);
     _builder.append(_imported, "\t");
     _builder.append(" grammarAccess;");
     _builder.newLineIfNotEmpty();
     {
       List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax =
           this.util.getAllAmbiguousTransitionsBySyntax();
       for (final EqualAmbiguousTransitions group : _allAmbiguousTransitionsBySyntax) {
         _builder.append("\t");
         _builder.append("protected ");
         String _imported_1 =
             file.imported(
                 "org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias");
         _builder.append(_imported_1, "\t");
         _builder.append(" match_");
         String _identifyer = group.getIdentifyer();
         _builder.append(_identifyer, "\t");
         _builder.append(";");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("@Inject");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("protected void init(IGrammarAccess access) {");
     _builder.newLine();
     _builder.append("\t\t");
     _builder.append("grammarAccess = (");
     String _gaFQName_1 = this.grammarAccess.gaFQName(this.grammar);
     String _imported_2 = file.imported(_gaFQName_1);
     _builder.append(_imported_2, "\t\t");
     _builder.append(") access;");
     _builder.newLineIfNotEmpty();
     {
       List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_1 =
           this.util.getAllAmbiguousTransitionsBySyntax();
       for (final EqualAmbiguousTransitions group_1 : _allAmbiguousTransitionsBySyntax_1) {
         _builder.append("\t\t");
         _builder.append("match_");
         String _identifyer_1 = group_1.getIdentifyer();
         _builder.append(_identifyer_1, "\t\t");
         _builder.append(" = ");
         GrammarAlias.AbstractElementAlias _elementAlias = group_1.getElementAlias();
         String _elementAliasToConstructor =
             this.util.elementAliasToConstructor(_elementAlias, file);
         _builder.append(_elementAliasToConstructor, "\t\t");
         _builder.append(";");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     CharSequence _genGetUnassignedRuleCallTokens = this.genGetUnassignedRuleCallTokens(file);
     _builder.append(_genGetUnassignedRuleCallTokens, "\t");
     _builder.newLineIfNotEmpty();
     _builder.append("\t");
     _builder.newLine();
     {
       List<AbstractRule> _unassignedCalledTokenRules = this.unassignedCalledTokenRules();
       boolean _hasElements = false;
       for (final AbstractRule rule : _unassignedCalledTokenRules) {
         if (!_hasElements) {
           _hasElements = true;
         } else {
           _builder.appendImmediate("\n", "\t");
         }
         _builder.append("\t");
         boolean _isAbstract_1 = filename.isAbstract();
         String _genGetUnassignedRuleCallToken =
             this.genGetUnassignedRuleCallToken(file, rule, _isAbstract_1);
         _builder.append(_genGetUnassignedRuleCallToken, "\t");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     CharSequence _genEmitUnassignedTokens = this.genEmitUnassignedTokens(file);
     _builder.append(_genEmitUnassignedTokens, "\t");
     _builder.newLineIfNotEmpty();
     _builder.newLine();
     {
       List<EqualAmbiguousTransitions> _allAmbiguousTransitionsBySyntax_2 =
           this.util.getAllAmbiguousTransitionsBySyntax();
       for (final EqualAmbiguousTransitions group_2 : _allAmbiguousTransitionsBySyntax_2) {
         _builder.append("\t");
         _builder.append("/**");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* Ambiguous syntax:");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*     ");
         GrammarAlias.AbstractElementAlias _elementAlias_1 = group_2.getElementAlias();
         String _string = _elementAlias_1.toString();
         String _replace = _string.replace("\n", "\n *     ");
         _builder.append(_replace, "\t ");
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* This ambiguous syntax occurs at:");
         _builder.newLine();
         {
           List<ISyntacticSequencerPDAProvider.ISynTransition> _transitions =
               group_2.getTransitions();
           final Function1<ISyntacticSequencerPDAProvider.ISynTransition, String> _function_3 =
               new Function1<ISyntacticSequencerPDAProvider.ISynTransition, String>() {
                 @Override
                 public String apply(final ISyntacticSequencerPDAProvider.ISynTransition it) {
                   String _ambiguityInsideTransition = group_2.ambiguityInsideTransition(it);
                   return _ambiguityInsideTransition.trim();
                 }
               };
           List<String> _map_1 =
               ListExtensions.<ISyntacticSequencerPDAProvider.ISynTransition, String>map(
                   _transitions, _function_3);
           Set<String> _set = IterableExtensions.<String>toSet(_map_1);
           List<String> _sort = IterableExtensions.<String>sort(_set);
           for (final String trans : _sort) {
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("*     ");
             String _string_1 = trans.toString();
             String _replace_1 = _string_1.replace("\n", "\n*     ");
             _builder.append(_replace_1, "\t ");
             _builder.newLineIfNotEmpty();
           }
         }
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*/");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("protected void emit_");
         String _identifyer_2 = group_2.getIdentifyer();
         _builder.append(_identifyer_2, "\t");
         _builder.append("(EObject semanticObject, ");
         String _imported_3 = file.imported(ISyntacticSequencerPDAProvider.ISynNavigable.class);
         _builder.append(_imported_3, "\t");
         _builder.append(" transition, List<INode> nodes) {");
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         _builder.append("\t");
         _builder.append("acceptNodes(transition, nodes);");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("}");
         _builder.newLine();
         _builder.append("\t");
         _builder.newLine();
       }
     }
     _builder.append("}");
     _builder.newLine();
     String _string_2 = _builder.toString();
     file.body = _string_2;
     _xblockexpression = file.toString();
   }
   return _xblockexpression;
 }
 public static String generate(final MyxGenBrick b) {
   MyxGenBrick _xtrycatchfinallyexpression = null;
   try {
     String _parentBrickId = b.getParentBrickId();
     MyxGenBrick _activeMyxGenBrick =
         MyxGenWorkspaceExtensions.getActiveMyxGenBrick(_parentBrickId);
     _xtrycatchfinallyexpression = _activeMyxGenBrick;
   } catch (final Throwable _t) {
     if (_t instanceof Exception) {
       final Exception e = (Exception) _t;
       _xtrycatchfinallyexpression = null;
     } else {
       throw Exceptions.sneakyThrow(_t);
     }
   }
   final MyxGenBrick pb = _xtrycatchfinallyexpression;
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("package ");
     String _stubClassName = b.getStubClassName();
     String _packageName = MyxCompUtils.toPackageName(_stubClassName);
     _builder.append(_packageName, "");
     _builder.append(";");
     _builder.newLineIfNotEmpty();
     _builder.newLine();
     {
       boolean _equals = Objects.equal(pb, null);
       if (_equals) {
         _builder.append("import org.archstudio.myx.fw.MyxRegistry;");
         _builder.newLine();
       }
     }
     {
       Collection<MyxGenInterface> _interfaces = b.getInterfaces();
       int _size = _interfaces.size();
       boolean _greaterThan = (_size > 0);
       if (_greaterThan) {
         _builder.append("import org.archstudio.myx.fw.MyxUtils;");
         _builder.newLine();
       }
     }
     _builder.append("import org.archstudio.myx.fw.IMyxName;");
     _builder.newLine();
     _builder.newLine();
     _builder.append("/*");
     _builder.newLine();
     _builder.append(" ");
     _builder.append("* DO NOT EDIT THIS CLASS, it is automatically generated.");
     _builder.newLine();
     _builder.append(" ");
     _builder.append("* ANY MODIFICATIONS WILL BE OVERWRITTEN.");
     _builder.newLine();
     _builder.append(" ");
     _builder.append("*");
     _builder.newLine();
     _builder.append(" ");
     _builder.append("* To modify, update the \"");
     String _name = b.getName();
     _builder.append(_name, " ");
     _builder.append("\" MyxGen ");
     _builder.newLineIfNotEmpty();
     _builder.append(" ");
     _builder.append("* extension in the ");
     IContributor _contributor = b.getContributor();
     String _name_1 = _contributor.getName();
     _builder.append(_name_1, " ");
     _builder.append(" plugin.");
     _builder.newLineIfNotEmpty();
     _builder.append(" ");
     _builder.append("*/");
     _builder.newLine();
     _builder.newLine();
     _builder.append("/**");
     _builder.newLine();
     _builder.append(" ");
     _builder.append("* Abstract Myx brick: ");
     String _name_2 = b.getName();
     _builder.append(_name_2, " ");
     _builder.newLineIfNotEmpty();
     _builder.append(" ");
     _builder.append("* ");
     {
       String _description = b.getDescription();
       boolean _notEquals = (!Objects.equal(_description, null));
       if (_notEquals) {
         _builder.append("<p>");
         String _description_1 = b.getDescription();
         _builder.append(_description_1, " ");
       }
     }
     _builder.newLineIfNotEmpty();
     _builder.append(" ");
     _builder.append("* @generated");
     _builder.newLine();
     _builder.append(" ");
     _builder.append("*/");
     _builder.newLine();
     _builder.append("public abstract class ");
     String _stubClassName_1 = b.getStubClassName();
     String _className = MyxCompUtils.toClassName(_stubClassName_1);
     _builder.append(_className, "");
     _builder.newLineIfNotEmpty();
     {
       boolean _equals_1 = Objects.equal(pb, null);
       if (_equals_1) {
         _builder.append("extends org.archstudio.myx.fw.AbstractMyxSimpleBrick");
         _builder.newLine();
       } else {
         _builder.append("extends ");
         String _className_1 = pb.getClassName();
         _builder.append(_className_1, "");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("implements org.archstudio.myx.fw.IMyxDynamicBrick");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_1 = b.getInterfaces();
       final Function1<MyxGenInterface, Boolean> _function =
           new Function1<MyxGenInterface, Boolean>() {
             public Boolean apply(final MyxGenInterface i) {
               EServiceObjectDelegate _serviceObjectDelegate = i.getServiceObjectDelegate();
               boolean _equals =
                   Objects.equal(_serviceObjectDelegate, EServiceObjectDelegate.brick);
               return Boolean.valueOf(_equals);
             }
           };
       Iterable<MyxGenInterface> _filter =
           IterableExtensions.<MyxGenInterface>filter(_interfaces_1, _function);
       boolean _hasElements = false;
       for (final MyxGenInterface i : _filter) {
         if (!_hasElements) {
           _hasElements = true;
           _builder.append(", ", "");
         } else {
           _builder.appendImmediate(", ", "");
         }
         String _className_2 = i.getClassName();
         _builder.append(_className_2, "");
       }
     }
     _builder.newLineIfNotEmpty();
     _builder.append("{");
     _builder.newLine();
     _builder.append("\t");
     _builder.newLine();
     {
       boolean _notEquals_1 = (!Objects.equal(pb, null));
       if (_notEquals_1) {
         _builder.append("\t");
         IContributor _contributor_1 = pb.getContributor();
         String _name_3 = _contributor_1.getName();
         String _className_3 = pb.getClassName();
         String _constructorsFor = MyxCompUtils.constructorsFor(b, _name_3, _className_3);
         _builder.append(_constructorsFor, "	");
         _builder.newLineIfNotEmpty();
       } else {
         _builder.append("\t");
         _builder.append("/**");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* The registry of objects for this brick.");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* @generated");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*/");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(
             "protected final MyxRegistry myxRegistry = MyxRegistry.getSharedInstance();");
         _builder.newLine();
         _builder.append("\t");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("/**");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* Register this brick instance with the registry.");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* @generated");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*/");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("@Override");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("public void begin(){");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("\t");
         _builder.append("super.begin();");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("\t");
         _builder.append("myxRegistry.register(this);");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("}");
         _builder.newLine();
         _builder.append("\t");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("/**");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* Unregister this brick instance with the registry.");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* @generated");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*/");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("@Override");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("public void end(){");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("\t");
         _builder.append("myxRegistry.unregister(this);");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("\t");
         _builder.append("super.end();");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("}");
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_2 = b.getInterfaces();
       for (final MyxGenInterface i_1 : _interfaces_2) {
         _builder.append("\t");
         _builder.append("/**");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* Myx name for the <code>");
         String _name_4 = i_1.getName();
         _builder.append(_name_4, "	 ");
         _builder.append("</code> interface.");
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* ");
         {
           String _description_2 = i_1.getDescription();
           boolean _notEquals_2 = (!Objects.equal(_description_2, null));
           if (_notEquals_2) {
             _builder.append("<p>");
             String _description_3 = i_1.getDescription();
             _builder.append(_description_3, "	 ");
           }
         }
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("* @generated");
         _builder.newLine();
         _builder.append("\t");
         _builder.append(" ");
         _builder.append("*/");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("public static final IMyxName ");
         EMyxInterfaceDirection _direction = i_1.getDirection();
         String _name_5 = _direction.name();
         String _lowerCase = _name_5.toLowerCase();
         String _name_6 = i_1.getName();
         String _firstUpper = StringExtensions.toFirstUpper(_name_6);
         String _plus = (_lowerCase + _firstUpper);
         String _constantName = MyxCompUtils.toConstantName(_plus);
         _builder.append(_constantName, "	");
         _builder.append(" = MyxUtils.createName(\"");
         String _id = i_1.getId();
         _builder.append(_id, "	");
         _builder.append("\");");
         _builder.newLineIfNotEmpty();
         _builder.append("\t");
         _builder.newLine();
         {
           EServiceObjectDelegate _serviceObjectDelegate = i_1.getServiceObjectDelegate();
           boolean _isNeedsVariable = _serviceObjectDelegate.isNeedsVariable();
           if (_isNeedsVariable) {
             _builder.append("\t");
             _builder.append("/**");
             _builder.newLine();
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("* Service object");
             {
               boolean _isSingle = i_1.isSingle();
               boolean _not = (!_isSingle);
               if (_not) {
                 _builder.append("s");
               }
             }
             _builder.append(" for the ");
             String _name_7 = i_1.getName();
             _builder.append(_name_7, "	 ");
             _builder.append(" interface.");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("* @see #");
             EMyxInterfaceDirection _direction_1 = i_1.getDirection();
             String _name_8 = _direction_1.name();
             String _lowerCase_1 = _name_8.toLowerCase();
             String _name_9 = i_1.getName();
             String _firstUpper_1 = StringExtensions.toFirstUpper(_name_9);
             String _plus_1 = (_lowerCase_1 + _firstUpper_1);
             String _constantName_1 = MyxCompUtils.toConstantName(_plus_1);
             _builder.append(_constantName_1, "	 ");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("* @generated");
             _builder.newLine();
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("*/");
             _builder.newLine();
             {
               boolean _isSingle_1 = i_1.isSingle();
               if (_isSingle_1) {
                 _builder.append("\t");
                 _builder.append("protected ");
                 String _className_4 = i_1.getClassName();
                 _builder.append(_className_4, "	");
                 _builder.append(" ");
                 String _name_10 = i_1.getName();
                 _builder.append(_name_10, "	");
                 _builder.append(" = null;");
                 _builder.newLineIfNotEmpty();
               } else {
                 _builder.append("\t");
                 _builder.append("protected final java.util.Collection<");
                 String _className_5 = i_1.getClassName();
                 _builder.append(_className_5, "	");
                 _builder.append("> ");
                 String _name_11 = i_1.getName();
                 _builder.append(_name_11, "	");
                 _builder.append(" = new java.util.concurrent.CopyOnWriteArrayList<");
                 String _className_6 = i_1.getClassName();
                 _builder.append(_className_6, "	");
                 _builder.append(">();");
                 _builder.newLineIfNotEmpty();
               }
             }
           }
         }
         _builder.append("\t");
         _builder.newLine();
         {
           EServiceObjectDelegate _serviceObjectDelegate_1 = i_1.getServiceObjectDelegate();
           boolean _isNeedsProxy = _serviceObjectDelegate_1.isNeedsProxy();
           if (_isNeedsProxy) {
             _builder.append("\t");
             _builder.append("/**");
             _builder.newLine();
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("* Service object proxy for the ");
             String _name_12 = i_1.getName();
             _builder.append(_name_12, "	 ");
             _builder.append(" interface.");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append(" ");
             _builder.append("* Calls to this proxy object are automatically delegated to ");
             {
               EServiceObjectDelegate _serviceObjectDelegate_2 = i_1.getServiceObjectDelegate();
               boolean _equals_2 =
                   Objects.equal(_serviceObjectDelegate_2, EServiceObjectDelegate.myxRegistry);
               if (_equals_2) {
                 _builder.append("all service objects in the MyxRegistry of type ");
                 String _className_7 = i_1.getClassName();
                 _builder.append(_className_7, "	 ");
                 _builder.append(".");
               } else {
                 _builder.append("all connections on the interface");
               }
             }
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("* @see #");
             EMyxInterfaceDirection _direction_2 = i_1.getDirection();
             String _name_13 = _direction_2.name();
             String _lowerCase_2 = _name_13.toLowerCase();
             String _name_14 = i_1.getName();
             String _firstUpper_2 = StringExtensions.toFirstUpper(_name_14);
             String _plus_2 = (_lowerCase_2 + _firstUpper_2);
             String _constantName_2 = MyxCompUtils.toConstantName(_plus_2);
             _builder.append(_constantName_2, "	");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("* @generated");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("*/");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("protected final ");
             String _className_8 = i_1.getClassName();
             _builder.append(_className_8, "	");
             _builder.append(" ");
             String _name_15 = i_1.getName();
             _builder.append(_name_15, "	");
             _builder.append("Proxy =");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t");
             _builder.append("(");
             String _className_9 = i_1.getClassName();
             _builder.append(_className_9, "		");
             _builder.append(") java.lang.reflect.Proxy.newProxyInstance(");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t\t");
             String _className_10 = i_1.getClassName();
             _builder.append(_className_10, "			");
             _builder.append(".class.getClassLoader(), ");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t\t");
             _builder.append("new Class[] { ");
             String _className_11 = i_1.getClassName();
             _builder.append(_className_11, "			");
             _builder.append(".class },");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t\t");
             _builder.append("new java.lang.reflect.InvocationHandler() {");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t");
             _builder.append("@Override");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t");
             _builder.append(
                 "public Object invoke(Object proxy, java.lang.reflect.Method method, Object[] args) throws Throwable {");
             _builder.newLine();
             {
               EServiceObjectDelegate _serviceObjectDelegate_3 = i_1.getServiceObjectDelegate();
               boolean _equals_3 =
                   Objects.equal(_serviceObjectDelegate_3, EServiceObjectDelegate.myxRegistry);
               if (_equals_3) {
                 _builder.append("\t");
                 _builder.append("\t\t\t\t");
                 _builder.append("for (");
                 String _className_12 = i_1.getClassName();
                 _builder.append(_className_12, "					");
                 _builder.append(" o : myxRegistry.getObjects(");
                 String _stubClassName_2 = b.getStubClassName();
                 String _className_13 = MyxCompUtils.toClassName(_stubClassName_2);
                 _builder.append(_className_13, "					");
                 _builder.append(".this, ");
                 String _className_14 = i_1.getClassName();
                 _builder.append(_className_14, "					");
                 _builder.append(".class)) {");
                 _builder.newLineIfNotEmpty();
               } else {
                 boolean _isSingle_2 = i_1.isSingle();
                 boolean _not_1 = (!_isSingle_2);
                 if (_not_1) {
                   _builder.append("\t");
                   _builder.append("\t\t\t\t");
                   _builder.append("for (");
                   String _className_15 = i_1.getClassName();
                   _builder.append(_className_15, "					");
                   _builder.append(" o : ");
                   String _name_16 = i_1.getName();
                   _builder.append(_name_16, "					");
                   _builder.append(") {");
                   _builder.newLineIfNotEmpty();
                 } else {
                   _builder.append("\t");
                   _builder.append("\t\t\t\t");
                   String _className_16 = i_1.getClassName();
                   _builder.append(_className_16, "					");
                   _builder.append(" o = ");
                   String _name_17 = i_1.getName();
                   _builder.append(_name_17, "					");
                   _builder.append(";");
                   _builder.newLineIfNotEmpty();
                   _builder.append("\t");
                   _builder.append("\t\t\t\t");
                   _builder.append("if (o == null) {");
                   _builder.newLine();
                   _builder.append("\t");
                   _builder.append("\t\t\t\t");
                   _builder.append("\t");
                   _builder.append("throw new NullPointerException(\"");
                   String _name_18 = i_1.getName();
                   _builder.append(_name_18, "						");
                   _builder.append("\");");
                   _builder.newLineIfNotEmpty();
                   _builder.append("\t");
                   _builder.append("\t\t\t\t");
                   _builder.append("}");
                   _builder.newLine();
                   _builder.append("\t");
                   _builder.append("\t\t\t\t");
                   _builder.append("else {");
                   _builder.newLine();
                 }
               }
             }
             _builder.append("\t");
             _builder.append("\t\t\t\t");
             _builder.append("try {");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t\t\t");
             _builder.append("method.invoke(o, args);");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t\t");
             _builder.append("}");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t\t");
             _builder.append("catch (Exception e) {");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t\t\t");
             _builder.append("e.printStackTrace();");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t\t");
             _builder.append("}");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t\t");
             _builder.append("}");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t");
             _builder.append("return null;");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t\t\t");
             _builder.append("}");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("\t");
             _builder.append("});");
             _builder.newLine();
           }
         }
         _builder.newLine();
         {
           boolean _isGenerateGetter = i_1.isGenerateGetter();
           if (_isGenerateGetter) {
             _builder.append("\t");
             _builder.append("/**");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("* Returns the service object(s) for the ");
             String _name_19 = i_1.getName();
             _builder.append(_name_19, "	");
             _builder.append(" interface.");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("* @see #");
             EMyxInterfaceDirection _direction_3 = i_1.getDirection();
             String _name_20 = _direction_3.name();
             String _lowerCase_3 = _name_20.toLowerCase();
             String _name_21 = i_1.getName();
             String _firstUpper_3 = StringExtensions.toFirstUpper(_name_21);
             String _plus_3 = (_lowerCase_3 + _firstUpper_3);
             String _constantName_3 = MyxCompUtils.toConstantName(_plus_3);
             _builder.append(_constantName_3, "	");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("* @generated");
             _builder.newLine();
             _builder.append("\t");
             _builder.append("*/");
             _builder.newLine();
             {
               EServiceObjectDelegate _serviceObjectDelegate_4 = i_1.getServiceObjectDelegate();
               boolean _isNeedsProxy_1 = _serviceObjectDelegate_4.isNeedsProxy();
               if (_isNeedsProxy_1) {
                 _builder.append("\t");
                 _builder.append("public ");
                 String _className_17 = i_1.getClassName();
                 _builder.append(_className_17, "	");
                 _builder.append(" get");
                 String _name_22 = i_1.getName();
                 String _firstUpper_4 = StringExtensions.toFirstUpper(_name_22);
                 _builder.append(_firstUpper_4, "	");
                 _builder.append("() {");
                 _builder.newLineIfNotEmpty();
               } else {
                 _builder.append("\t");
                 _builder.append("public ");
                 {
                   boolean _isSingle_3 = i_1.isSingle();
                   if (_isSingle_3) {
                     String _className_18 = i_1.getClassName();
                     _builder.append(_className_18, "	");
                   } else {
                     _builder.append("java.util.Collection<");
                     String _className_19 = i_1.getClassName();
                     _builder.append(_className_19, "	");
                     _builder.append(">");
                   }
                 }
                 _builder.append(" get");
                 String _name_23 = i_1.getName();
                 String _firstUpper_5 = StringExtensions.toFirstUpper(_name_23);
                 _builder.append(_firstUpper_5, "	");
                 _builder.append("() {");
                 _builder.newLineIfNotEmpty();
               }
             }
             {
               EServiceObjectDelegate _serviceObjectDelegate_5 = i_1.getServiceObjectDelegate();
               boolean _equals_4 =
                   Objects.equal(_serviceObjectDelegate_5, EServiceObjectDelegate.brick);
               if (_equals_4) {
                 _builder.append("\t");
                 _builder.append("\t");
                 _builder.append("return this;");
                 _builder.newLine();
               } else {
                 {
                   boolean _and = false;
                   EServiceObjectDelegate _serviceObjectDelegate_6 =
                       i_1.getServiceObjectDelegate();
                   boolean _isNeedsProxy_2 = _serviceObjectDelegate_6.isNeedsProxy();
                   boolean _not_2 = (!_isNeedsProxy_2);
                   if (!_not_2) {
                     _and = false;
                   } else {
                     boolean _isSingle_4 = i_1.isSingle();
                     _and = (_not_2 && _isSingle_4);
                   }
                   if (_and) {
                     _builder.append("\t");
                     _builder.append("\t");
                     _builder.append("if (");
                     String _name_24 = i_1.getName();
                     _builder.append(_name_24, "		");
                     _builder.append(" == null) {");
                     _builder.newLineIfNotEmpty();
                     _builder.append("\t");
                     _builder.append("\t");
                     _builder.append("\t");
                     _builder.append(
                         "throw new NullPointerException(\"Uninitialized service object: ");
                     String _name_25 = i_1.getName();
                     _builder.append(_name_25, "			");
                     _builder.append("\");");
                     _builder.newLineIfNotEmpty();
                     _builder.append("\t");
                     _builder.append("\t");
                     _builder.append("}");
                     _builder.newLine();
                   }
                 }
                 _builder.append("\t");
                 _builder.append("\t");
                 _builder.append("return ");
                 String _name_26 = i_1.getName();
                 _builder.append(_name_26, "		");
                 {
                   EServiceObjectDelegate _serviceObjectDelegate_7 =
                       i_1.getServiceObjectDelegate();
                   boolean _isNeedsProxy_3 = _serviceObjectDelegate_7.isNeedsProxy();
                   if (_isNeedsProxy_3) {
                     _builder.append("Proxy");
                   }
                 }
                 _builder.append(";");
                 _builder.newLineIfNotEmpty();
               }
             }
             _builder.append("\t");
             _builder.append("}");
             _builder.newLine();
           }
         }
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("/**");
     _builder.newLine();
     _builder.append("\t ");
     _builder.append("* Returns service object(s) for IN interfaces.");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_3 = b.getInterfaces();
       final Function1<MyxGenInterface, Boolean> _function_1 =
           new Function1<MyxGenInterface, Boolean>() {
             public Boolean apply(final MyxGenInterface i) {
               EMyxInterfaceDirection _direction = i.getDirection();
               boolean _equals = Objects.equal(_direction, EMyxInterfaceDirection.IN);
               return Boolean.valueOf(_equals);
             }
           };
       Iterable<MyxGenInterface> _filter_1 =
           IterableExtensions.<MyxGenInterface>filter(_interfaces_3, _function_1);
       for (final MyxGenInterface i_2 : _filter_1) {
         _builder.append("\t");
         _builder.append("* @see #");
         EMyxInterfaceDirection _direction_4 = i_2.getDirection();
         String _name_27 = _direction_4.name();
         String _lowerCase_4 = _name_27.toLowerCase();
         String _name_28 = i_2.getName();
         String _firstUpper_6 = StringExtensions.toFirstUpper(_name_28);
         String _plus_4 = (_lowerCase_4 + _firstUpper_6);
         String _constantName_4 = MyxCompUtils.toConstantName(_plus_4);
         _builder.append(_constantName_4, "	");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.append("* @generated");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("*/");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("@Override");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("public Object getServiceObject(IMyxName interfaceName) {");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_4 = b.getInterfaces();
       final Function1<MyxGenInterface, Boolean> _function_2 =
           new Function1<MyxGenInterface, Boolean>() {
             public Boolean apply(final MyxGenInterface i) {
               EMyxInterfaceDirection _direction = i.getDirection();
               boolean _equals = Objects.equal(_direction, EMyxInterfaceDirection.IN);
               return Boolean.valueOf(_equals);
             }
           };
       Iterable<MyxGenInterface> _filter_2 =
           IterableExtensions.<MyxGenInterface>filter(_interfaces_4, _function_2);
       for (final MyxGenInterface i_3 : _filter_2) {
         _builder.append("\t");
         _builder.append("if(interfaceName.equals(");
         EMyxInterfaceDirection _direction_5 = i_3.getDirection();
         String _name_29 = _direction_5.name();
         String _lowerCase_5 = _name_29.toLowerCase();
         String _name_30 = i_3.getName();
         String _firstUpper_7 = StringExtensions.toFirstUpper(_name_30);
         String _plus_5 = (_lowerCase_5 + _firstUpper_7);
         String _constantName_5 = MyxCompUtils.toConstantName(_plus_5);
         _builder.append(_constantName_5, "	");
         _builder.append(")) {");
         _builder.newLineIfNotEmpty();
         {
           EServiceObjectDelegate _serviceObjectDelegate_8 = i_3.getServiceObjectDelegate();
           boolean _equals_5 =
               Objects.equal(_serviceObjectDelegate_8, EServiceObjectDelegate.brick);
           if (_equals_5) {
             _builder.append("\t");
             _builder.append("\t");
             _builder.append("return this;");
             _builder.newLine();
           } else {
             {
               boolean _and_1 = false;
               EServiceObjectDelegate _serviceObjectDelegate_9 = i_3.getServiceObjectDelegate();
               boolean _isNeedsProxy_4 = _serviceObjectDelegate_9.isNeedsProxy();
               boolean _not_3 = (!_isNeedsProxy_4);
               if (!_not_3) {
                 _and_1 = false;
               } else {
                 boolean _isSingle_5 = i_3.isSingle();
                 _and_1 = (_not_3 && _isSingle_5);
               }
               if (_and_1) {
                 _builder.append("\t");
                 _builder.append("\t");
                 _builder.append("if (");
                 String _name_31 = i_3.getName();
                 _builder.append(_name_31, "		");
                 _builder.append(" == null) {");
                 _builder.newLineIfNotEmpty();
                 _builder.append("\t");
                 _builder.append("\t");
                 _builder.append("\t");
                 _builder.append(
                     "throw new NullPointerException(\"Uninitialized service object: ");
                 String _name_32 = i_3.getName();
                 _builder.append(_name_32, "			");
                 _builder.append("\");");
                 _builder.newLineIfNotEmpty();
                 _builder.append("\t");
                 _builder.append("\t");
                 _builder.append("}");
                 _builder.newLine();
               }
             }
             _builder.append("\t");
             _builder.append("\t");
             _builder.append("return ");
             String _name_33 = i_3.getName();
             _builder.append(_name_33, "		");
             {
               EServiceObjectDelegate _serviceObjectDelegate_10 = i_3.getServiceObjectDelegate();
               boolean _isNeedsProxy_5 = _serviceObjectDelegate_10.isNeedsProxy();
               if (_isNeedsProxy_5) {
                 _builder.append("Proxy");
               }
             }
             _builder.append(";");
             _builder.newLineIfNotEmpty();
           }
         }
         _builder.append("\t");
         _builder.append("}");
         _builder.newLine();
       }
     }
     {
       String _parentBrickId_1 = b.getParentBrickId();
       boolean _equals_6 = Objects.equal(_parentBrickId_1, null);
       if (_equals_6) {
         _builder.append("\t");
         _builder.append(
             "throw new IllegalArgumentException(\"Unhandled interface: \"+interfaceName.getName());");
         _builder.newLine();
       } else {
         _builder.append("\t");
         _builder.append("return super.getServiceObject(interfaceName);");
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.newLine();
     _builder.append("\t");
     _builder.append("/**");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("* Update service objects based on connected OUT interfaces.");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_5 = b.getInterfaces();
       final Function1<MyxGenInterface, Boolean> _function_3 =
           new Function1<MyxGenInterface, Boolean>() {
             public Boolean apply(final MyxGenInterface i) {
               EMyxInterfaceDirection _direction = i.getDirection();
               boolean _equals = Objects.equal(_direction, EMyxInterfaceDirection.OUT);
               return Boolean.valueOf(_equals);
             }
           };
       Iterable<MyxGenInterface> _filter_3 =
           IterableExtensions.<MyxGenInterface>filter(_interfaces_5, _function_3);
       for (final MyxGenInterface i_4 : _filter_3) {
         _builder.append("\t");
         _builder.append("* @see #");
         EMyxInterfaceDirection _direction_6 = i_4.getDirection();
         String _name_34 = _direction_6.name();
         String _lowerCase_6 = _name_34.toLowerCase();
         String _name_35 = i_4.getName();
         String _firstUpper_8 = StringExtensions.toFirstUpper(_name_35);
         String _plus_6 = (_lowerCase_6 + _firstUpper_8);
         String _constantName_6 = MyxCompUtils.toConstantName(_plus_6);
         _builder.append(_constantName_6, "	");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.append("* @generated");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("*/");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("@Override");
     _builder.newLine();
     _builder.append("\t");
     _builder.append(
         "public void interfaceConnected(IMyxName interfaceName, Object serviceObject) {");
     _builder.newLine();
     _builder.append("\t\t");
     _builder.append("if (serviceObject == null)");
     _builder.newLine();
     _builder.append("\t\t\t");
     _builder.append("throw new NullPointerException(interfaceName.getName());");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_6 = b.getInterfaces();
       final Function1<MyxGenInterface, Boolean> _function_4 =
           new Function1<MyxGenInterface, Boolean>() {
             public Boolean apply(final MyxGenInterface i) {
               EMyxInterfaceDirection _direction = i.getDirection();
               boolean _equals = Objects.equal(_direction, EMyxInterfaceDirection.OUT);
               return Boolean.valueOf(_equals);
             }
           };
       Iterable<MyxGenInterface> _filter_4 =
           IterableExtensions.<MyxGenInterface>filter(_interfaces_6, _function_4);
       for (final MyxGenInterface i_5 : _filter_4) {
         _builder.newLine();
         _builder.append("\t");
         _builder.append("if(interfaceName.equals(");
         EMyxInterfaceDirection _direction_7 = i_5.getDirection();
         String _name_36 = _direction_7.name();
         String _lowerCase_7 = _name_36.toLowerCase();
         String _name_37 = i_5.getName();
         String _firstUpper_9 = StringExtensions.toFirstUpper(_name_37);
         String _plus_7 = (_lowerCase_7 + _firstUpper_9);
         String _constantName_7 = MyxCompUtils.toConstantName(_plus_7);
         _builder.append(_constantName_7, "	");
         _builder.append(")) {");
         _builder.newLineIfNotEmpty();
         {
           boolean _isSingle_6 = i_5.isSingle();
           if (_isSingle_6) {
             _builder.append("\t");
             _builder.append("\t\t");
             _builder.append("if (");
             String _name_38 = i_5.getName();
             _builder.append(_name_38, "			");
             _builder.append(" != null)");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t\t");
             _builder.append("\t");
             _builder.append(
                 "throw new IllegalStateException(\"Only a single connection is supported on interface: ");
             String _name_39 = i_5.getName();
             _builder.append(_name_39, "				");
             _builder.append("\");");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t\t");
             String _name_40 = i_5.getName();
             _builder.append(_name_40, "			");
             _builder.append(" = (");
             String _className_20 = i_5.getClassName();
             _builder.append(_className_20, "			");
             _builder.append(") serviceObject;");
             _builder.newLineIfNotEmpty();
           } else {
             _builder.append("\t");
             _builder.append("\t\t");
             String _name_41 = i_5.getName();
             _builder.append(_name_41, "			");
             _builder.append(".add((");
             String _className_21 = i_5.getClassName();
             _builder.append(_className_21, "			");
             _builder.append(") serviceObject);");
             _builder.newLineIfNotEmpty();
           }
         }
         _builder.append("\t");
         _builder.append("\t\t");
         _builder.append("return;");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("}");
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     {
       String _parentBrickId_2 = b.getParentBrickId();
       boolean _equals_7 = Objects.equal(_parentBrickId_2, null);
       if (_equals_7) {
         _builder.append("\t");
         _builder.append(
             "throw new IllegalArgumentException(\"Unhandled interface: \"+interfaceName.getName());");
         _builder.newLine();
       } else {
         _builder.append("\t");
         _builder.append("super.interfaceConnected(interfaceName, serviceObject);");
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.newLine();
     _builder.append("\t");
     _builder.append("/**");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("* Update service objects based on disconnecting OUT interfaces.");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_7 = b.getInterfaces();
       final Function1<MyxGenInterface, Boolean> _function_5 =
           new Function1<MyxGenInterface, Boolean>() {
             public Boolean apply(final MyxGenInterface i) {
               EMyxInterfaceDirection _direction = i.getDirection();
               boolean _equals = Objects.equal(_direction, EMyxInterfaceDirection.OUT);
               return Boolean.valueOf(_equals);
             }
           };
       Iterable<MyxGenInterface> _filter_5 =
           IterableExtensions.<MyxGenInterface>filter(_interfaces_7, _function_5);
       for (final MyxGenInterface i_6 : _filter_5) {
         _builder.append("\t");
         _builder.append("* @see #");
         EMyxInterfaceDirection _direction_8 = i_6.getDirection();
         String _name_42 = _direction_8.name();
         String _lowerCase_8 = _name_42.toLowerCase();
         String _name_43 = i_6.getName();
         String _firstUpper_10 = StringExtensions.toFirstUpper(_name_43);
         String _plus_8 = (_lowerCase_8 + _firstUpper_10);
         String _constantName_8 = MyxCompUtils.toConstantName(_plus_8);
         _builder.append(_constantName_8, "	");
         _builder.newLineIfNotEmpty();
       }
     }
     _builder.append("\t");
     _builder.append("* @generated");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("*/");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("@Override");
     _builder.newLine();
     _builder.append("\t");
     _builder.append(
         "public void interfaceDisconnecting(IMyxName interfaceName, Object serviceObject) {");
     _builder.newLine();
     _builder.append("\t\t");
     _builder.append("if (serviceObject == null)");
     _builder.newLine();
     _builder.append("\t\t\t");
     _builder.append("throw new NullPointerException(interfaceName.getName());");
     _builder.newLine();
     {
       Collection<MyxGenInterface> _interfaces_8 = b.getInterfaces();
       final Function1<MyxGenInterface, Boolean> _function_6 =
           new Function1<MyxGenInterface, Boolean>() {
             public Boolean apply(final MyxGenInterface i) {
               EMyxInterfaceDirection _direction = i.getDirection();
               boolean _equals = Objects.equal(_direction, EMyxInterfaceDirection.OUT);
               return Boolean.valueOf(_equals);
             }
           };
       Iterable<MyxGenInterface> _filter_6 =
           IterableExtensions.<MyxGenInterface>filter(_interfaces_8, _function_6);
       for (final MyxGenInterface i_7 : _filter_6) {
         _builder.newLine();
         _builder.append("\t");
         _builder.append("if(interfaceName.equals(");
         EMyxInterfaceDirection _direction_9 = i_7.getDirection();
         String _name_44 = _direction_9.name();
         String _lowerCase_9 = _name_44.toLowerCase();
         String _name_45 = i_7.getName();
         String _firstUpper_11 = StringExtensions.toFirstUpper(_name_45);
         String _plus_9 = (_lowerCase_9 + _firstUpper_11);
         String _constantName_9 = MyxCompUtils.toConstantName(_plus_9);
         _builder.append(_constantName_9, "	");
         _builder.append(")) {");
         _builder.newLineIfNotEmpty();
         {
           boolean _isSingle_7 = i_7.isSingle();
           if (_isSingle_7) {
             _builder.append("\t");
             _builder.append("\t\t");
             _builder.append("if (");
             String _name_46 = i_7.getName();
             _builder.append(_name_46, "			");
             _builder.append(" == null)");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t\t");
             _builder.append("\t");
             _builder.append(
                 "throw new IllegalStateException(\"A connection was never made on interface: ");
             String _name_47 = i_7.getName();
             _builder.append(_name_47, "				");
             _builder.append("\");");
             _builder.newLineIfNotEmpty();
             _builder.append("\t");
             _builder.append("\t\t");
             String _name_48 = i_7.getName();
             _builder.append(_name_48, "			");
             _builder.append(" = null;");
             _builder.newLineIfNotEmpty();
           } else {
             _builder.append("\t");
             _builder.append("\t\t");
             String _name_49 = i_7.getName();
             _builder.append(_name_49, "			");
             _builder.append(".remove(serviceObject);");
             _builder.newLineIfNotEmpty();
           }
         }
         _builder.append("\t");
         _builder.append("\t\t");
         _builder.append("return;");
         _builder.newLine();
         _builder.append("\t");
         _builder.append("}");
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.newLine();
     {
       String _parentBrickId_3 = b.getParentBrickId();
       boolean _equals_8 = Objects.equal(_parentBrickId_3, null);
       if (_equals_8) {
         _builder.append("\t");
         _builder.append(
             "throw new IllegalArgumentException(\"Unhandled interface: \"+interfaceName.getName());");
         _builder.newLine();
       } else {
         _builder.append("\t");
         _builder.append("super.interfaceDisconnecting(interfaceName, serviceObject);");
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.newLine();
     _builder.append("\t");
     _builder.append("/**");
     _builder.newLine();
     _builder.append("\t ");
     _builder.append("* Performs no operation upon the completion of an interface disconnecting.");
     _builder.newLine();
     _builder.append("\t ");
     _builder.append("* @generated");
     _builder.newLine();
     _builder.append("\t ");
     _builder.append("*/");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("@Override");
     _builder.newLine();
     _builder.append("\t");
     _builder.append(
         "public void interfaceDisconnected(IMyxName interfaceName, Object serviceObject) {");
     _builder.newLine();
     {
       String _parentBrickId_4 = b.getParentBrickId();
       boolean _notEquals_3 = (!Objects.equal(_parentBrickId_4, null));
       if (_notEquals_3) {
         _builder.append("\t");
         _builder.append("super.interfaceDisconnected(interfaceName, serviceObject);");
         _builder.newLine();
       }
     }
     _builder.append("\t");
     _builder.append("}");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     return _builder.toString();
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }