org.eclipse.xtext.parser.IEncodingProvider Java Examples

The following examples show how to use org.eclipse.xtext.parser.IEncodingProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SCTXtextIntegrationModule.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void configure(Binder binder) {
	binder.bind(IResourceValidator.class).to(SCTResourceValidatorImpl.class);
	binder.bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("sct");
	binder.bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
	binder.bind(IQualifiedNameProvider.class).to(StextNameProvider.class);
	binder.bind(org.eclipse.jface.viewers.ILabelProvider.class)
			.annotatedWith(org.eclipse.xtext.ui.resource.ResourceServiceDescriptionLabelProvider.class)
			.to(DefaultDescriptionLabelProvider.class);
	binder.bind(IDefaultResourceDescriptionStrategy.class).to(SCTResourceDescriptionStrategy.class);
	
	binder.bind(MarkerCreator.class).to(SCTMarkerCreator.class);
	binder.bind(MarkerTypeProvider.class).to(SCTMarkerTypeProvider.class);
	binder.bind(IDiagnosticConverter.class).to(SCTDiagnosticConverterImpl.class);
	binder.bind(IURIEditorOpener.class).annotatedWith(LanguageSpecific.class).to(SCTFileEditorOpener.class);
	
	binder.bind(IMarkerContributor.class).to(TaskMarkerContributor.class);
	binder.bind(ITaskFinder.class).to(DomainSpecificTaskFinder.class);
	binder.bind(TaskMarkerCreator.class).to(SCTTaskMarkerCreator.class);
	binder.bind(TaskMarkerTypeProvider.class).to(SCTTaskMarkerTypeProvider.class);
}
 
Example #2
Source File: JavaSourceLanguageRuntimeModule.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(Resource.Factory.class).to(JavaResource.Factory.class);
	bind(IResourceValidator.class).toInstance(IResourceValidator.NULL);
	bind(IGenerator.class).to(IGenerator.NullGenerator.class);
	bind(IEncodingProvider.class).to(IEncodingProvider.Runtime.class);
	bind(IResourceServiceProvider.class).to(JavaResourceServiceProvider.class);
	bind(IContainer.Manager.class).to(SimpleResourceDescriptionsBasedContainerManager.class);
	bind(IResourceDescription.Manager.class).to(JavaResourceDescriptionManager.class);
	bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class);
	bind(String.class).annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).toInstance("java");
	bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME))
			.toInstance("org.eclipse.xtext.java.Java");
	bind(IJvmTypeProvider.Factory.class).to(ClasspathTypeProviderFactory.class);
	bind(ClassLoader.class).toInstance(JavaSourceLanguageRuntimeModule.class.getClassLoader());
	bind(IReferableElementsUnloader.class).to(IReferableElementsUnloader.GenericUnloader.class);
	bind(IResourceDescriptionsProvider.class)
			.toInstance((ResourceSet rs) -> ChunkedResourceDescriptions.findInEmfObject(rs));
}
 
Example #3
Source File: XtextGenerator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected void initializeEncoding() {
  final IResourceServiceProvider.Registry serviceProviderRegistry = IResourceServiceProvider.Registry.INSTANCE;
  Object _get = serviceProviderRegistry.getExtensionToFactoryMap().get("xtext");
  final IResourceServiceProvider serviceProvider = ((IResourceServiceProvider) _get);
  String _elvis = null;
  if (this.grammarEncoding != null) {
    _elvis = this.grammarEncoding;
  } else {
    String _encoding = this.configuration.getCode().getEncoding();
    _elvis = _encoding;
  }
  final String encoding = _elvis;
  if (((serviceProvider != null) && (encoding != null))) {
    final IEncodingProvider encodingProvider = serviceProvider.<IEncodingProvider>get(IEncodingProvider.class);
    if ((encodingProvider instanceof IEncodingProvider.Runtime)) {
      ((IEncodingProvider.Runtime)encodingProvider).setDefaultEncoding(encoding);
    }
  }
}
 
Example #4
Source File: StandaloneBuilderModule.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(IResourceDescriptions.class)
			.annotatedWith(named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE))
			.to(ResourceSetBasedResourceDescriptions.class);
	bind(IResourceDescriptions.class)
			.annotatedWith(named(ResourceDescriptionsProvider.LIVE_SCOPE))
			.to(ResourceSetBasedResourceDescriptions.class);
	bind(IResourceDescriptions.class)
			.annotatedWith(named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS))
			.to(ResourceSetBasedResourceDescriptions.class);
	bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class);
	bind(IIssueHandler.class).to(this.bindIIssueHandler());
	bind(AbstractFileSystemAccess.class).to(this.bindJavaIoFileSystemAccess());
	bind(IJavaCompiler.class).to(this.bindIJavaCompiler());
	bind(IEncodingProvider.class).to(this.bindIEncodingProvider());
}
 
