Search in sources :

Example 6 with PluginXmlAccess

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

the class ResourceFactoryFragment2 method generate.

@Override
public void generate() {
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append(IResourceFactory.class);
            _builder.append(" resourceFactory = injector.getInstance(");
            _builder.append(IResourceFactory.class);
            _builder.append(".class);");
            _builder.newLineIfNotEmpty();
            _builder.append(IResourceServiceProvider.class);
            _builder.append(" serviceProvider = injector.getInstance(");
            _builder.append(IResourceServiceProvider.class);
            _builder.append(".class);");
            _builder.newLineIfNotEmpty();
            _builder.newLine();
            {
                List<String> _fileExtensions = ResourceFactoryFragment2.this.getLanguage().getFileExtensions();
                for (final String fileExtension : _fileExtensions) {
                    _builder.append(Resource.class);
                    _builder.append(".Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(\"");
                    _builder.append(fileExtension);
                    _builder.append("\", resourceFactory);");
                    _builder.newLineIfNotEmpty();
                    _builder.append(IResourceServiceProvider.class);
                    _builder.append(".Registry.INSTANCE.getExtensionToFactoryMap().put(\"");
                    _builder.append(fileExtension);
                    _builder.append("\", serviceProvider);");
                    _builder.newLineIfNotEmpty();
                }
            }
        }
    };
    this.getLanguage().getRuntimeGenSetup().getRegistrations().add(_client);
    IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
    PluginXmlAccess _pluginXml = null;
    if (_eclipsePlugin != null) {
        _pluginXml = _eclipsePlugin.getPluginXml();
    }
    boolean _tripleNotEquals = (_pluginXml != null);
    if (_tripleNotEquals) {
        List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("<!-- adding resource factories -->");
        _builder.newLine();
        {
            List<String> _fileExtensions = this.getLanguage().getFileExtensions();
            for (final String fileExtension : _fileExtensions) {
                _builder.append("<extension");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("point=\"org.eclipse.emf.ecore.extension_parser\">");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("<parser");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("class=\"");
                TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
                _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
                _builder.append(":org.eclipse.xtext.resource.IResourceFactory\"");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("type=\"");
                _builder.append(fileExtension, "\t\t");
                _builder.append("\">");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("</parser>");
                _builder.newLine();
                _builder.append("</extension>");
                _builder.newLine();
                _builder.append("<extension point=\"org.eclipse.xtext.extension_resourceServiceProvider\">");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("<resourceServiceProvider");
                _builder.newLine();
                _builder.append("\t\t");
                _builder.append("class=\"");
                TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
                _builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t\t");
                _builder.append(":org.eclipse.xtext.ui.resource.IResourceUIServiceProvider\"");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("uriExtension=\"");
                _builder.append(fileExtension, "\t\t");
                _builder.append("\">");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("</resourceServiceProvider>");
                _builder.newLine();
                _builder.append("</extension>");
                _builder.newLine();
            }
        }
        _entries.add(_builder.toString());
    }
}
Also used : IBundleProjectConfig(org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) Resource(org.eclipse.emf.ecore.resource.Resource) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) List(java.util.List) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 7 with PluginXmlAccess

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

the class QuickOutlineFragment2 method generate.

