Search in sources :

Example 46 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class XbaseGeneratorFragment2 method doGenerateXtendInferrer.

protected void doGenerateXtendInferrer() {
    final TypeReference firstRuleType = TypeReference.typeRef(GenModelUtil2.getJavaTypeName(IterableExtensions.<AbstractRule>head(this.getLanguage().getGrammar().getRules()).getType().getClassifier(), this.getLanguage().getGrammar().eResource().getResourceSet()));
    TypeReference _jvmModelInferrer = this.getJvmModelInferrer();
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("/**");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("* <p>Infers a JVM model from the source model.</p> ");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("*");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("* <p>The JVM model should contain all elements that would appear in the Java code ");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>     ");
            _builder.newLine();
            _builder.append(" ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("class ");
            String _simpleName = XbaseGeneratorFragment2.this.getJvmModelInferrer().getSimpleName();
            _builder.append(_simpleName);
            _builder.append(" extends ");
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer");
            _builder.append(_typeRef);
            _builder.append(" {");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("/**");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* convenience API to build and initialize JVM types and their members.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("@");
            _builder.append(Inject.class, "\t");
            _builder.append(" extension ");
            TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder");
            _builder.append(_typeRef_1, "\t");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            _builder.append("\t");
            _builder.append("/**");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* The dispatch method {@code infer} is called for each instance of the");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* given element\'s type that is contained in a resource.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* ");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* @param element");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            the model to create one or more");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            {@link org.eclipse.xtext.common.types.JvmDeclaredType declared");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            types} from.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* @param acceptor");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            each created");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            {@link org.eclipse.xtext.common.types.JvmDeclaredType type}");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            without a container should be passed to the acceptor in order");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            get attached to the current resource. The acceptor\'s");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            {@link IJvmDeclaredTypeAcceptor#accept(org.eclipse.xtext.common.types.JvmDeclaredType)");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            accept(..)} method takes the constructed empty type for the");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            pre-indexing phase. This one is further initialized in the");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            indexing phase using the lambda you pass as the last argument.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("* @param isPreIndexingPhase");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            whether the method is called in a pre-indexing phase, i.e.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            when the global index is not yet fully updated. You must not");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            rely on linking using the index if isPreIndexingPhase is");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*            <code>true</code>.");
            _builder.newLine();
            _builder.append("\t ");
            _builder.append("*/");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("def dispatch void infer(");
            _builder.append(firstRuleType, "\t");
            _builder.append(" element, ");
            TypeReference _typeRef_2 = TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor");
            _builder.append(_typeRef_2, "\t");
            _builder.append(" acceptor, boolean isPreIndexingPhase) {");
            _builder.newLineIfNotEmpty();
            _builder.append("\t\t");
            _builder.append("// Here you explain how your model is mapped to Java elements, by writing the actual translation code.");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.newLine();
            _builder.append("\t\t");
            _builder.append("// An implementation for the initial hello world example could look like this:");
            _builder.newLine();
            _builder.append("// \t\tacceptor.accept(element.toClass(\"my.company.greeting.MyGreetings\")) [");
            _builder.newLine();
            _builder.append("// \t\t\tfor (greeting : element.greetings) {");
            _builder.newLine();
            _builder.append("// \t\t\t\tmembers += greeting.toMethod(\"hello\" + greeting.name, typeRef(String)) [");
            _builder.newLine();
            _builder.append("// \t\t\t\t\tbody = ");
            _builder.append("\'\'\'");
            _builder.newLineIfNotEmpty();
            _builder.append("//\t\t\t\t\t\treturn \"Hello ");
            _builder.append("�");
            _builder.append("greeting.name");
            _builder.append("�");
            _builder.append("\";");
            _builder.newLineIfNotEmpty();
            _builder.append("//\t\t\t\t\t");
            _builder.append("\'\'\'");
            _builder.newLineIfNotEmpty();
            _builder.append("//\t\t\t\t]");
            _builder.newLine();
            _builder.append("//\t\t\t}");
            _builder.newLine();
            _builder.append("//\t\t]");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            _builder.append("}");
            _builder.newLine();
        }
    };
    this.fileAccessFactory.createXtendFile(_jvmModelInferrer, _client).writeTo(this.getProjectConfig().getRuntime().getSrc());
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference) AbstractRule(org.eclipse.xtext.AbstractRule)

Example 47 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class XbaseGeneratorFragment2 method contributeRuntimeGuiceBindings.