Example #5
Source File: StandaloneBuilder.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public void fileEncodingSetup(Collection<LanguageAccess> langs, String encoding) {
	for (LanguageAccess lang : langs) {
		IEncodingProvider provider = lang.getEncodingProvider();
		if (provider instanceof IEncodingProvider.Runtime) {
			((IEncodingProvider.Runtime) provider).setDefaultEncoding(encoding);
		} else {
			forceDebugLog("Couldn't set encoding '" + encoding + "' for provider '" + provider
					+ "'. Only subclasses of IEncodingProvider.Runtime are supported.");
		}
	}
}
 
Example #6
Source File: ChangeConverter2.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected String getCharset(Resource resource) {
	IEncodingProvider xtextEncodingProvider = registry.getResourceServiceProvider(resource.getURI())
			.get(IEncodingProvider.class);
	if (xtextEncodingProvider != null) {
		return xtextEncodingProvider.getEncoding(resource.getURI());
	} else {
		if (resource instanceof XMLResource) {
			return ((XMLResource) resource).getEncoding();
		} else {
			return Charset.defaultCharset().toString();
		}
	}
}
 
Example #7
Source File: UnicodeTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	with(UnicodeTestLanguageStandaloneSetup.class);
	IEncodingProvider.Runtime encodingProvider = get(IEncodingProvider.Runtime.class);
	encodingProvider.setDefaultEncoding(getCharsetForTest().name());
}
 
Example #8
Source File: JavaIoFileSystemAccess.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.4
 */
public JavaIoFileSystemAccess(IResourceServiceProvider.Registry registry, IEncodingProvider encodingProvider,
		TraceFileNameProvider traceFileNameProvider, TraceRegionSerializer traceRegionSerializer) {
	this.registry = registry;
	this.encodingProvider = encodingProvider;
	this.traceFileNameProvider = traceFileNameProvider;
	this.traceSerializer = traceRegionSerializer;
}
 
Example #9
Source File: JavaIoFileSystemTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  try {
    final File tempDir = this.temporaryFolder.newFolder();
    JavaIOFileSystemSupport _javaIOFileSystemSupport = new JavaIOFileSystemSupport();
    final Procedure1<JavaIOFileSystemSupport> _function = (JavaIOFileSystemSupport it) -> {
      final IProjectConfigProvider _function_1 = (ResourceSet it_1) -> {
        File _file = new File(tempDir, "foo");
        FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
        final Procedure1<FileProjectConfig> _function_2 = (FileProjectConfig it_2) -> {
          it_2.addSourceFolder("src");
        };
        return ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function_2);
      };
      it.setProjectConfigProvider(_function_1);
      IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
      it.setEncodingProvider(_runtime);
      XtextResourceSet _xtextResourceSet = new XtextResourceSet();
      it.setContext(_xtextResourceSet);
    };
    JavaIOFileSystemSupport _doubleArrow = ObjectExtensions.<JavaIOFileSystemSupport>operator_doubleArrow(_javaIOFileSystemSupport, _function);
    this.fs = _doubleArrow;
    this.createProject("foo");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #10