@Override
public void generate() {
    ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
        _requiredBundles.add("org.eclipse.xtext.ui");
    }
    PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
    boolean _tripleNotEquals_1 = (_pluginXml != null);
    if (_tripleNotEquals_1) {
        List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("<!-- Quick Outline -->");
        _builder.newLine();
        _builder.append("<extension");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("point=\"org.eclipse.ui.handlers\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<handler ");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("class=\"");
        TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
        _builder.append(_eclipsePluginExecutableExtensionFactory, "\t\t");
        _builder.append(":org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("commandId=\"org.eclipse.xtext.ui.editor.outline.QuickOutline\">");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("<activeWhen>");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("<reference");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("definitionId=\"");
        String _name = this.getGrammar().getName();
        _builder.append(_name, "\t\t\t\t");
        _builder.append(".Editor.opened\">");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t\t");
        _builder.append("</reference>");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("</activeWhen>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("</handler>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("point=\"org.eclipse.ui.commands\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<command");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("description=\"Open the quick outline.\"");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("id=\"org.eclipse.xtext.ui.editor.outline.QuickOutline\"");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("name=\"Quick Outline\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("</command>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension point=\"org.eclipse.ui.menus\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<menuContribution");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("locationURI=\"popup:#TextEditorContext?after=group.open\">");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("<command commandId=\"org.eclipse.xtext.ui.editor.outline.QuickOutline\"");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("style=\"push\"");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("tooltip=\"Open Quick Outline\">");
        _builder.newLine();
        _builder.append("\t\t\t");
        _builder.append("<visibleWhen checkEnabled=\"false\">");
        _builder.newLine();
        _builder.append("\t\t\t\t");
        _builder.append("<reference definitionId=\"");
        String _name_1 = this.getGrammar().getName();
        _builder.append(_name_1, "\t\t\t\t");
        _builder.append(".Editor.opened\"/>");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t\t");
        _builder.append("</visibleWhen>");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("</command>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("</menuContribution>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _entries.add(_builder.toString());
    }
}
Also used : ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 8 with PluginXmlAccess

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

the class QuickfixProviderFragment2 method generate.

@Override
public void generate() {
    GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
    TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.editor.quickfix.IssueResolutionProvider");
    _bindingFactory.addTypeToType(_typeReference, this.getQuickfixProviderClass(this.getGrammar())).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    boolean _isGenerateStub = this.isGenerateStub();
    if (_isGenerateStub) {
        IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
        IXtextGeneratorFileSystemAccess _src = null;
        if (_eclipsePlugin != null) {
            _src = _eclipsePlugin.getSrc();
        }
        boolean _tripleNotEquals = (_src != null);
        if (_tripleNotEquals) {
            boolean _isGenerateXtendStub = this.isGenerateXtendStub();
            if (_isGenerateXtendStub) {
                this.generateXtendQuickfixProvider();
            } else {
                this.generateJavaQuickfixProvider();
            }
        }
        ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest();
        boolean _tripleNotEquals_1 = (_manifest != null);
        if (_tripleNotEquals_1) {
            Set<String> _exportedPackages = this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages();
            String _packageName = this.getQuickfixProviderClass(this.getGrammar()).getPackageName();
            _exportedPackages.add(_packageName);
        }
        PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
        boolean _tripleNotEquals_2 = (_pluginXml != null);
        if (_tripleNotEquals_2) {
            this.addRegistrationToPluginXml();
        }
    } else {
        IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
        IXtextGeneratorFileSystemAccess _srcGen = null;
        if (_eclipsePlugin_1 != null) {
            _srcGen = _eclipsePlugin_1.getSrcGen();
        }
        boolean _tripleNotEquals_3 = (_srcGen != null);
        if (_tripleNotEquals_3) {
            this.generateGenQuickfixProvider();
        }
        ManifestAccess _manifest_1 = this.getProjectConfig().getEclipsePlugin().getManifest();
        boolean _tripleNotEquals_4 = (_manifest_1 != null);
        if (_tripleNotEquals_4) {
            Set<String> _exportedPackages_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages();
            String _packageName_1 = this.getQuickfixProviderClass(this.getGrammar()).getPackageName();
            _exportedPackages_1.add(_packageName_1);
        }
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) IBundleProjectConfig(org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 9 with PluginXmlAccess

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

the class TaskTagPreferencePageFragment2 method generate.

@Override
public void generate() {
    final GuiceModuleAccess.BindingFactory rtBindings = new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef("org.eclipse.xtext.tasks.ITaskTagProvider"), TypeReference.typeRef("org.eclipse.xtext.tasks.PreferenceTaskTagProvider"));
    rtBindings.contributeTo(this.getLanguage().getRuntimeGenModule());
    GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("binder.bind(org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreInitializer.class)");
            _builder.newLine();
            _builder.append(".annotatedWith(com.google.inject.name.Names.named(\"taskTagPreferenceInitializer\"))");
            _builder.newLine();
            _builder.append(".to(org.eclipse.xtext.ui.tasks.preferences.TaskTagPreferenceInitializer.class);");
            _builder.newLine();
        }
    };
    final GuiceModuleAccess.BindingFactory eclipseBindings = _bindingFactory.addConfiguredBinding("TaskTagPreferenceStoreInitializer", _client);
    eclipseBindings.contributeTo(this.getLanguage().getEclipsePluginGenModule());
    IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
    PluginXmlAccess _pluginXml = null;
    if (_eclipsePlugin != null) {
        _pluginXml = _eclipsePlugin.getPluginXml();
    }
    boolean _tripleNotEquals = (_pluginXml != null);
    if (_tripleNotEquals) {
        List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("<!-- task preference page for ");
        String _name = this.grammar.getName();
        _builder.append(_name);
        _builder.append(" -->");
        _builder.newLineIfNotEmpty();
        _builder.append("<extension");
        _builder.newLine();
        _builder.append("point=\"org.eclipse.ui.preferencePages\">");
        _builder.newLine();
        _builder.append("<page");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("category=\"");
        String _name_1 = this.grammar.getName();
        _builder.append(_name_1, "\t");
        _builder.append("\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("class=\"");
        TypeReference _eclipsePluginExecutableExtensionFactory = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.grammar);
        _builder.append(_eclipsePluginExecutableExtensionFactory, "\t");
        _builder.append(":org.eclipse.xtext.ui.tasks.preferences.TaskTagPreferencePage\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("id=\"");
        String _name_2 = this.grammar.getName();
        _builder.append(_name_2, "\t");
        _builder.append(".task.preferencePage\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("name=\"Task Tags\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<keywordReference id=\"");
        String _runtimeBasePackage = this._xtextGeneratorNaming.getRuntimeBasePackage(this.grammar);
        String _plus = (_runtimeBasePackage + ".ui.keyword_");
        String _simpleName = GrammarUtil.getSimpleName(this.grammar);
        String _plus_1 = (_plus + _simpleName);
        _builder.append(_plus_1, "\t");
        _builder.append("\"/>");
        _builder.newLineIfNotEmpty();
        _builder.append("</page>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension");
        _builder.newLine();
        _builder.append("point=\"org.eclipse.ui.propertyPages\">");
        _builder.newLine();
        _builder.append("<page");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("category=\"");
        String _name_3 = this.grammar.getName();
        _builder.append(_name_3, "\t");
        _builder.append("\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("class=\"");
        TypeReference _eclipsePluginExecutableExtensionFactory_1 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.grammar);
        _builder.append(_eclipsePluginExecutableExtensionFactory_1, "\t");
        _builder.append(":org.eclipse.xtext.ui.tasks.preferences.TaskTagPreferencePage\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("id=\"");
        String _name_4 = this.grammar.getName();
        _builder.append(_name_4, "\t");
        _builder.append(".task.propertyPage\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("name=\"Task Tags\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<keywordReference id=\"");
        String _runtimeBasePackage_1 = this._xtextGeneratorNaming.getRuntimeBasePackage(this.grammar);
        String _plus_2 = (_runtimeBasePackage_1 + ".ui.keyword_");
        String _simpleName_1 = GrammarUtil.getSimpleName(this.grammar);
        String _plus_3 = (_plus_2 + _simpleName_1);
        _builder.append(_plus_3, "\t");
        _builder.append("\"/>");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("<enabledWhen>");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("<adapt type=\"org.eclipse.core.resources.IProject\"/>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("</enabledWhen>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<filter name=\"projectNature\" value=\"org.eclipse.xtext.ui.shared.xtextNature\"/>");
        _builder.newLine();
        _builder.append("</page>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _entries.add(_builder.toString());
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) IBundleProjectConfig(org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 10 with PluginXmlAccess

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

the class ValidatorFragment2 method generate.

@Override
public void generate() {
    new GuiceModuleAccess.BindingFactory().addTypeToTypeEagerSingleton(this._validatorNaming.getValidatorClass(this.getGrammar()), this._validatorNaming.getValidatorClass(this.getGrammar())).contributeTo(this.getLanguage().getRuntimeGenModule());
    boolean _isGenerateStub = this.isGenerateStub();
    if (_isGenerateStub) {
        boolean _isGenerateXtendStub = this.isGenerateXtendStub();
        if (_isGenerateXtendStub) {
            this.generateXtendValidatorStub();
        } else {
            this.generateJavaValidatorStub();
        }
    }
    this.generateGenValidator().writeTo(this.getProjectConfig().getRuntime().getSrcGen());
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages();
        String _packageName = this._validatorNaming.getValidatorClass(this.getGrammar()).getPackageName();
        _exportedPackages.add(_packageName);
    }
    PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
    boolean _tripleNotEquals_1 = (_pluginXml != null);
    if (_tripleNotEquals_1) {
        this.contributeEclipsePluginExtensions();
    }
}
Also used : ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) PluginXmlAccess(org.eclipse.xtext.xtext.generator.model.PluginXmlAccess)

Aggregations

PluginXmlAccess (org.eclipse.xtext.xtext.generator.model.PluginXmlAccess)14 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)12 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)11 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)9 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)9 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)7 IBundleProjectConfig (org.eclipse.xtext.xtext.generator.model.project.IBundleProjectConfig)7 List (java.util.List)2 Names (com.google.inject.name.Names)1 GenPackage (org.eclipse.emf.codegen.ecore.genmodel.GenPackage)1 EPackage (org.eclipse.emf.ecore.EPackage)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)1 IAllContainersState (org.eclipse.xtext.resource.containers.IAllContainersState)1 IXtextGeneratorFileSystemAccess (org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess)1