Search in sources :

Example 1 with GuiceModuleAccess

use of org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess in project xtext-core by eclipse.

the class XbaseGeneratorFragment2 method generate.

@Override
public void generate() {
    boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(this.getGrammar());
    boolean _not = (!_inheritsXbase);
    if (_not) {
        return;
    }
    boolean _equals = this._xtextGeneratorNaming.getEclipsePluginEditor(this.getGrammar()).equals(this._xtextGeneratorNaming.getEclipsePluginXbaseEditor(this.getGrammar()));
    boolean _not_1 = (!_equals);
    if (_not_1) {
        this.contributeEditorStub();
    }
    this.contributeRuntimeGuiceBindings();
    this.contributeEclipsePluginGuiceBindings();
    PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
    boolean _tripleNotEquals = (_pluginXml != null);
    if (_tripleNotEquals) {
        this.contributeEclipsePluginExtensions();
    }
    if (this.generateXtendInferrer) {
        this.doGenerateXtendInferrer();
    }
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals_1 = (_manifest != null);
    if (_tripleNotEquals_1) {
        String _xbaseLibVersionLowerBound = this.getProjectConfig().getRuntime().getXbaseLibVersionLowerBound();
        String _plus = ("org.eclipse.xtext.xbase.lib;bundle-version=\"" + _xbaseLibVersionLowerBound);
        String _plus_1 = (_plus + "\"");
        this.getProjectConfig().getRuntime().getManifest().getRequiredBundles().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.xbase", _plus_1)));
        if (((this.generateXtendInferrer || this.useInferredJvmModel) && (!this.skipExportedPackage))) {
            Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages();
            String _packageName = this.getJvmModelInferrer().getPackageName();
            _exportedPackages.add(_packageName);
        }
    }
    ManifestAccess _manifest_1 = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals_2 = (_manifest_1 != null);
    if (_tripleNotEquals_2) {
        this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.xbase.ui", "org.eclipse.jdt.debug.ui")));
    }
    GuiceModuleAccess _ideGenModule = this.getLanguage().getIdeGenModule();
    _ideGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.ide.DefaultXbaseIdeModule"));
    GuiceModuleAccess _webGenModule = this.getLanguage().getWebGenModule();
    _webGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.web.DefaultXbaseWebModule"));
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess)

Example 2 with GuiceModuleAccess

use of org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess 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 3 with GuiceModuleAccess

use of org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess in project xtext-core by eclipse.

the class TypesGeneratorFragment2 method generate.

@Override
public void generate() {
    if ((this.onlyEnabledIfGrammarIsUsed.get() && (!this.xbaseUsageDetector.inheritsXtype(this.getLanguage().getGrammar())))) {
        return;
    }
    new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IGlobalScopeProvider.class), TypeReference.typeRef("org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider")).contributeTo(this.getLanguage().getRuntimeGenModule());
    GuiceModuleAccess _runtimeGenModule = this.getLanguage().getRuntimeGenModule();
    _runtimeGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.common.types.DefaultCommonTypesRuntimeModule"));
    new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.PrefixMatcher"), TypeReference.typeRef("org.eclipse.xtext.ui.editor.contentassist.FQNPrefixMatcher")).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    GuiceModuleAccess _eclipsePluginGenModule = this.getLanguage().getEclipsePluginGenModule();
    _eclipsePluginGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.common.types.ui.DefaultCommonTypesUiModule"));
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        CollectionExtensions.<String>addAll(this.getProjectConfig().getRuntime().getManifest().getRequiredBundles(), "org.eclipse.xtext.common.types", "org.objectweb.asm;bundle-version=\"[5.0.1,6.0.0)\";resolution:=optional");
    }
    ManifestAccess _manifest_1 = this.getProjectConfig().getRuntimeTest().getManifest();
    boolean _tripleNotEquals_1 = (_manifest_1 != null);
    if (_tripleNotEquals_1) {
        this.getProjectConfig().getRuntimeTest().getManifest().getRequiredBundles().add("org.objectweb.asm;bundle-version=\"[5.0.1,6.0.0)\";resolution:=optional");
    }
    ManifestAccess _manifest_2 = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals_2 = (_manifest_2 != null);
    if (_tripleNotEquals_2) {
        this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles().add("org.eclipse.xtext.common.types.ui");
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess)

Example 4 with GuiceModuleAccess

use of org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess in project xtext-core by eclipse.

the class XbaseGeneratorFragment2 method contributeEclipsePluginGuiceBindings.

