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);
}
}
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project n4js by eclipse.
the class RegExLiteralConverter method getRegexParser.
private IParser getRegexParser() {
if (regexParser == null) {
// no need for sync since we can also use a new regexParser if concurrent access happens by accident
IResourceServiceProvider serviceProvider = serviceProviders.getResourceServiceProvider(URI.createURI("a.regex"));
regexParser = serviceProvider.get(IParser.class);
}
return regexParser;
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project dsl-devkit by dsldevkit.
the class RegistryBuilderParticipant method initializeParticipant.
/**
* Initializes the given {@link IXtextBuilderParticipant}.
*
* @param participant
* the {@link IXtextBuilderParticipant} to initialize, must not be {@code null}
* @return whether the builder participant was initialized successfully
*/
private boolean initializeParticipant(final IXtextBuilderParticipant participant) {
String languageId = null;
if (participant instanceof IGeneratorModuleProvider) {
languageId = ((IGeneratorModuleProvider) participant).getGeneratorModuleId();
} else if (participant instanceof ILanguageSpecificBuilderParticipant) {
languageId = ((ILanguageSpecificBuilderParticipant) participant).getLanguageId();
}
if (languageId != null && !BuilderParticipantSettings.isBuilderParticipantEnabled(languageId)) {
return false;
}
if (!initializedParticipants.contains(participant)) {
if (languageId != null) {
final IResourceServiceProvider resourceServiceProvider = resourceServiceProviderLocator.getResourceServiceProviderById(languageId);
if (resourceServiceProvider != null) {
// inject members of the participant
final Injector injector = resourceServiceProvider.get(Injector.class);
injector.injectMembers(participant);
} else {
// $NON-NLS-1$
LOG.error(NLS.bind("No ResourceServiceProvider found for builder participant ''{0}'' and language id ''{1}''", participant.getClass().getName(), languageId));
return false;
}
}
initializedParticipants.add(participant);
}
return true;
}
Aggregations