Source File: JavaIoFileSystemTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  try {
    final File tempDir = this.temporaryFolder.newFolder();
    JavaIOFileSystemSupport _javaIOFileSystemSupport = new JavaIOFileSystemSupport();
    final Procedure1<JavaIOFileSystemSupport> _function = (JavaIOFileSystemSupport it) -> {
      final IProjectConfigProvider _function_1 = (ResourceSet it_1) -> {
        File _file = new File(tempDir, "foo");
        FileProjectConfig _fileProjectConfig = new FileProjectConfig(_file);
        final Procedure1<FileProjectConfig> _function_2 = (FileProjectConfig it_2) -> {
          it_2.addSourceFolder("src");
        };
        return ObjectExtensions.<FileProjectConfig>operator_doubleArrow(_fileProjectConfig, _function_2);
      };
      it.setProjectConfigProvider(_function_1);
      IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
      it.setEncodingProvider(_runtime);
      XtextResourceSet _xtextResourceSet = new XtextResourceSet();
      it.setContext(_xtextResourceSet);
    };
    JavaIOFileSystemSupport _doubleArrow = ObjectExtensions.<JavaIOFileSystemSupport>operator_doubleArrow(_javaIOFileSystemSupport, _function);
    this.fs = _doubleArrow;
    this.createProject("foo");
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example #11
Source File: CommandRegistryTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public IEncodingProvider getEncodingProvider() {
	return noImpl.getEncodingProvider();
}
 
Example #12
Source File: AbstractGenericResourceRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IEncodingProvider> bindIEncodingProvider() {
	return XMLEncodingProvider.class;
}
 
Example #13
Source File: DefaultResourceServiceProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IEncodingProvider getEncodingProvider() {
	return encodingProvider;
}
 
Example #14
Source File: DefaultRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureRuntimeEncodingProvider(Binder binder) {
	binder.bind(IEncodingProvider.class).annotatedWith(DispatchingProvider.Runtime.class).to(IEncodingProvider.Runtime.class);
}
 
Example #15
Source File: DefaultRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.8
 */
public Class<? extends IEncodingProvider.Runtime> bindRuntimeEncodingProvider() {
	return EclipseProjectPropertiesEncodingProvider.class;
}
 
Example #16
Source File: DefaultRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends Provider<IEncodingProvider>> provideIEncodingProvider() {
	return IEncodingProviderDispatcher.class;
}
 
Example #17
Source File: URIBasedFileSystemAccess.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public IEncodingProvider getEncodingProvider() {
	return encodingProvider;
}
 
Example #18
Source File: DefaultGeneratorModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void configureIEncodingProvider(Binder binder) {
	IEncodingProvider.Runtime runtime = new IEncodingProvider.Runtime();
	runtime.setDefaultEncoding(code.getEncoding());
	binder.bind(IEncodingProvider.class).toInstance(runtime);
}
 
Example #19
Source File: GamlUiModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void configureUiEncodingProvider(final Binder binder) {
	binder.bind(IEncodingProvider.class).annotatedWith(DispatchingProvider.Ui.class).to(GamlEncodingProvider.class);
}
 
Example #20
Source File: GamlRuntimeModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void configureRuntimeEncodingProvider(final Binder binder) {
	binder.bind(IEncodingProvider.class).annotatedWith(DispatchingProvider.Runtime.class)
			.to(GamlEncodingProvider.class);
}
 
Example #21
Source File: GenericResourceServiceProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IEncodingProvider getEncodingProvider() {
	return encodingProvider;
}
 
Example #22
Source File: URIBasedFileSystemAccess.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public void setEncodingProvider(IEncodingProvider encodingProvider) {
	this.encodingProvider = encodingProvider;
}
 
Example #23
Source File: JavaIoFileSystemAccess.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.3
 */
public JavaIoFileSystemAccess(IResourceServiceProvider.Registry registry, IEncodingProvider encodingProvider) {
	this.registry = registry;
	this.encodingProvider = encodingProvider;
}
 
Example #24
Source File: AbstractFileSystemSupport.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public void setEncodingProvider(final IEncodingProvider encodingProvider) {
  this.encodingProvider = encodingProvider;
}
 
Example #25
Source File: AbstractFileSystemSupport.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Pure
public IEncodingProvider getEncodingProvider() {
  return this.encodingProvider;
}
 
Example #26
Source File: DefaultRefactoringDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public RedirectedFileDocument(URI resourceURI, IFile file, IFile redirectedFile, 
		IEncodingProvider encodingProvider) {
	super(resourceURI, file, encodingProvider);
	this.redirectedFile = redirectedFile;
}
 
Example #27
Source File: DefaultRefactoringDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public FileDocument(URI resourceURI, IFile file, IEncodingProvider encodingProvider) {
	super(resourceURI);
	this.file = file;
	this.encodingProvider = encodingProvider;
}
 
Example #28
Source File: DefaultRefactoringDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected IEncodingProvider getEncodingProvider(URI resourceURI) {
	return globalServiceProvider.findService(
			resourceURI, IEncodingProvider.class);
}
 
Example #29
Source File: DefaultUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void configureUiEncodingProvider(Binder binder) {
	binder.bind(IEncodingProvider.class).annotatedWith(DispatchingProvider.Ui.class)
			.to(WorkspaceEncodingProvider.class);
}
 
Example #30
Source File: DefaultResourceUIServiceProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IEncodingProvider getEncodingProvider() {
	return encodingProvider;
}