Search in sources :

Example 1 with BindFactory

use of org.eclipse.xtext.generator.BindFactory in project dsl-devkit by dsldevkit.

the class ModelInferenceFragment method getGuiceBindingsRt.

@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    BindFactory factory = new BindFactory();
    if (generateModelInference) {
        factory.addTypeToTypeSingleton(IInferredModelAssociations.class.getName(), InferredModelAssociator.class.getName());
        factory.addTypeToTypeSingleton(IInferredModelAssociator.class.getName(), InferredModelAssociator.class.getName());
        factory.addTypeToTypeSingleton(IDerivedStateComputer.class.getName(), InferredModelAssociator.class.getName());
    }
    return factory.getBindings();
}
Also used : IInferredModelAssociator(com.avaloq.tools.ddk.xtext.modelinference.IInferredModelAssociator) InferredModelAssociator(com.avaloq.tools.ddk.xtext.modelinference.InferredModelAssociator) IInferredModelAssociations(com.avaloq.tools.ddk.xtext.modelinference.IInferredModelAssociations) IDerivedStateComputer(org.eclipse.xtext.resource.IDerivedStateComputer) BindFactory(org.eclipse.xtext.generator.BindFactory) IInferredModelAssociator(com.avaloq.tools.ddk.xtext.modelinference.IInferredModelAssociator)

Example 2 with BindFactory

use of org.eclipse.xtext.generator.BindFactory in project dsl-devkit by dsldevkit.

the class BuilderIntegrationFragment method getGuiceBindingsUi.

/**
 * {@inheritDoc}
 */
@Override
public Set<Binding> getGuiceBindingsUi(final Grammar grammar) {
    final Set<Binding> bindings = super.getGuiceBindingsUi(grammar);
    final BindFactory factory = new BindFactory();
    factory.addConfiguredBinding(IResourceDescriptions.class.getName() + "BuilderScope", "binder.bind(" + IResourceDescriptions.class.getName() + ".class" + ").annotatedWith(com.google.inject.name.Names.named(" + ResourceDescriptionsProvider.class.getName() + ".NAMED_BUILDER_SCOPE)).to(" + "com.avaloq.tools.ddk.xtext.builder.CurrentDescriptions2.ResourceSetAware.class)");
    final Set<Binding> result = factory.getBindings();
    result.addAll(bindings);
    return result;
}
Also used : Binding(org.eclipse.xtext.generator.Binding) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) BindFactory(org.eclipse.xtext.generator.BindFactory)

Example 3 with BindFactory

use of org.eclipse.xtext.generator.BindFactory in project dsl-devkit by dsldevkit.

the class BuilderIntegrationFragment method getGuiceBindingsRt.

@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    final Set<Binding> bindings = super.getGuiceBindingsRt(grammar);
    final BindFactory factory = new BindFactory();
    factory.addTypeToType(IContainer.Manager.class.getName(), "com.avaloq.tools.ddk.xtext.builder.CachingStateBasedContainerManager");
    factory.addTypeToType(LazyLinkingResource.class.getName(), LazyLinkingResource2.class.getName());
    factory.addTypeToType(LazyURIEncoder.class.getName(), FastLazyURIEncoder.class.getName());
    final Set<Binding> result = factory.getBindings();
    result.addAll(bindings);
    return result;
}
Also used : Binding(org.eclipse.xtext.generator.Binding) FastLazyURIEncoder(com.avaloq.tools.ddk.xtext.linking.FastLazyURIEncoder) LazyLinkingResource2(com.avaloq.tools.ddk.xtext.linking.LazyLinkingResource2) LazyLinkingResource(org.eclipse.xtext.linking.lazy.LazyLinkingResource) FastLazyURIEncoder(com.avaloq.tools.ddk.xtext.linking.FastLazyURIEncoder) LazyURIEncoder(org.eclipse.xtext.linking.lazy.LazyURIEncoder) BindFactory(org.eclipse.xtext.generator.BindFactory)

Example 4 with BindFactory

use of org.eclipse.xtext.generator.BindFactory in project dsl-devkit by dsldevkit.

the class ScopingFragment method getGuiceBindingsRt.

/**
 * {@inheritDoc}
 */
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    final BindFactory bindFactory = new BindFactory();
    final String prefix = GrammarUtil.getNamespace(grammar) + ".scoping." + GrammarUtil.getName(grammar);
    bindFactory.addTypeToType(IScopeProvider.class.getName(), prefix + "ScopeProvider");
    bindFactory.addTypeToType(IScopeNameProvider.class.getName(), prefix + "ScopeNameProvider");
    bindFactory.addTypeToType(ILinkingService.class.getName(), "com.avaloq.tools.ddk.xtext.linking.LinkingService");
    return bindFactory.getBindings();
}
Also used : IScopeProvider(org.eclipse.xtext.scoping.IScopeProvider) ILinkingService(org.eclipse.xtext.linking.ILinkingService) IScopeNameProvider(com.avaloq.tools.ddk.xtext.scoping.IScopeNameProvider) BindFactory(org.eclipse.xtext.generator.BindFactory)

Example 5 with BindFactory

use of org.eclipse.xtext.generator.BindFactory in project xtext-eclipse by eclipse.

the class IdeaPluginGenerator method generate.

@Override
public void generate(final Grammar grammar, final Xtend2ExecutionContext ctx) {
    this._xtextIDEAGeneratorExtensions.installOutlets(ctx, this.ideaProjectPath, this.encoding, this.getNaming().getLineDelimiter());
    String outlet_src_gen = this._xtextIDEAGeneratorExtensions.getSrcGenOutlet(ctx).getName();
    String _xifexpression = null;
    if (this.srcGenOnly) {
        _xifexpression = outlet_src_gen;
    } else {
        _xifexpression = this._xtextIDEAGeneratorExtensions.getSrcOutlet(ctx).getName();
    }
    String outlet_src = _xifexpression;
    final BindFactory bindFactory = new BindFactory();
    bindFactory.addTypeToType("org.eclipse.xtext.parser.antlr.IAntlrTokenFileProvider", this._ideaPluginClassNames.getAntlrTokenFileProvider(grammar));
    bindFactory.addTypeToType("org.eclipse.xtext.parser.antlr.Lexer", this._ideaPluginClassNames.getPsiInternalLexerName(grammar));
    String _psiInternalLexerName = this._ideaPluginClassNames.getPsiInternalLexerName(grammar);
    String _plus = (((("binder.bind(org.eclipse.xtext.parser.antlr.Lexer.class)" + ".annotatedWith(com.google.inject.name.Names.named(") + "org.eclipse.xtext.parser.antlr.LexerBindings.RUNTIME") + ")).to(") + _psiInternalLexerName);
    String _plus_1 = (_plus + ".class)");
    bindFactory.addConfiguredBinding("RuntimeLexer", _plus_1);
    bindFactory.addTypeToType("com.intellij.lang.PsiParser", this._ideaPluginClassNames.getPsiParserName(grammar));
    bindFactory.addTypeToType("org.eclipse.xtext.idea.parser.TokenTypeProvider", this._ideaPluginClassNames.getTokenTypeProviderName(grammar));
    bindFactory.addTypeToType("com.intellij.lang.ParserDefinition", this._ideaPluginClassNames.getParserDefinitionName(grammar));
    bindFactory.addTypeToTypeSingleton("org.eclipse.xtext.idea.lang.IElementTypeProvider", this._ideaPluginClassNames.getElementTypeProviderName(grammar));
    bindFactory.addTypeToType("org.eclipse.xtext.idea.facet.AbstractFacetConfiguration", this._ideaPluginClassNames.getFacetConfiguration(grammar));
    String _facetTypeName = this._ideaPluginClassNames.getFacetTypeName(grammar);
    String _plus_2 = (_facetTypeName + ".TYPEID");
    bindFactory.addTypeToInstance("com.intellij.facet.FacetTypeId", _plus_2);
    boolean _doesUseXbase = XbaseGeneratorFragment.doesUseXbase(grammar);
    if (_doesUseXbase) {
        bindFactory.addTypeToType("org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider", "org.eclipse.xtext.idea.common.types.StubBasedTypeScopeProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.xbase.typesystem.internal.IFeatureScopeTracker.Provider", "org.eclipse.xtext.xbase.typesystem.internal.OptimizingFeatureScopeTrackerProvider");
        bindFactory.addConfiguredBinding("LanguageSpecificPsiModelAssociations", (("binder.bind(org.eclipse.xtext.psi.IPsiModelAssociations.class)." + "annotatedWith(org.eclipse.xtext.service.LanguageSpecific.class).") + "to(org.eclipse.xtext.idea.common.types.DerivedMemberAwarePsiModelAssociations.class)"));
        bindFactory.addTypeToType("org.eclipse.xtext.idea.highlighting.IHighlightingConfiguration", "org.eclipse.xtext.xbase.idea.highlighting.XbaseHighlightingConfiguration");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.formatting.BlockFactory", "org.eclipse.xtext.xbase.idea.formatting.XbaseBlockFactory");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.formatting.ChildAttributesProvider", "org.eclipse.xtext.xbase.idea.formatting.XbaseChildAttributesProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.ide.editor.bracketmatching.IBracePairProvider", "org.eclipse.xtext.xbase.idea.bracketmatching.XbaseBracePairProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.findusages.IReferenceSearcher", "org.eclipse.xtext.xbase.idea.findusages.JvmElementAwareReferenceSearcher");
        bindFactory.addTypeToType("org.eclipse.xtext.xbase.compiler.IGeneratorConfigProvider", "org.eclipse.xtext.xbase.idea.facet.XbaseGeneratorConfigProvider");
        bindFactory.addTypeToType("org.eclipse.xtext.idea.findusages.WordsScannerProvider", "org.eclipse.xtext.xbase.idea.findusages.XbaseWordsScanner.XbaseWordsScannerProvider");
    }
    final Set<Binding> bindings = bindFactory.getBindings();
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getStandaloneSetupIdea(grammar)), this.compileStandaloneSetup(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.getIdeaSetup(grammar)), this.compileIdeaSetup(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getIdeaModuleName(grammar)), this.compileIdeaModule(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.getCompletionContributor(grammar)), this.compileCompletionContributor(grammar));
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("META-INF/services/");
    String _name = ISetup.class.getName();
    _builder.append(_name);
    ctx.writeFile(outlet_src_gen, _builder.toString(), this.compileServicesISetup(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAbstractCompletionContributor(grammar)), this.compileAbstractCompletionContributor(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getLanguageName(grammar)), this.compileLanguage(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.getFileTypeName(grammar)), this.compileFileType(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAbstractFileTypeName(grammar)), this.compileAbstractFileType(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFileTypeFactoryName(grammar)), this.compileFileTypeFactory(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFileImplName(grammar)), this.compileFileImpl(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getTokenTypeProviderName(grammar)), this.compileTokenTypeProvider(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getElementTypeProviderName(grammar)), this.compileElementTypeProvider(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getParserDefinitionName(grammar)), this.compileParserDefinition(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getSyntaxHighlighterFactoryName(grammar)), this.compileSyntaxHighlighterFactory(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getSemanticHighlightVisitorName(grammar)), this.compileSemanticHighlightVisitor(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAbstractIdeaModuleName(grammar)), this.compileGuiceModuleIdeaGenerated(grammar, bindings));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getExtensionFactoryName(grammar)), this.compileExtensionFactory(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getCodeBlockModificationListenerName(grammar)), this.compileCodeBlockModificationListener(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getPsiParserName(grammar)), this.compilePsiParser(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getAntlrTokenFileProvider(grammar)), this.compileAntlrTokenFileProvider(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getPomDeclarationSearcherName(grammar)), this.compilePomDeclarationSearcher(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFacetTypeName(grammar)), this.compileFacetType(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.getFacetConfiguration(grammar)), this.compileFacetConfiguration(grammar));
    ctx.writeFile(outlet_src_gen, this._ideaPluginClassNames.toJavaPath(this._ideaPluginClassNames.baseColorSettingsPage(grammar)), this.compileBaseColorSettingsPage(grammar));
    ctx.writeFile(outlet_src, this._ideaPluginClassNames.toXtendPath(this._ideaPluginClassNames.colorSettingsPage(grammar)), this.compileColorSettingsPage(grammar));
    OutputImpl output = new OutputImpl();
    this.addOutlet(output, IdeaPluginGenerator.PLUGIN, false, this.ideaProjectPath);
    this.addOutlet(output, IdeaPluginGenerator.META_INF_PLUGIN, false, (this.ideaProjectPath + "/META-INF"));
    this.addOutlet(output, IdeaPluginGenerator.META_INF_PLUGIN_GEN, true, (this.ideaProjectPath + "/META-INF"));
    if (this.deployable) {
        this.writeFile(output, IdeaPluginGenerator.META_INF_PLUGIN, "plugin.xml", this.compilePluginXml(grammar));
        this.writeFile(output, IdeaPluginGenerator.META_INF_PLUGIN_GEN, "plugin_gen.xml", this.compilePluginGenXml(grammar));
    }
}
Also used : Binding(org.eclipse.xtext.generator.Binding) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BindFactory(org.eclipse.xtext.generator.BindFactory) OutputImpl(org.eclipse.xpand2.output.OutputImpl)