protected void contributeRuntimeGuiceBindings() {
    final GuiceModuleAccess.BindingFactory bindingFactory = new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider"));
    boolean _usesXImportSection = this._xbaseUsageDetector.usesXImportSection(this.getGrammar());
    boolean _not = (!_usesXImportSection);
    if (_not) {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("binder.bind(");
                _builder.append(Boolean.class);
                _builder.append(".TYPE)");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append(".annotatedWith(");
                _builder.append(Names.class, "\t");
                _builder.append(".named(");
                TypeReference _typeReference = new TypeReference("org.eclipse.xtext.xbase.imports", "RewritableImportSection.Factory");
                _builder.append(_typeReference, "\t");
                _builder.append(".REWRITABLEIMPORTSECTION_ENABLEMENT))");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append(".toInstance(");
                _builder.append(Boolean.class, "\t");
                _builder.append(".FALSE);");
                _builder.newLineIfNotEmpty();
            }
        };
        bindingFactory.addConfiguredBinding("RewritableImportSectionEnablement", _client);
    }
    if (this.useInferredJvmModel) {
        bindingFactory.addTypeToType(TypeReference.typeRef(ILocationInFileProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.JvmLocationInFileProvider")).addTypeToType(TypeReference.typeRef(IGlobalScopeProvider.class), TypeReference.typeRef("org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.validation.FeatureNameValidator"), TypeReference.typeRef("org.eclipse.xtext.xbase.validation.LogicalContainerAwareFeatureNameValidator")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.DefaultBatchTypeResolver"), TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareBatchTypeResolver")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.DefaultReentrantTypeResolver"), TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareReentrantTypeResolver")).addTypeToType(TypeReference.typeRef(IResourceValidator.class), TypeReference.typeRef("org.eclipse.xtext.xbase.annotations.validation.DerivedStateAwareResourceValidator"));
        if (this.generateXtendInferrer) {
            bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.IJvmModelInferrer"), this.getJvmModelInferrer());
        }
    } else {
        bindingFactory.addTypeToType(TypeReference.typeRef(ILocationInFileProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.resource.XbaseLocationInFileProvider"));
    }
    bindingFactory.contributeTo(this.getLanguage().getRuntimeGenModule());
    boolean _inheritsXbaseWithAnnotations = this._xbaseUsageDetector.inheritsXbaseWithAnnotations(this.getLanguage().getGrammar());
    if (_inheritsXbaseWithAnnotations) {
        GuiceModuleAccess _runtimeGenModule = this.getLanguage().getRuntimeGenModule();
        _runtimeGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.annotations.DefaultXbaseWithAnnotationsRuntimeModule"));
    } else {
        GuiceModuleAccess _runtimeGenModule_1 = this.getLanguage().getRuntimeGenModule();
        _runtimeGenModule_1.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.DefaultXbaseRuntimeModule"));
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) ILocationInFileProvider(org.eclipse.xtext.resource.ILocationInFileProvider) IQualifiedNameProvider(org.eclipse.xtext.naming.IQualifiedNameProvider) IGlobalScopeProvider(org.eclipse.xtext.scoping.IGlobalScopeProvider) IResourceValidator(org.eclipse.xtext.validation.IResourceValidator) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 48 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class ImplicitFragment method generate.

@Override
public void generate() {
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        this.getProjectConfig().getRuntime().getManifest().getRequiredBundles().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext", "org.eclipse.xtext.util")));
        boolean _isGenerateXtendStub = this.isGenerateXtendStub();
        if (_isGenerateXtendStub) {
            Set<String> _requiredBundles = this.getProjectConfig().getRuntime().getManifest().getRequiredBundles();
            String _xtendLibVersionLowerBound = this.getProjectConfig().getRuntime().getXtendLibVersionLowerBound();
            String _plus = ("org.eclipse.xtend.lib;bundle-version=\"" + _xtendLibVersionLowerBound);
            String _plus_1 = (_plus + "\"");
            _requiredBundles.add(_plus_1);
        }
        this.getProjectConfig().getRuntime().getManifest().getImportedPackages().add("org.apache.log4j");
    }
    ManifestAccess _manifest_1 = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals_1 = (_manifest_1 != null);
    if (_tripleNotEquals_1) {
        this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.ui", "org.eclipse.xtext.ui.shared", "org.eclipse.ui.editors", "org.eclipse.ui")));
        boolean _isGenerateXtendStub_1 = this.isGenerateXtendStub();
        if (_isGenerateXtendStub_1) {
            Set<String> _requiredBundles_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
            String _xtendLibVersionLowerBound_1 = this.getProjectConfig().getRuntime().getXtendLibVersionLowerBound();
            String _plus_2 = ("org.eclipse.xtend.lib;bundle-version=\"" + _xtendLibVersionLowerBound_1);
            String _plus_3 = (_plus_2 + "\"");
            _requiredBundles_1.add(_plus_3);
        }
        this.getProjectConfig().getEclipsePlugin().getManifest().getImportedPackages().add("org.apache.log4j");
    }
    PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
    boolean _tripleNotEquals_2 = (_pluginXml != null);
    if (_tripleNotEquals_2) {
        List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
        CharSequence _implicitPluginXmlEnties = this.getImplicitPluginXmlEnties(this.getGrammar());
        _entries.add(_implicitPluginXmlEnties);
    }
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.shared.Access");
            _builder.append(_typeRef);
            _builder.append(".getJavaProjectsState()");
        }
    };
    final StringConcatenationClient expression = _client;
    final GuiceModuleAccess.BindingFactory bindingFactory = new GuiceModuleAccess.BindingFactory().addTypeToProviderInstance(TypeReference.typeRef(IAllContainersState.class), expression);
    boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(this.getGrammar());
    if (_inheritsXbase) {
        bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.editor.XbaseDocumentProvider")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.generator.trace.XbaseOpenGeneratedFileHandler"));
    }
    bindingFactory.contributeTo(this.getLanguage().getEclipsePluginGenModule());
}
Also used : IAllContainersState(org.eclipse.xtext.resource.containers.IAllContainersState) GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 49 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class XtextGeneratorTemplates method createBindingMethod.

