All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.xtext.service.DefaultRuntimeModule Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.service;

import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.xtext.common.services.DefaultTerminalConverters;
import org.eclipse.xtext.formatting.IFormatter;
import org.eclipse.xtext.formatting.INodeModelFormatter;
import org.eclipse.xtext.formatting.impl.DefaultNodeModelFormatter;
import org.eclipse.xtext.formatting.impl.OneWhitespaceFormatter;
import org.eclipse.xtext.linking.ILinkingService;
import org.eclipse.xtext.linking.LinkingScopeProviderBinding;
import org.eclipse.xtext.linking.impl.DefaultLinkingService;
import org.eclipse.xtext.linking.lazy.LazyLinker;
import org.eclipse.xtext.linking.lazy.LazyLinkingResource;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.naming.SimpleNameProvider;
import org.eclipse.xtext.parser.IEncodingProvider;
import org.eclipse.xtext.parser.antlr.AntlrTokenToStringConverter;
import org.eclipse.xtext.parser.antlr.ITokenDefProvider;
import org.eclipse.xtext.parser.antlr.NullTokenDefProvider;
import org.eclipse.xtext.parser.impl.PartialParsingHelper;
import org.eclipse.xtext.parsetree.reconstr.ITransientValueService;
import org.eclipse.xtext.parsetree.reconstr.Serializer;
import org.eclipse.xtext.parsetree.reconstr.impl.DefaultTransientValueService;
import org.eclipse.xtext.resource.DefaultFragmentProvider;
import org.eclipse.xtext.resource.DefaultLocationInFileProvider;
import org.eclipse.xtext.resource.IContainer;
import org.eclipse.xtext.resource.IFragmentProvider;
import org.eclipse.xtext.resource.ILocationInFileProvider;
import org.eclipse.xtext.resource.IResourceDescriptions;
import org.eclipse.xtext.resource.IResourceFactory;
import org.eclipse.xtext.resource.IResourceServiceProvider;
import org.eclipse.xtext.resource.SynchronizedXtextResourceSet;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.resource.XtextResourceFactory;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider;
import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions;
import org.eclipse.xtext.resource.impl.SimpleResourceDescriptionsBasedContainerManager;
import org.eclipse.xtext.scoping.IGlobalScopeProvider;
import org.eclipse.xtext.scoping.IScopeProvider;
import org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider;
import org.eclipse.xtext.scoping.impl.SimpleLocalScopeProvider;
import org.eclipse.xtext.serializer.ISerializer;
import org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.tokens.SerializerScopeProviderBinding;
import org.eclipse.xtext.validation.CancelableDiagnostician;
import org.eclipse.xtext.validation.IConcreteSyntaxValidator;
import org.eclipse.xtext.validation.impl.ConcreteSyntaxValidator;

import com.google.inject.Binder;
import com.google.inject.Provider;
import com.google.inject.name.Names;

/**
 * @author Heiko Behrens - Initial contribution and API
 * @author Sven Efftinge
 * @author Jan Koehnlein
 */
public abstract class DefaultRuntimeModule extends AbstractGenericModule {

	@Override
	public void configure(Binder binder) {
		super.configure(binder);
	}
	
	public EValidator.Registry bindEValidatorRegistry() {
		return EValidator.Registry.INSTANCE;
	}

	public EPackage.Registry bindEPackageRegistry() {
		return EPackage.Registry.INSTANCE;
	}
	
	public IResourceServiceProvider.Registry bindIResourceServiceProvider$Registry() {
		return IResourceServiceProvider.Registry.INSTANCE;
	}
	
	@SingletonBinding
	public Class bindDiagnostician() {
		return CancelableDiagnostician.class;
	}

	public Class bindIFragmentProvider() {
		return DefaultFragmentProvider.class;
	}

	public Class bindITransientValueService() {
		return DefaultTransientValueService.class;
	}

	public Class bindILocationInFileProvider() {
		return DefaultLocationInFileProvider.class;
	}
	
	public Class bindIFormatter() {
		return OneWhitespaceFormatter.class;
	}
	
	public Class bindINodeModelFormatter() {
		return DefaultNodeModelFormatter.class;
	}

	public Class bindISerializer() {
		return Serializer.class;
	}
	
	/**
	 * @since 2.0
	 */
	public Class bindISemanticSequencer() {
		return BacktrackingSemanticSequencer.class;
	}

	public Class bindConcreteSyntaxValidator() {
		return ConcreteSyntaxValidator.class;
	}

	public Class bindIResourceFactory() {
		return XtextResourceFactory.class;
	}

	public Class bindILinkingService() {
		return DefaultLinkingService.class;
	}

	public Class bindIScopeProvider() {
		return SimpleLocalScopeProvider.class;
	}
	
	/**
	 * @since 2.4
	 */
	public void configureSerializerIScopeProvider(Binder binder) {
		binder.bind(IScopeProvider.class).annotatedWith(SerializerScopeProviderBinding.class).to(IScopeProvider.class);
	}
	
	public void configureLinkingIScopeProvider(Binder binder) {
		binder.bind(IScopeProvider.class).annotatedWith(LinkingScopeProviderBinding.class).to(IScopeProvider.class);
	}
	
	public Class bindIGlobalScopeProvider() {
		return ImportUriGlobalScopeProvider.class;
	}
	
	public void configureIResourceDescriptions(com.google.inject.Binder binder) {
		binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class);
	}

	public void configureIResourceDescriptionsBuilderScope(com.google.inject.Binder binder) {
		binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(ResourceSetBasedResourceDescriptions.class);
	}
	
	public Class bindIQualifiedNameProvider() {
		return SimpleNameProvider.class;
	}

	public Class bindILinker() {
		return LazyLinker.class;
	}

	public Class bindIValueConverterService() {
		return DefaultTerminalConverters.class;
	}

	public Class bindITokenToStringConverter() {
		return AntlrTokenToStringConverter.class;
	}

	public Class bindIPartialParserHelper() {
		return PartialParsingHelper.class;
	}
	
	public Class bindITokenDefProvider() {
		return NullTokenDefProvider.class;
	}

	public Class bindIAstFactory() {
		return org.eclipse.xtext.parser.DefaultEcoreElementFactory.class;
	}

	public Class bindXtextResource() {
		return LazyLinkingResource.class;
	}
	
	public Class bindResourceSet() {
		return XtextResourceSet.class;
	}
	
	public Class bindXtextResourceSet() {
		return SynchronizedXtextResourceSet.class;
	}
	
	public Class bindIContainer$Manager() {
		return SimpleResourceDescriptionsBasedContainerManager.class;
	}
	
	public void configureRuntimeEncodingProvider(Binder binder) {
		binder.bind(IEncodingProvider.class).annotatedWith(DispatchingProvider.Runtime.class).to(IEncodingProvider.Runtime.class);
	}

	public Class> provideIEncodingProvider() {
		return IEncodingProviderDispatcher.class;
	}

	static class IEncodingProviderDispatcher extends DispatchingProvider{}
	
	public void configureIResourceDescriptionsLiveScope(Binder binder) {
		binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE)).to(ResourceSetBasedResourceDescriptions.class);
	}
	
	/**
	 * @since 2.0
	 */
	public void configureGenericSemanticSequencer(com.google.inject.Binder binder) {
		binder.bind(ISemanticSequencer.class).annotatedWith(GenericSequencer.class).to(BacktrackingSemanticSequencer.class);
	}
	

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy