Search in sources :

Example 11 with ManifestAccess

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

the class XtextAntlrGeneratorFragment2 method addRuntimeBindingsAndImports.

protected void addRuntimeBindingsAndImports() {
    @Extension final GrammarNaming naming = this.productionNaming;
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        ManifestAccess _manifest_1 = this.getProjectConfig().getRuntime().getManifest();
        final Procedure1<ManifestAccess> _function = (ManifestAccess it) -> {
            Set<String> _exportedPackages = it.getExportedPackages();
            String _packageName = naming.getLexerClass(this.getGrammar()).getPackageName();
            String _packageName_1 = naming.getParserClass(this.getGrammar()).getPackageName();
            String _packageName_2 = naming.getInternalParserClass(this.getGrammar()).getPackageName();
            Iterables.<String>addAll(_exportedPackages, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(_packageName, _packageName_1, _packageName_2)));
            Set<String> _requiredBundles = it.getRequiredBundles();
            _requiredBundles.add("org.antlr.runtime");
        };
        ObjectExtensions.<ManifestAccess>operator_doubleArrow(_manifest_1, _function);
    }
    GuiceModuleAccess.BindingFactory _addTypeToType = new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IParser.class), naming.getParserClass(this.getGrammar())).addTypeToType(TypeReference.typeRef(ITokenToStringConverter.class), TypeReference.typeRef(AntlrTokenToStringConverter.class)).addTypeToType(TypeReference.typeRef(IAntlrTokenFileProvider.class), naming.getAntlrTokenFileProviderClass(this.getGrammar())).addTypeToType(naming.getLexerSuperClass(this.getGrammar()), naming.getLexerClass(this.getGrammar())).addTypeToType(TypeReference.typeRef(ITokenDefProvider.class), TypeReference.typeRef(AntlrTokenDefProvider.class));
    TypeReference _lexerClass = naming.getLexerClass(this.getGrammar());
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append(LexerProvider.class);
            _builder.append(".create(");
            TypeReference _lexerClass = naming.getLexerClass(XtextAntlrGeneratorFragment2.this.getGrammar());
            _builder.append(_lexerClass);
            _builder.append(".class)");
        }
    };
    GuiceModuleAccess.BindingFactory _addTypeToProviderInstance = _addTypeToType.addTypeToProviderInstance(_lexerClass, _client);
    StringConcatenationClient _client_1 = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("binder.bind(");
            _builder.append(Lexer.class);
            _builder.append(".class)");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append(".annotatedWith(");
            _builder.append(Names.class, "\t");
            _builder.append(".named(");
            _builder.append(LexerBindings.class, "\t");
            _builder.append(".RUNTIME))");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append(".to(");
            TypeReference _lexerClass = naming.getLexerClass(XtextAntlrGeneratorFragment2.this.getGrammar());
            _builder.append(_lexerClass, "\t");
            _builder.append(".class);");
            _builder.newLineIfNotEmpty();
        }
    };
    final GuiceModuleAccess.BindingFactory rtBindings = _addTypeToProviderInstance.addConfiguredBinding("RuntimeLexer", _client_1);
    boolean _containsUnorderedGroup = this.containsUnorderedGroup(this.getGrammar());
    if (_containsUnorderedGroup) {
        rtBindings.addTypeToType(TypeReference.typeRef(IUnorderedGroupHelper.class), TypeReference.typeRef(UnorderedGroupHelper.class));
    }
    boolean _isIgnoreCase = this.getOptions().isIgnoreCase();
    if (_isIgnoreCase) {
        rtBindings.addTypeToType(TypeReference.typeRef(ITokenSerializer.IKeywordSerializer.class), TypeReference.typeRef(IgnoreCaseKeywordSerializer.class)).addTypeToType(TypeReference.typeRef(IKeywordSerializer.class), TypeReference.typeRef(org.eclipse.xtext.serializer.tokens.IgnoreCaseKeywordSerializer.class)).addTypeToType(TypeReference.typeRef(AbstractIDValueConverter.class), TypeReference.typeRef(IgnoreCaseIDValueConverter.class));
    }
    rtBindings.contributeTo(this.getLanguage().getRuntimeGenModule());
}
Also used : Set(java.util.Set) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) IUnorderedGroupHelper(org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper) ContentAssistGrammarNaming(org.eclipse.xtext.xtext.generator.parser.antlr.ContentAssistGrammarNaming) GrammarNaming(org.eclipse.xtext.xtext.generator.parser.antlr.GrammarNaming) ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess) UnorderedGroupHelper(org.eclipse.xtext.parser.antlr.UnorderedGroupHelper) IUnorderedGroupHelper(org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference) GuiceModuleAccess(org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess) ITokenDefProvider(org.eclipse.xtext.parser.antlr.ITokenDefProvider) IgnoreCaseIDValueConverter(org.eclipse.xtext.conversion.impl.IgnoreCaseIDValueConverter) IgnoreCaseKeywordSerializer(org.eclipse.xtext.parsetree.reconstr.impl.IgnoreCaseKeywordSerializer) Extension(org.eclipse.xtext.xbase.lib.Extension) AntlrTokenDefProvider(org.eclipse.xtext.parser.antlr.AntlrTokenDefProvider) IKeywordSerializer(org.eclipse.xtext.serializer.tokens.IKeywordSerializer) AbstractIDValueConverter(org.eclipse.xtext.conversion.impl.AbstractIDValueConverter) IAntlrTokenFileProvider(org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider) IParser(org.eclipse.xtext.parser.IParser)

Example 12 with ManifestAccess

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

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

the class XtextProjectConfig method newManifestAccess.

protected ManifestAccess newManifestAccess() {
    ManifestAccess _manifestAccess = new ManifestAccess();
    final Procedure1<ManifestAccess> _function = (ManifestAccess it) -> {
        it.setLineDelimiter(this.codeConfig.getLineDelimiter());
    };
    return ObjectExtensions.<ManifestAccess>operator_doubleArrow(_manifestAccess, _function);
}
Also used : ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess)

Example 14 with ManifestAccess

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

the class BuilderIntegrationFragment2 method generate.

@Override
public void generate() {
    this.addRuntimeGuiceBindings();
    this.addEclipsePluginGuiceBindings();
    ManifestAccess _manifest = this.getProjectConfig().getEclipsePlugin().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
        this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.builder", "org.eclipse.xtext.ui")));
    }
}
Also used : ManifestAccess(org.eclipse.xtext.xtext.generator.model.ManifestAccess)

Example 15 with ManifestAccess

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

the class LabelProviderFragment2 method generate.

@Override
public void generate() {
    if ((this.isGenerateStub() || this._xbaseUsageDetector.inheritsXbase(this.getGrammar()))) {
        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");
        }
        TypeReference _xifexpression = null;
        boolean _isGenerateStub = this.isGenerateStub();
        if (_isGenerateStub) {
            _xifexpression = this.getEObjectLabelProviderClass(this.getGrammar());
        } else {
            _xifexpression = new TypeReference(LabelProviderFragment2.XBASE_LABEL_PROVIDER);
        }
        final TypeReference labelProviderClass = _xifexpression;
        TypeReference _xifexpression_1 = null;
        boolean _isGenerateStub_1 = this.isGenerateStub();
        if (_isGenerateStub_1) {
            _xifexpression_1 = this.getDescriptionLabelProviderClass(this.getGrammar());
        } else {
            _xifexpression_1 = new TypeReference(LabelProviderFragment2.XBASE_DESCRIPTION_LABEL_PROVIDER);
        }
        final TypeReference descriptionLabelProviderClass = _xifexpression_1;
        final TypeReference iLabelProviderClass = new TypeReference("org.eclipse.jface.viewers.ILabelProvider");
        final TypeReference rsdLabelProviderClass = new TypeReference("org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider");
        GuiceModuleAccess.BindingFactory _addTypeToType = new GuiceModuleAccess.BindingFactory().addTypeToType(iLabelProviderClass, labelProviderClass);
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("binder.bind(");
                _builder.append(iLabelProviderClass);
                _builder.append(".class).annotatedWith(");
                _builder.append(rsdLabelProviderClass);
                _builder.append(".class).to(");
                _builder.append(descriptionLabelProviderClass);
                _builder.append(".class);");
                _builder.newLineIfNotEmpty();
            }
        };
        _addTypeToType.addConfiguredBinding("ResourceUIServiceLabelProvider", _client).contributeTo(this.getLanguage().getEclipsePluginGenModule());
    }
    if ((this.isGenerateStub() && (this.getProjectConfig().getEclipsePlugin().getSrc() != null))) {
        boolean _isGenerateXtendStub = this.isGenerateXtendStub();
        if (_isGenerateXtendStub) {
            this.generateXtendEObjectLabelProvider();
            this.generateXtendDescriptionLabelProvider();
        } else {
            this.generateJavaEObjectLabelProvider();
            this.generateJavaDescriptionLabelProvider();
        }
    }
}
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