use of org.eclipse.xtext.resource.IResourceServiceProvider in project n4js by eclipse.
the class RegularExpressionStandaloneSetupGenerated method register.
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/n4js/regex/RegularExpression")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/n4js/regex/RegularExpression", RegularExpressionPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("regex", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("regex", serviceProvider);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project n4js by eclipse.
the class EagerResourceSetBasedResourceDescriptions method computeResourceDescription.
private IResourceDescription computeResourceDescription(URI uri) {
Resource resource = resourceSet.getResource(uri, false);
if (resource == null)
return null;
IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
if (resourceServiceProvider == null)
return null;
IResourceDescription.Manager manager = resourceServiceProvider.getResourceDescriptionManager();
if (manager == null)
return null;
return manager.getResourceDescription(resource);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project n4js by eclipse.
the class TypesStandaloneSetupGenerated method register.
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4ts", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4ts", serviceProvider);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project n4js by eclipse.
the class TestDiscoveryUIUtils method getSelectedElement.
private static EObject getSelectedElement(final XtextEditor editor, final ITextSelection textSelection) {
return editor.getDocument().modify(resource -> {
final IResourceServiceProvider serviceProvider = resource.getResourceServiceProvider();
final EObjectAtOffsetHelper offsetHelper = serviceProvider.get(EObjectAtOffsetHelper.class);
return offsetHelper.resolveElementAt(resource, textSelection.getOffset());
});
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project n4js by eclipse.
the class N4HeadlessCompiler method indexResource.
/**
* Install the given resource's description into the given index. Raw JavaScript files will not be indexed. Note
* that when this method is called for the given resource, it is not yet fully processed and therefore the
* serialized type model is not added to the index.
* <p>
* This is due to the fact that we keep a common resource set for all projects that contains the resources of all
* projects with unprocessed dependencies, unlike in the IDE case where we have one resource set per open document
* and load the type models from the index.
* </p>
* <p>
* Since the type models are available in the resource set as long as they may still be referenced, they need not be
* serialized and stored into the index.
* </p>
*
* @param resource
* the resource to be indexed
* @param index
* the index to add the given resource to
*/
private void indexResource(Resource resource, ResourceDescriptionsData index) {
if (!shouldIndexResource(resource))
return;
final URI uri = resource.getURI();
IResourceServiceProvider serviceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uri);
if (serviceProvider != null) {
if (logger.isCreateDebugOutput()) {
logger.debug(" Indexing resource " + uri);
}
IResourceDescription.Manager resourceDescriptionManager = serviceProvider.getResourceDescriptionManager();
IResourceDescription resourceDescription = resourceDescriptionManager.getResourceDescription(resource);
if (resourceDescription != null) {
index.addDescription(uri, resourceDescription);
}
}
}
Aggregations