Search in sources :

Example 26 with ManifestAccess

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

the class CompareFragment2 method generate.

@Override
public void generate() {
    IBundleProjectConfig _eclipsePlugin = this.getProjectConfig().getEclipsePlugin();
    ManifestAccess _manifest = null;
    if (_eclipsePlugin != null) {
        _manifest = _eclipsePlugin.getManifest();
    }
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        Set<String> _requiredBundles = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
        Iterables.<String>addAll(_requiredBundles, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.compare", "org.eclipse.xtext.ui")));
    }
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("binder.bind(");
            _builder.append(String.class);
            _builder.append(".class).annotatedWith(");
            _builder.append(Names.class);
            _builder.append(".named(");
            TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.UIBindings");
            _builder.append(_typeReference);
            _builder.append(".COMPARE_VIEWER_TITLE)).toInstance(\"");
            String _simpleName = GrammarUtil.getSimpleName(CompareFragment2.this.getGrammar());
            _builder.append(_simpleName);
            _builder.append(" Compare\");");
        }
    };
    final StringConcatenationClient statement = _client;
    GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
    TypeReference _typeReference = new TypeReference("org.eclipse.compare.IViewerCreator");
    TypeReference _typeReference_1 = new TypeReference("org.eclipse.xtext.ui.compare.DefaultViewerCreator");
    _bindingFactory.addTypeToType(_typeReference, _typeReference_1).addConfiguredBinding("CompareViewerTitle", statement).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    IBundleProjectConfig _eclipsePlugin_1 = this.getProjectConfig().getEclipsePlugin();
    PluginXmlAccess _pluginXml = null;
    if (_eclipsePlugin_1 != null) {
        _pluginXml = _eclipsePlugin_1.getPluginXml();
    }
    boolean _tripleNotEquals_1 = (_pluginXml != null);
    if (_tripleNotEquals_1) {
        List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("<extension point=\"org.eclipse.compare.contentViewers\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<viewer id=\"");
        String _name = this.getGrammar().getName();
        _builder.append(_name, "\t");
        _builder.append(".compare.contentViewers\"");
        _builder.newLineIfNotEmpty();
        _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.compare.InjectableViewerCreator\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("extensions=\"");
        String _join = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
        _builder.append(_join, "\t\t");
        _builder.append("\">");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("</viewer>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<contentTypeBinding");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("contentTypeId=\"");
        String _name_1 = this.getGrammar().getName();
        _builder.append(_name_1, "\t\t");
        _builder.append(".contenttype\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("contentViewerId=\"");
        String _name_2 = this.getGrammar().getName();
        _builder.append(_name_2, "\t\t");
        _builder.append(".compare.contentViewers\" />");
        _builder.newLineIfNotEmpty();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension point=\"org.eclipse.compare.contentMergeViewers\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<viewer id=\"");
        String _name_3 = this.getGrammar().getName();
        _builder.append(_name_3, "\t");
        _builder.append(".compare.contentMergeViewers\"");
        _builder.newLineIfNotEmpty();
        _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.compare.InjectableViewerCreator\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("extensions=\"");
        String _join_1 = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
        _builder.append(_join_1, "\t\t");
        _builder.append("\" label=\"");
        String _simpleName = GrammarUtil.getSimpleName(this.getGrammar());
        _builder.append(_simpleName, "\t\t");
        _builder.append(" Compare\">");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("</viewer>");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<contentTypeBinding");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("contentTypeId=\"");
        String _name_4 = this.getGrammar().getName();
        _builder.append(_name_4, "\t\t");
        _builder.append(".contenttype\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("contentMergeViewerId=\"");
        String _name_5 = this.getGrammar().getName();
        _builder.append(_name_5, "\t\t");
        _builder.append(".compare.contentMergeViewers\" />");
        _builder.newLineIfNotEmpty();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension point=\"org.eclipse.ui.editors.documentProviders\">");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("<provider id=\"");
        String _name_6 = this.getGrammar().getName();
        _builder.append(_name_6, "\t");
        _builder.append(".editors.documentProviders\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("class=\"");
        TypeReference _eclipsePluginExecutableExtensionFactory_2 = this._xtextGeneratorNaming.getEclipsePluginExecutableExtensionFactory(this.getGrammar());
        _builder.append(_eclipsePluginExecutableExtensionFactory_2, "\t\t");
        _builder.append(":org.eclipse.xtext.ui.editor.model.XtextDocumentProvider\"");
        _builder.newLineIfNotEmpty();
        _builder.append("\t\t");
        _builder.append("extensions=\"");
        String _join_2 = IterableExtensions.join(this.getLanguage().getFileExtensions(), ",");
        _builder.append(_join_2, "\t\t");
        _builder.append("\">");
        _builder.newLineIfNotEmpty();
        _builder.append("\t");
        _builder.append("</provider>");
        _builder.newLine();
        _builder.append("</extension>");
        _builder.newLine();
        _builder.append("<extension point=\"org.eclipse.team.core.fileTypes\">");
        _builder.newLine();
        {
            List<String> _fileExtensions = this.getLanguage().getFileExtensions();
            for (final String modelFileExtension : _fileExtensions) {
                _builder.append("\t");
                _builder.append("<fileTypes");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("\t");
                _builder.append("extension=\"");
                _builder.append(modelFileExtension, "\t\t");
                _builder.append("\"");
                _builder.newLineIfNotEmpty();
                _builder.append("\t");
                _builder.append("\t");
                _builder.append("type=\"text\">");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("</fileTypes>");
                _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) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) List(java.util.List) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference)

