use of org.eclipse.xtext.resource.IResourceServiceProvider in project dsl-devkit by dsldevkit.
the class ResourceServiceProviderLocator method getResourceServiceProviderById.
/**
* Finds the {@link IResourceServiceProvider} for a language by given its id.
*
* @param languageId
* the language id (grammar name)
* @return the {@link IResourceServiceProvider} for the given language id
*/
public IResourceServiceProvider getResourceServiceProviderById(final String languageId) {
ImmutableMap<Map<String, Object>, ? extends Function<String, IResourceServiceProvider>> resourceProvidersMap = getProviderMaps();
for (Map.Entry<Map<String, Object>, ? extends Function<String, IResourceServiceProvider>> mapEntry : resourceProvidersMap.entrySet()) {
Map<String, Object> map = mapEntry.getKey();
for (Map.Entry<String, Object> entry : map.entrySet()) {
try {
IResourceServiceProvider resourceServiceProvider = mapEntry.getValue().apply(entry.getKey());
if (resourceServiceProvider == null) {
continue;
}
IGrammarAccess grammarAccess = resourceServiceProvider.get(IGrammarAccess.class);
if (grammarAccess != null && grammarAccess.getGrammar().getName().equals(languageId)) {
return resourceServiceProvider;
}
// CHECKSTYLE:OFF
} catch (ConfigurationException ex) {
// CHECKSTYLE:ON
// ignore
}
}
}
return null;
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project statecharts by Yakindu.
the class AbstractLibraryGlobalScopeProvider method getDescriptions.
protected Iterable<IEObjectDescription> getDescriptions(Resource context, URI uri) {
List<IEObjectDescription> result = Lists.newArrayList();
ResourceSet set = context.getResourceSet();
Resource resource = set.getResource(uri, true);
IResourceServiceProvider resourceServiceProvider = serviceProviderRegistry.getResourceServiceProvider(uri);
if (resourceServiceProvider == null) {
Iterables.addAll(result, Scopes.scopedElementsFor(Lists.newArrayList(resource.getAllContents())));
} else {
IResourceDescription resourceDescription = resourceServiceProvider.getResourceDescriptionManager().getResourceDescription(resource);
Iterables.addAll(result, resourceDescription.getExportedObjects());
}
resource.unload();
return result;
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project metalib by softlang.
the class FsmlStandaloneSetupGenerated method register.
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.softlang.org/metalib/xtext/fsml/Fsml")) {
EPackage.Registry.INSTANCE.put("http://www.softlang.org/metalib/xtext/fsml/Fsml", FsmlPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("fsml", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("fsml", serviceProvider);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project statecharts by Yakindu.
the class DirtyStateAwareDiagramDocumentEditor method createDirtyResource.
private void createDirtyResource(Resource resource) {
IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(resource.getURI());
if (resourceServiceProvider == null) {
return;
}
final DirtyResourceAdapter dirtyResource = new DirtyResourceAdapter(resource, resourceServiceProvider);
dirtyStateManager.manageDirtyState(dirtyResource);
uri2dirtyResource.put(resource.getURI(), dirtyResource);
if (EcoreUtil.getExistingAdapter(resource, DirtyResourceUpdater.class) == null)
resource.eAdapters().add(new DirtyResourceUpdater(dirtyResource));
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project gemoc-studio by eclipse.
the class DslStandaloneSetupGenerated method register.
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/gemoc/Dsl")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/gemoc/Dsl", DslPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("dsl", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("dsl", serviceProvider);
}
Aggregations