protected void contributeEclipsePluginGuiceBindings() {
    final GuiceModuleAccess.BindingFactory bindingFactory = new GuiceModuleAccess.BindingFactory();
    if (this.useInferredJvmModel) {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("if (");
                TypeReference _typeRef = TypeReference.typeRef("org.eclipse.ui.PlatformUI");
                _builder.append(_typeRef);
                _builder.append(".isWorkbenchRunning()) {");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("binder.bind(");
                TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.ui.editor.IURIEditorOpener");
                _builder.append(_typeRef_1, "\t");
                _builder.append(".class).annotatedWith(");
                TypeReference _typeRef_2 = TypeReference.typeRef("org.eclipse.xtext.ui.LanguageSpecific");
                _builder.append(_typeRef_2, "\t");
                _builder.append(".class).to(");
                TypeReference _typeRef_3 = TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.navigation.DerivedMemberAwareEditorOpener");
                _builder.append(_typeRef_3, "\t");
                _builder.append(".class);");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("binder.bind(");
                TypeReference _typeRef_4 = TypeReference.typeRef("org.eclipse.xtext.common.types.ui.navigation.IDerivedMemberAwareEditorOpener");
                _builder.append(_typeRef_4, "\t");
                _builder.append(".class).to(");
                TypeReference _typeRef_5 = TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.navigation.DerivedMemberAwareEditorOpener");
                _builder.append(_typeRef_5, "\t");
                _builder.append(".class);");
                _builder.newLineIfNotEmpty();
                _builder.append("}");
                _builder.newLine();
            }
        };
        final StringConcatenationClient statement = _client;
        GuiceModuleAccess.BindingFactory _addTypeToType = bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.findrefs.JvmModelFindReferenceHandler")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.findrefs.ReferenceQueryExecutor"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.findrefs.JvmModelReferenceQueryExecutor")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IDependentElementsCalculator"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.refactoring.JvmModelDependentElementsCalculator")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IRenameRefactoringProvider"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.refactoring.jdt.CombinedJvmJdtRenameRefactoringProvider")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IReferenceUpdater"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.refactoring.XbaseReferenceUpdater")).addfinalTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.ui.IRenameContextFactory"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.refactoring.jdt.CombinedJvmJdtRenameContextFactory")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IRenameStrategy"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.refactoring.DefaultJvmModelRenameStrategy"));
        TypeReference _typeReference = new TypeReference("org.eclipse.xtext.common.types.ui.refactoring.participant", "JdtRenameParticipant.ContextFactory");
        TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.xbase.ui.jvmmodel.refactoring", "JvmModelJdtRenameParticipantContext.ContextFactory");
        GuiceModuleAccess.BindingFactory _addTypeToType_1 = _addTypeToType.addTypeToType(_typeReference, _typeReference_1).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.outline.impl.OutlineNodeElementOpener"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.jvmmodel.outline.JvmOutlineNodeElementOpener")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.GlobalURIEditorOpener"), TypeReference.typeRef("org.eclipse.xtext.common.types.ui.navigation.GlobalDerivedMemberAwareURIEditorOpener"));
        TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.common.types.ui.query.IJavaSearchParticipation");
        TypeReference _typeReference_2 = new TypeReference("org.eclipse.xtext.common.types.ui.query", "IJavaSearchParticipation.No");
        _addTypeToType_1.addTypeToType(_typeRef, _typeReference_2).addConfiguredBinding("LanguageSpecificURIEditorOpener", statement);
    } else {
        bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.refactoring.IRenameStrategy"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.refactoring.XbaseRenameStrategy"));
    }
    boolean _usesXImportSection = this._xbaseUsageDetector.usesXImportSection(this.getLanguage().getGrammar());
    if (_usesXImportSection) {
        bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.imports.IUnresolvedTypeResolver"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.imports.InteractiveUnresolvedTypeResolver")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.contentassist.ImportingTypesProposalProvider")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.templates.XtextTemplateContextType"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.templates.XbaseTemplateContextType"));
    } else {
        bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.ui.quickfix.JavaTypeQuickfixes"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.quickfix.JavaTypeQuickfixesNoImportSection"));
    }
    bindingFactory.addTypeToType(this._xtextGeneratorNaming.getEclipsePluginDefaultEditor(this.getGrammar()), this._xtextGeneratorNaming.getEclipsePluginEditor(this.getGrammar()));
    bindingFactory.contributeTo(this.getLanguage().getEclipsePluginGenModule());
    boolean _inheritsXbaseWithAnnotations = this._xbaseUsageDetector.inheritsXbaseWithAnnotations(this.getLanguage().getGrammar());
    if (_inheritsXbaseWithAnnotations) {
        GuiceModuleAccess _eclipsePluginGenModule = this.getLanguage().getEclipsePluginGenModule();
        _eclipsePluginGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.annotations.ui.DefaultXbaseWithAnnotationsUiModule"));
    } else {
        GuiceModuleAccess _eclipsePluginGenModule_1 = this.getLanguage().getEclipsePluginGenModule();
        _eclipsePluginGenModule_1.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.ui.DefaultXbaseUiModule"));
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Aggregations

GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)4 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)2 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)2 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)2 IQualifiedNameProvider (org.eclipse.xtext.naming.IQualifiedNameProvider)1 ILocationInFileProvider (org.eclipse.xtext.resource.ILocationInFileProvider)1 IGlobalScopeProvider (org.eclipse.xtext.scoping.IGlobalScopeProvider)1 IResourceValidator (org.eclipse.xtext.validation.IResourceValidator)1 PluginXmlAccess (org.eclipse.xtext.xtext.generator.model.PluginXmlAccess)1