private StringConcatenationClient createBindingMethod(final GuiceModuleAccess.Binding it) {
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            {
                if (((!it.getValue().isProvider()) && it.getValue().getStatements().isEmpty())) {
                    _builder.append("// contributed by ");
                    String _contributedBy = it.getContributedBy();
                    _builder.append(_contributedBy);
                    _builder.newLineIfNotEmpty();
                    {
                        boolean _isSingleton = it.getKey().isSingleton();
                        if (_isSingleton) {
                            _builder.append("@");
                            _builder.append(SingletonBinding.class);
                            {
                                boolean _isEagerSingleton = it.getKey().isEagerSingleton();
                                if (_isEagerSingleton) {
                                    _builder.append("(eager=true)");
                                }
                            }
                        }
                    }
                    _builder.newLineIfNotEmpty();
                    _builder.append("public ");
                    {
                        Object _expression = it.getValue().getExpression();
                        boolean _tripleEquals = (_expression == null);
                        if (_tripleEquals) {
                            _builder.append("Class<? extends ");
                            TypeReference _type = it.getKey().getType();
                            _builder.append(_type);
                            _builder.append(">");
                        } else {
                            TypeReference _type_1 = it.getKey().getType();
                            _builder.append(_type_1);
                        }
                    }
                    _builder.append(" ");
                    CharSequence _bindMethodName = XtextGeneratorTemplates.this.getBindMethodName(it);
                    _builder.append(_bindMethodName);
                    _builder.append("() {");
                    _builder.newLineIfNotEmpty();
                    _builder.append("\t");
                    _builder.append("return ");
                    {
                        Object _expression_1 = it.getValue().getExpression();
                        boolean _tripleNotEquals = (_expression_1 != null);
                        if (_tripleNotEquals) {
                            Object _expression_2 = it.getValue().getExpression();
                            _builder.append(_expression_2, "\t");
                        } else {
                            TypeReference _type_2 = it.getValue().getType();
                            _builder.append(_type_2, "\t");
                            _builder.append(".class");
                        }
                    }
                    _builder.append(";");
                    _builder.newLineIfNotEmpty();
                    _builder.append("}");
                    _builder.newLine();
                } else {
                    boolean _isEmpty = it.getValue().getStatements().isEmpty();
                    if (_isEmpty) {
                        _builder.append("// contributed by ");
                        String _contributedBy_1 = it.getContributedBy();
                        _builder.append(_contributedBy_1);
                        _builder.newLineIfNotEmpty();
                        {
                            boolean _isSingleton_1 = it.getKey().isSingleton();
                            if (_isSingleton_1) {
                                _builder.append("@");
                                _builder.append(SingletonBinding.class);
                                {
                                    boolean _isEagerSingleton_1 = it.getKey().isEagerSingleton();
                                    if (_isEagerSingleton_1) {
                                        _builder.append("(eager=true)");
                                    }
                                }
                            }
                        }
                        _builder.newLineIfNotEmpty();
                        _builder.append("public ");
                        {
                            Object _expression_3 = it.getValue().getExpression();
                            boolean _tripleEquals_1 = (_expression_3 == null);
                            if (_tripleEquals_1) {
                                _builder.append("Class<? extends ");
                                _builder.append(Provider.class);
                                _builder.append("<? extends ");
                                TypeReference _type_3 = it.getKey().getType();
                                _builder.append(_type_3);
                                _builder.append(">>");
                            } else {
                                _builder.append(Provider.class);
                                _builder.append("<? extends ");
                                TypeReference _type_4 = it.getKey().getType();
                                _builder.append(_type_4);
                                _builder.append(">");
                            }
                        }
                        _builder.append(" ");
                        CharSequence _bindMethodName_1 = XtextGeneratorTemplates.this.getBindMethodName(it);
                        _builder.append(_bindMethodName_1);
                        _builder.append("() {");
                        _builder.newLineIfNotEmpty();
                        _builder.append("\t");
                        _builder.append("return ");
                        {
                            Object _expression_4 = it.getValue().getExpression();
                            boolean _tripleNotEquals_1 = (_expression_4 != null);
                            if (_tripleNotEquals_1) {
                                Object _expression_5 = it.getValue().getExpression();
                                _builder.append(_expression_5, "\t");
                            } else {
                                TypeReference _type_5 = it.getValue().getType();
                                _builder.append(_type_5, "\t");
                                _builder.append(".class");
                            }
                        }
                        _builder.append(";");
                        _builder.newLineIfNotEmpty();
                        _builder.append("}");
                        _builder.newLine();
                    } else {
                        _builder.append("// contributed by ");
                        String _contributedBy_2 = it.getContributedBy();
                        _builder.append(_contributedBy_2);
                        _builder.newLineIfNotEmpty();
                        _builder.append("public void ");
                        CharSequence _bindMethodName_2 = XtextGeneratorTemplates.this.getBindMethodName(it);
                        _builder.append(_bindMethodName_2);
                        _builder.append("(");
                        _builder.append(Binder.class);
                        _builder.append(" binder) {");
                        _builder.newLineIfNotEmpty();
                        {
                            List<Object> _statements = it.getValue().getStatements();
                            for (final Object statement : _statements) {
                                _builder.append("\t");
                                _builder.append(statement, "\t");
                                _builder.newLineIfNotEmpty();
                            }
                        }
                        _builder.append("}");
                        _builder.newLine();
                    }
                }
            }
        }
    };
    return _client;
}
Also used : Binder(com.google.inject.Binder) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 50 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-core by eclipse.

