Search in sources :

Example 6 with BindFactory

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

the class FormatterFragment method getGuiceBindingsRt.

@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    final Set<Binding> bindings = super.getGuiceBindingsRt(grammar);
    BindFactory bindFactory = new BindFactory();
    bindings.addAll(bindFactory.addTypeToType(INodeModelFormatter.class.getName(), RegionNodeModelFormatter.class.getName()).getBindings());
    bindings.addAll(bindFactory.addTypeToType(INodeModelStreamer.class.getName(), DirectNodeModelStreamer.class.getName()).getBindings());
    return bindings;
}
Also used : Binding(org.eclipse.xtext.generator.Binding) DirectNodeModelStreamer(com.avaloq.tools.ddk.xtext.formatting.DirectNodeModelStreamer) INodeModelStreamer(org.eclipse.xtext.formatting.INodeModelStreamer) INodeModelFormatter(org.eclipse.xtext.formatting.INodeModelFormatter) RegionNodeModelFormatter(com.avaloq.tools.ddk.xtext.formatting.RegionNodeModelFormatter) BindFactory(org.eclipse.xtext.generator.BindFactory)

Example 7 with BindFactory

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

the class ExportFragment method getGuiceBindingsRt.

/**
 * {@inheritDoc}
 */
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    final BindFactory bindFactory = new BindFactory();
    // $NON-NLS-1$
    final String namingPrefix = GrammarUtil.getNamespace(grammar) + ".naming." + GrammarUtil.getName(grammar);
    // $NON-NLS-1$
    final String resourcePrefix = GrammarUtil.getNamespace(grammar) + ".resource." + GrammarUtil.getName(grammar);
    ExportModel m = getModel(grammar);
    if (m != null) {
        // $NON-NLS-1$
        bindFactory.addTypeToType(IQualifiedNameProvider.class.getName(), namingPrefix + "ExportedNamesProvider");
        if (!m.getInterfaces().isEmpty()) {
            // $NON-NLS-1$
            bindFactory.addTypeToType(IFingerprintComputer.class.getName(), resourcePrefix + "FingerprintComputer");
        }
        if (!m.getExports().isEmpty()) {
            // $NON-NLS-1$
            bindFactory.addTypeToType(IDefaultResourceDescriptionStrategy.class.getName(), resourcePrefix + "ResourceDescriptionStrategy");
        }
        if (Iterables.any(m.getExports(), new Predicate<Export>() {

            @Override
            public boolean apply(final Export input) {
                return input.isFingerprint() && input.getFragmentAttribute() != null;
            }
        })) {
            // $NON-NLS-1$
            bindFactory.addTypeToType(IFragmentProvider.class.getName(), resourcePrefix + "FragmentProvider");
        }
    }
    // $NON-NLS-1$
    bindFactory.addTypeToType(IResourceDescription.Manager.class.getName(), resourcePrefix + "ResourceDescriptionManager");
    return bindFactory.getBindings();
}
Also used : IQualifiedNameProvider(org.eclipse.xtext.naming.IQualifiedNameProvider) IFingerprintComputer(com.avaloq.tools.ddk.xtext.resource.IFingerprintComputer) IDefaultResourceDescriptionStrategy(org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy) ExportModel(com.avaloq.tools.ddk.xtext.export.export.ExportModel) Export(com.avaloq.tools.ddk.xtext.export.export.Export) BindFactory(org.eclipse.xtext.generator.BindFactory) IFragmentProvider(org.eclipse.xtext.resource.IFragmentProvider)

Example 8 with BindFactory

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

the class CheckValidatorFragment method getGuiceBindingsRt.

@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    BindFactory factory = new BindFactory();
    factory.addTypeToTypeEagerSingleton(AbstractCheckValidator.class.getName(), DefaultCheckValidator.class.getName());
    return factory.getBindings();
}
Also used : AbstractCheckValidator(com.avaloq.tools.ddk.check.runtime.validation.AbstractCheckValidator) DefaultCheckValidator(com.avaloq.tools.ddk.check.runtime.validation.DefaultCheckValidator) BindFactory(org.eclipse.xtext.generator.BindFactory)

Example 9 with BindFactory

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

the class FormatFragment method getGuiceBindingsRt.

/**
 * {@inheritDoc}
 */
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
    final BindFactory bindFactory = new BindFactory();
    bindFactory.addTypeToType(IFormatter.class.getName(), FormatGeneratorUtil.getFormatterName(grammar, ""));
    bindFactory.addTypeToType(INodeModelFormatter.class.getName(), RegionNodeModelFormatter.class.getName());
    bindFactory.addTypeToType(INodeModelStreamer.class.getName(), DirectNodeModelStreamer.class.getName());
    return bindFactory.getBindings();
}
Also used : DirectNodeModelStreamer(com.avaloq.tools.ddk.xtext.formatting.DirectNodeModelStreamer) INodeModelStreamer(org.eclipse.xtext.formatting.INodeModelStreamer) INodeModelFormatter(org.eclipse.xtext.formatting.INodeModelFormatter) RegionNodeModelFormatter(com.avaloq.tools.ddk.xtext.formatting.RegionNodeModelFormatter) BindFactory(org.eclipse.xtext.generator.BindFactory) IFormatter(org.eclipse.xtext.formatting.IFormatter)

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