Search in sources :

Example 6 with ManifestAccess

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

the class CodetemplatesGeneratorFragment2 method generate.

@Override
public void generate() {
    IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
    ManifestAccess _manifest = null;
    if (_eclipsePlugin != null) {
        _manifest = _eclipsePlugin.getManifest();
    }
    Set<String> _requiredBundles = null;
    if (_manifest != null) {
        _requiredBundles = _manifest.getRequiredBundles();
    }
    if (_requiredBundles != null) {
        _requiredBundles.addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.ui", "org.eclipse.xtext.ui.codetemplates.ui")));
    }
    GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
    TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.preferences.TemplatesLanguageConfiguration");
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.AccessibleCodetemplatesActivator");
            _builder.append(_typeRef);
            _builder.append(".getTemplatesLanguageConfigurationProvider()");
        }
    };
    GuiceModuleAccess.BindingFactory _addTypeToProviderInstance = _bindingFactory.addTypeToProviderInstance(_typeRef, _client);
    TypeReference _typeRef_1 = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistry");
    StringConcatenationClient _client_1 = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.AccessibleCodetemplatesActivator");
            _builder.append(_typeRef);
            _builder.append(".getLanguageRegistry()");
        }
    };
    _addTypeToProviderInstance.addTypeToProviderInstance(_typeRef_1, _client_1).addTypeToTypeEagerSingleton(TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistrar"), TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.registry.LanguageRegistrar")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"), TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.preferences.AdvancedTemplatesPreferencePage")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ide.editor.partialEditing.IPartialEditingContentAssistParser"), this.getPartialContentAssistParserClass(this.getGrammar())).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.partialEditing.IPartialEditingContentAssistContextFactory"), TypeReference.typeRef("org.eclipse.xtext.ui.codetemplates.ui.partialEditing.PartialEditingContentAssistContextFactory")).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    IBundleProjectConfig _genericIde = this.getProjectConfig().getGenericIde();
    IXtextGeneratorFileSystemAccess _srcGen = null;
    if (_genericIde != null) {
        _srcGen = _genericIde.getSrcGen();
    }
    boolean _tripleNotEquals = (_srcGen != null);
    if (_tripleNotEquals) {
        GeneratedJavaFileAccess _createGeneratedJavaFile = this.fileAccessFactory.createGeneratedJavaFile(this.getPartialContentAssistParserClass(this.getGrammar()));
        final Procedure1<GeneratedJavaFileAccess> _function = (GeneratedJavaFileAccess it) -> {
            it.setContent(this.getGenPartialContentAssistParser());
            it.writeTo(this.getProjectConfig().getGenericIde().getSrcGen());
        };
        ObjectExtensions.<GeneratedJavaFileAccess>operator_doubleArrow(_createGeneratedJavaFile, _function);
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) IBundleProjectConfig(org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess) GeneratedJavaFileAccess(org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 7 with ManifestAccess

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

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

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

the class Formatter2Fragment2 method generate.

@Override
public void generate() {
    boolean _isGenerateStub = this.isGenerateStub();
    boolean _not = (!_isGenerateStub);
    if (_not) {
        return;
    }
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("binder.bind(");
            _builder.append(IPreferenceValuesProvider.class);
            _builder.append(".class).annotatedWith(");
            _builder.append(FormatterPreferences.class);
            _builder.append(".class).to(");
            _builder.append(FormatterPreferenceValuesProvider.class);
            _builder.append(".class);");
        }
    };
    final StringConcatenationClient statement = _client;
    new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IFormatter2.class), this.getFormatter2Stub(this.getLanguage().getGrammar())).addConfiguredBinding(FormatterPreferences.class.getSimpleName(), statement).contributeTo(this.getLanguage().getRuntimeGenModule());
    new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.formatting.IContentFormatterFactory"), TypeReference.typeRef("org.eclipse.xtext.ui.editor.formatting2.ContentFormatterFactory")).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages();
        String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(this.getGrammar());
        String _plus = (_runtimeBasePackage + ".formatting2");
        _exportedPackages.add(_plus);
    }
    this.doGenerateStubFile();
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) IFormatter2(org.eclipse.xtext.formatting2.IFormatter2) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 10 with ManifestAccess

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

the class GrammarAccessFragment2 method generate.

@Override
public void generate() {
    final GuiceModuleAccess.BindingFactory bindingFactory = new GuiceModuleAccess.BindingFactory();
    String _name = this.getLanguage().getGrammar().getName();
    boolean _notEquals = (!Objects.equal(_name, "org.eclipse.xtext.common.Terminals"));
    if (_notEquals) {
        TypeReference _typeRef = TypeReference.typeRef(ClassLoader.class);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("getClass().getClassLoader()");
            }
        };
        bindingFactory.addTypeToInstance(_typeRef, _client);
    }
    bindingFactory.addTypeToType(TypeReference.typeRef(IGrammarAccess.class), this._grammarAccessExtensions.getGrammarAccess(this.getLanguage().getGrammar())).contributeTo(this.getLanguage().getRuntimeGenModule());
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(this.getGrammar());
        String _runtimeBasePackage_1 = this._xtextGeneratorNaming.getRuntimeBasePackage(this.getGrammar());
        String _plus = (_runtimeBasePackage_1 + ".services");
        this.getProjectConfig().getRuntime().getManifest().getExportedPackages().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(_runtimeBasePackage, _plus)));
    }
    this.doGenerateGrammarAccess();
    this.writeGrammar();
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Aggregations

ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)27 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)18 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)17 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)12 PluginXmlAccess (org.eclipse.xtext.xtext.generator.model.PluginXmlAccess)12 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)7 IBundleProjectConfig (org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig)6 IXtextGeneratorFileSystemAccess (org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess)5 Set (java.util.Set)3 Extension (org.eclipse.xtext.xbase.lib.Extension)3 ContentAssistGrammarNaming (org.eclipse.xtext.xtext.generator.parser.antlr.ContentAssistGrammarNaming)3 Names (com.google.inject.name.Names)1 List (java.util.List)1 GenPackage (org.eclipse.emf.codegen.ecore.genmodel.GenPackage)1 EPackage (org.eclipse.emf.ecore.EPackage)1 AbstractIDValueConverter (org.eclipse.xtext.conversion.impl.AbstractIDValueConverter)1 IgnoreCaseIDValueConverter (org.eclipse.xtext.conversion.impl.IgnoreCaseIDValueConverter)1 IFormatter2 (org.eclipse.xtext.formatting2.IFormatter2)1 IParser (org.eclipse.xtext.parser.IParser)1 AntlrTokenDefProvider (org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider)1