Aggregations

BindFactory (org.eclipse.xtext.generator.BindFactory)9 Binding (org.eclipse.xtext.generator.Binding)4 DirectNodeModelStreamer (com.avaloq.tools.ddk.xtext.formatting.DirectNodeModelStreamer)2 RegionNodeModelFormatter (com.avaloq.tools.ddk.xtext.formatting.RegionNodeModelFormatter)2 INodeModelFormatter (org.eclipse.xtext.formatting.INodeModelFormatter)2 INodeModelStreamer (org.eclipse.xtext.formatting.INodeModelStreamer)2 AbstractCheckValidator (com.avaloq.tools.ddk.check.runtime.validation.AbstractCheckValidator)1 DefaultCheckValidator (com.avaloq.tools.ddk.check.runtime.validation.DefaultCheckValidator)1 Export (com.avaloq.tools.ddk.xtext.export.export.Export)1 ExportModel (com.avaloq.tools.ddk.xtext.export.export.ExportModel)1 FastLazyURIEncoder (com.avaloq.tools.ddk.xtext.linking.FastLazyURIEncoder)1 LazyLinkingResource2 (com.avaloq.tools.ddk.xtext.linking.LazyLinkingResource2)1 IInferredModelAssociations (com.avaloq.tools.ddk.xtext.modelinference.IInferredModelAssociations)1 IInferredModelAssociator (com.avaloq.tools.ddk.xtext.modelinference.IInferredModelAssociator)1 InferredModelAssociator (com.avaloq.tools.ddk.xtext.modelinference.InferredModelAssociator)1 IFingerprintComputer (com.avaloq.tools.ddk.xtext.resource.IFingerprintComputer)1 IScopeNameProvider (com.avaloq.tools.ddk.xtext.scoping.IScopeNameProvider)1 OutputImpl (org.eclipse.xpand2.output.OutputImpl)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 IFormatter (org.eclipse.xtext.formatting.IFormatter)1