protected void _infer( final Script script, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) { Resource _eResource = script.eResource(); URI _uRI = _eResource.getURI(); URI _trimFileExtension = _uRI.trimFileExtension(); final String className = _trimFileExtension.lastSegment(); JvmGenericType _class = this._jvmTypesBuilder.toClass(script, className); IPostIndexingInitializing<JvmGenericType> _accept = acceptor.<JvmGenericType>accept(_class); final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { public void apply(final JvmGenericType it) { EList<JvmMember> _members = it.getMembers(); JvmTypeReference _newTypeRef = ScriptingJvmModelInferrer.this._jvmTypesBuilder.newTypeRef(script, Void.TYPE); final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { public void apply(final JvmOperation it) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _newTypeRef = ScriptingJvmModelInferrer.this._jvmTypesBuilder.newTypeRef( script, String.class); JvmTypeReference _addArrayTypeDimension = ScriptingJvmModelInferrer.this._jvmTypesBuilder.addArrayTypeDimension( _newTypeRef); JvmFormalParameter _parameter = ScriptingJvmModelInferrer.this._jvmTypesBuilder.toParameter( script, "args", _addArrayTypeDimension); ScriptingJvmModelInferrer.this._jvmTypesBuilder .<JvmFormalParameter>operator_add(_parameters, _parameter); it.setStatic(true); ScriptingJvmModelInferrer.this._jvmTypesBuilder.setBody(it, script); } }; JvmOperation _method = ScriptingJvmModelInferrer.this._jvmTypesBuilder.toMethod( script, "main", _newTypeRef, _function); ScriptingJvmModelInferrer.this._jvmTypesBuilder.<JvmOperation>operator_add( _members, _method); } }; _accept.initializeLater(_function); }
protected void _infer( final Model m, final IJvmDeclaredTypeAcceptor acceptor, final boolean prelinkingPhase) { final XBlockExpression e = m.getBlock(); Resource _eResource = e.eResource(); String _name = this.name(_eResource); JvmGenericType _class = this._jvmTypesBuilder.toClass(e, _name); final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { EList<JvmMember> _members = it.getMembers(); JvmTypeReference _inferredType = this._jvmTypesBuilder.inferredType(); final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> { EList<JvmTypeReference> _exceptions = it_1.getExceptions(); JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Throwable.class); this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef); this._jvmTypesBuilder.setBody(it_1, e); }; JvmOperation _method = this._jvmTypesBuilder.toMethod(e, "myMethod", _inferredType, _function_1); this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method); }; acceptor.<JvmGenericType>accept(_class, _function); }
protected void _infer( final ModuleAST module, final IJvmDeclaredTypeAcceptor acceptor, final boolean preIndexingPhase) { QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(module); JvmGenericType _class = this.builder.toClass(module, _fullyQualifiedName); final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { @Override public void apply(final JvmGenericType it) { String _documentation = GuiceModulesJvmModelInferrer.this.builder.getDocumentation(module); GuiceModulesJvmModelInferrer.this.builder.setDocumentation(it, _documentation); EList<JvmTypeReference> _superTypes = it.getSuperTypes(); JvmTypeReference _typeRef = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef(Module.class); GuiceModulesJvmModelInferrer.this.builder.<JvmTypeReference>operator_add( _superTypes, _typeRef); EList<ModuleAST> _mixins = module.getMixins(); for (final ModuleAST mixin : _mixins) { boolean _eIsProxy = mixin.eIsProxy(); boolean _not = (!_eIsProxy); if (_not) { EList<JvmMember> _members = it.getMembers(); String _simpleName = GuiceModulesJvmModelInferrer.this.simpleName(mixin); QualifiedName _fullyQualifiedName = GuiceModulesJvmModelInferrer.this._iQualifiedNameProvider.getFullyQualifiedName( mixin); String _string = _fullyQualifiedName.toString(); JvmTypeReference _typeRef_1 = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef(_string); final Procedure1<JvmField> _function = new Procedure1<JvmField>() { @Override public void apply(final JvmField it) { StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo( StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("new "); String _name = mixin.getName(); _builder.append(_name, ""); _builder.append("()"); } }; GuiceModulesJvmModelInferrer.this.builder.setInitializer(it, _client); } }; JvmField _field = GuiceModulesJvmModelInferrer.this.builder.toField( mixin, _simpleName, _typeRef_1, _function); GuiceModulesJvmModelInferrer.this.builder.<JvmField>operator_add(_members, _field); } } EList<BindingAST> _bindings = module.getBindings(); for (final BindingAST binding : _bindings) { { XExpression _toInstance = binding.getToInstance(); boolean _notEquals = (!Objects.equal(_toInstance, null)); if (_notEquals) { EList<JvmMember> _members_1 = it.getMembers(); String _syntheticToInstanceName = GuiceModulesJvmModelInferrer.this.syntheticToInstanceName(binding); KeyAST _from = binding.getFrom(); JvmTypeReference _type = _from.getType(); final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { @Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PRIVATE); XExpression _toInstance = binding.getToInstance(); GuiceModulesJvmModelInferrer.this.builder.setBody(it, _toInstance); } }; JvmOperation _method = GuiceModulesJvmModelInferrer.this.builder.toMethod( binding, _syntheticToInstanceName, _type, _function_1); GuiceModulesJvmModelInferrer.this.builder.<JvmOperation>operator_add( _members_1, _method); } KeyAST _to = binding.getTo(); XAnnotation _annotation = null; if (_to != null) { _annotation = _to.getAnnotation(); } boolean _notEquals_1 = (!Objects.equal(_annotation, null)); if (_notEquals_1) { EList<JvmMember> _members_2 = it.getMembers(); KeyAST _to_1 = binding.getTo(); String _syntheticName = GuiceModulesJvmModelInferrer.this.syntheticName(_to_1); KeyAST _to_2 = binding.getTo(); JvmTypeReference _type_1 = _to_2.getType(); final Procedure1<JvmField> _function_2 = new Procedure1<JvmField>() { @Override public void apply(final JvmField it) { KeyAST _to = binding.getTo(); XAnnotation _annotation = _to.getAnnotation(); GuiceModulesJvmModelInferrer.this.builder.addAnnotation(it, _annotation); it.setVisibility(JvmVisibility.PRIVATE); } }; JvmField _field_1 = GuiceModulesJvmModelInferrer.this.builder.toField( binding, _syntheticName, _type_1, _function_2); GuiceModulesJvmModelInferrer.this.builder.<JvmField>operator_add( _members_2, _field_1); } KeyAST _from_1 = binding.getFrom(); XAnnotation _annotation_1 = _from_1.getAnnotation(); boolean _notEquals_2 = (!Objects.equal(_annotation_1, null)); if (_notEquals_2) { EList<JvmMember> _members_3 = it.getMembers(); KeyAST _from_2 = binding.getFrom(); String _syntheticName_1 = GuiceModulesJvmModelInferrer.this.syntheticName(_from_2); KeyAST _from_3 = binding.getFrom(); JvmTypeReference _type_2 = _from_3.getType(); final Procedure1<JvmField> _function_3 = new Procedure1<JvmField>() { @Override public void apply(final JvmField it) { KeyAST _from = binding.getFrom(); XAnnotation _annotation = _from.getAnnotation(); GuiceModulesJvmModelInferrer.this.builder.addAnnotation(it, _annotation); it.setVisibility(JvmVisibility.PRIVATE); } }; JvmField _field_2 = GuiceModulesJvmModelInferrer.this.builder.toField( binding, _syntheticName_1, _type_2, _function_3); GuiceModulesJvmModelInferrer.this.builder.<JvmField>operator_add( _members_3, _field_2); } } } EList<JvmMember> _members_1 = it.getMembers(); JvmTypeReference _typeRef_2 = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef(void.class); final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { @Override public void apply(final JvmOperation it) { EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef( Binder.class); JvmFormalParameter _parameter = GuiceModulesJvmModelInferrer.this.builder.toParameter( module, "binder", _typeRef); GuiceModulesJvmModelInferrer.this.builder.<JvmFormalParameter>operator_add( _parameters, _parameter); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo( StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("configure(binder, new "); _builder.append(HashSet.class, ""); _builder.append("<"); JvmTypeReference _wildcard = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.wildcard(); JvmTypeReference _typeRef = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef( Key.class, _wildcard); _builder.append(_typeRef, ""); _builder.append(">());"); _builder.newLineIfNotEmpty(); } }; GuiceModulesJvmModelInferrer.this.builder.setBody(it, _client); } }; JvmOperation _method = GuiceModulesJvmModelInferrer.this.builder.toMethod( module, "configure", _typeRef_2, _function_1); GuiceModulesJvmModelInferrer.this.builder.<JvmOperation>operator_add( _members_1, _method); EList<JvmMember> _members_2 = it.getMembers(); JvmTypeReference _typeRef_3 = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef(void.class); final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() { @Override public void apply(final JvmOperation it) { GuiceModulesJvmModelInferrer.this.builder.setDocumentation( it, "Registers bindings for keys not present in the given set."); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef( Binder.class); JvmFormalParameter _parameter = GuiceModulesJvmModelInferrer.this.builder.toParameter( module, "bind", _typeRef); GuiceModulesJvmModelInferrer.this.builder.<JvmFormalParameter>operator_add( _parameters, _parameter); EList<JvmFormalParameter> _parameters_1 = it.getParameters(); JvmTypeReference _wildcard = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.wildcard(); JvmTypeReference _typeRef_1 = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef( Key.class, _wildcard); JvmTypeReference _typeRef_2 = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef( Set.class, _typeRef_1); JvmFormalParameter _parameter_1 = GuiceModulesJvmModelInferrer.this.builder.toParameter( module, "usedKeys", _typeRef_2); GuiceModulesJvmModelInferrer.this.builder.<JvmFormalParameter>operator_add( _parameters_1, _parameter_1); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo( StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("try {"); _builder.newLine(); { EList<BindingAST> _bindings = module.getBindings(); for (final BindingAST b : _bindings) { _builder.append("\t"); _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("\t"); KeyAST _from = b.getFrom(); JvmTypeReference _type = _from.getType(); JvmTypeReference _typeRef = GuiceModulesJvmModelInferrer.this._typeReferenceBuilder.typeRef( Key.class, _type); _builder.append(_typeRef, "\t\t"); _builder.append(" key = "); KeyAST _from_1 = b.getFrom(); StringConcatenationClient _guiceKey = GuiceModulesJvmModelInferrer.this.guiceKey(_from_1); _builder.append(_guiceKey, "\t\t"); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("\t"); _builder.append("if (usedKeys.add(key)) {"); _builder.newLine(); { XExpression _toInstance = b.getToInstance(); boolean _notEquals = (!Objects.equal(_toInstance, null)); if (_notEquals) { _builder.append("\t"); _builder.append("\t\t"); _builder.append("bind.bind(key).toInstance("); String _syntheticToInstanceName = GuiceModulesJvmModelInferrer.this.syntheticToInstanceName( b); _builder.append(_syntheticToInstanceName, "\t\t\t"); _builder.append("());"); _builder.newLineIfNotEmpty(); } else { _builder.append("\t"); _builder.append("\t\t"); _builder.append("bind.bind(key).to("); KeyAST _to = b.getTo(); StringConcatenationClient _guiceKey_1 = GuiceModulesJvmModelInferrer.this.guiceKey(_to); _builder.append(_guiceKey_1, "\t\t\t"); _builder.append(");"); _builder.newLineIfNotEmpty(); } } _builder.append("\t"); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); } } { EList<ModuleAST> _mixins = module.getMixins(); for (final ModuleAST mix : _mixins) { _builder.append("\t"); String _simpleName = GuiceModulesJvmModelInferrer.this.simpleName(mix); _builder.append(_simpleName, "\t"); _builder.append(".configure(bind, usedKeys);"); _builder.newLineIfNotEmpty(); } } _builder.append("} catch ("); _builder.append(Exception.class, ""); _builder.append(" e) {"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("throw new "); _builder.append(RuntimeException.class, "\t"); _builder.append("(e);"); _builder.newLineIfNotEmpty(); _builder.append("}"); _builder.newLine(); } }; GuiceModulesJvmModelInferrer.this.builder.setBody(it, _client); } }; JvmOperation _method_1 = GuiceModulesJvmModelInferrer.this.builder.toMethod( module, "configure", _typeRef_3, _function_2); GuiceModulesJvmModelInferrer.this.builder.<JvmOperation>operator_add( _members_2, _method_1); } }; acceptor.<JvmGenericType>accept(_class, _function); }
protected void _infer( final Model model, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPrelinkingPhase) { Resource _eResource = model.eResource(); URI _uRI = _eResource.getURI(); URI _trimFileExtension = _uRI.trimFileExtension(); final String postfix = _trimFileExtension.lastSegment(); JvmGenericType _class = this._jvmTypesBuilder.toClass(model, (IModelQueryConstants.INFERRED_CLASS_NAME + postfix)); final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> { EList<JvmMember> _members = it.getMembers(); JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IResourceDescriptions.class); JvmField _field = this._jvmTypesBuilder.toField(model, IModelQueryConstants.INDEX, _typeRef); this._jvmTypesBuilder.<JvmField>operator_add(_members, _field); EList<JvmMember> _members_1 = it.getMembers(); JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IProject.class); JvmField _field_1 = this._jvmTypesBuilder.toField(model, IModelQueryConstants.PROJECT, _typeRef_1); this._jvmTypesBuilder.<JvmField>operator_add(_members_1, _field_1); EList<JvmMember> _members_2 = it.getMembers(); JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(ResourceSet.class); JvmField _field_2 = this._jvmTypesBuilder.toField(model, IModelQueryConstants.RESOURCESET, _typeRef_2); this._jvmTypesBuilder.<JvmField>operator_add(_members_2, _field_2); EList<JvmMember> _members_3 = it.getMembers(); JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Injector.class); JvmField _field_3 = this._jvmTypesBuilder.toField(model, IModelQueryConstants.INJECTOR, _typeRef_3); this._jvmTypesBuilder.<JvmField>operator_add(_members_3, _field_3); EList<JvmMember> _members_4 = it.getMembers(); JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(Void.TYPE); final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> { XBlockExpression _body = model.getBody(); this._jvmTypesBuilder.setBody(it_1, _body); EList<JvmTypeReference> _exceptions = it_1.getExceptions(); JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(Exception.class); this._jvmTypesBuilder.<JvmTypeReference>operator_add(_exceptions, _typeRef_5); }; JvmOperation _method = this._jvmTypesBuilder.toMethod(model, "main", _typeRef_4, _function_1); this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method); EList<XMethodDeclaration> _methods = model.getMethods(); for (final XMethodDeclaration op : _methods) { EList<JvmMember> _members_5 = it.getMembers(); String _name = op.getName(); JvmTypeReference _elvis = null; JvmTypeReference _type = op.getType(); if (_type != null) { _elvis = _type; } else { JvmTypeReference _inferredType = this._jvmTypesBuilder.inferredType(); _elvis = _inferredType; } final Procedure1<JvmOperation> _function_2 = (JvmOperation it_1) -> { EList<JvmFormalParameter> _parameters = op.getParameters(); for (final JvmFormalParameter p : _parameters) { EList<JvmFormalParameter> _parameters_1 = it_1.getParameters(); String _name_1 = p.getName(); JvmTypeReference _parameterType = p.getParameterType(); JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(p, _name_1, _parameterType); this._jvmTypesBuilder.<JvmFormalParameter>operator_add( _parameters_1, _parameter); } EList<JvmTypeParameter> _typeParameters = op.getTypeParameters(); this.copyAndFixTypeParameters(_typeParameters, it_1); XExpression _body = op.getBody(); this._jvmTypesBuilder.setBody(it_1, _body); }; JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(op, _name, _elvis, _function_2); this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_1); } }; acceptor.<JvmGenericType>accept(_class, _function); }