the class XtextGeneratorTemplates method createRuntimeSetup.

public JavaFileAccess createRuntimeSetup(final IXtextGeneratorLanguage langConfig) {
    final Grammar it = langConfig.getGrammar();
    boolean _isPreferXtendStubs = this.codeConfig.isPreferXtendStubs();
    if (_isPreferXtendStubs) {
        TypeReference _runtimeSetup = this.naming.getRuntimeSetup(it);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("/**");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Initialization support for running Xtext languages without Equinox extension registry.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*/");
                _builder.newLine();
                _builder.append("class ");
                String _simpleName = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _runtimeGenSetup = XtextGeneratorTemplates.this.naming.getRuntimeGenSetup(it);
                _builder.append(_runtimeGenSetup);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.newLine();
                _builder.append("\t");
                _builder.append("def static void doSetup() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("new ");
                String _simpleName_1 = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
                _builder.append(_simpleName_1, "\t\t");
                _builder.append("().createInjectorAndDoEMFRegistration()");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        return this.fileAccessFactory.createXtendFile(_runtimeSetup, _client);
    } else {
        TypeReference _runtimeSetup_1 = this.naming.getRuntimeSetup(it);
        StringConcatenationClient _client_1 = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("/**");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("* Initialization support for running Xtext languages without Equinox extension registry.");
                _builder.newLine();
                _builder.append(" ");
                _builder.append("*/");
                _builder.newLine();
                _builder.append("public class ");
                String _simpleName = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
                _builder.append(_simpleName);
                _builder.append(" extends ");
                TypeReference _runtimeGenSetup = XtextGeneratorTemplates.this.naming.getRuntimeGenSetup(it);
                _builder.append(_runtimeGenSetup);
                _builder.append(" {");
                _builder.newLineIfNotEmpty();
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public static void doSetup() {");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("new ");
                String _simpleName_1 = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
                _builder.append(_simpleName_1, "\t\t");
                _builder.append("().createInjectorAndDoEMFRegistration();");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("}");
                _builder.newLine();
            }
        };
        return this.fileAccessFactory.createJavaFile(_runtimeSetup_1, _client_1);
    }
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) Grammar(org.eclipse.xtext.Grammar) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Aggregations

StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)194 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)119 GeneratedJavaFileAccess (org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess)24 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)24 Grammar (org.eclipse.xtext.Grammar)23 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)19 List (java.util.List)18 Test (org.junit.Test)18 Set (java.util.Set)14 JavaFileAccess (org.eclipse.xtext.xtext.generator.model.JavaFileAccess)12 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)12 EClass (org.eclipse.emf.ecore.EClass)11 EList (org.eclipse.emf.common.util.EList)10 AbstractRule (org.eclipse.xtext.AbstractRule)10 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)10 EObject (org.eclipse.emf.ecore.EObject)9 IClassAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)8 SuppressWarningsAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.SuppressWarningsAnnotation)8 ArrayList (java.util.ArrayList)7