Example 27 with ManifestAccess

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

the class ContentAssistFragment2 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");
    }
    GuiceModuleAccess.BindingFactory _bindingFactory = new GuiceModuleAccess.BindingFactory();
    TypeReference _typeReference = new TypeReference("org.eclipse.xtext.ui.editor.contentassist.IContentProposalProvider");
    _bindingFactory.addTypeToType(_typeReference, this.getProposalProviderClass(this.getGrammar())).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    IXtextGeneratorFileSystemAccess _srcGen = this.getProjectConfig().getEclipsePlugin().getSrcGen();
    boolean _tripleNotEquals_1 = (_srcGen != null);
    if (_tripleNotEquals_1) {
        this.generateGenJavaProposalProvider();
    }
    if ((this.isGenerateStub() && (this.getProjectConfig().getEclipsePlugin().getSrc() != null))) {
        boolean _isGenerateXtendStub = this.isGenerateXtendStub();
        if (_isGenerateXtendStub) {
            this.generateXtendProposalProviderStub();
            ManifestAccess _manifest_1 = this.getProjectConfig().getEclipsePlugin().getManifest();
            boolean _tripleNotEquals_2 = (_manifest_1 != null);
            if (_tripleNotEquals_2) {
                Set<String> _requiredBundles_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
                String _xbaseLibVersionLowerBound = this.getProjectConfig().getRuntime().getXbaseLibVersionLowerBound();
                String _plus = ("org.eclipse.xtext.xbase.lib;bundle-version=\"" + _xbaseLibVersionLowerBound);
                String _plus_1 = (_plus + "\"");
                _requiredBundles_1.add(_plus_1);
                Set<String> _requiredBundles_2 = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
                _requiredBundles_2.add("org.eclipse.xtend.lib;resolution:=optional");
            }
        } else {
            this.generateJavaProposalProviderStub();
        }
    }
    ManifestAccess _manifest_2 = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals_3 = (_manifest_2 != null);
    if (_tripleNotEquals_3) {
        Set<String> _exportedPackages = this.getProjectConfig().getEclipsePlugin().getManifest().getExportedPackages();
        String _packageName = this.getProposalProviderClass(this.getGrammar()).getPackageName();
        _exportedPackages.add(_packageName);
    }
}
Also used : GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) IXtextGeneratorFileSystemAccess(org.eclipse.xtext.xtext.generator.model.IXtextGeneratorFileSystemAccess) 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