use of org.eclipse.xtext.resource.IResourceServiceProvider.Registry in project xtext-eclipse by eclipse.
the class TraceEditor method updateText.
protected void updateText(EObject obj) {
DebugTraceRegion region = EcoreUtil2.getContainerOfType(obj, DebugTraceRegion.class);
if (region == null) {
text.setText("No " + DebugTraceRegion.class.getSimpleName() + " found for " + obj.eClass().getName());
return;
}
final DebugTraceBasedRegion trace = new DebugTraceBasedRegion(null, region);
SourceRelativeURI sourceURI = trace.getAssociatedSrcRelativePath();
if (sourceURI == null) {
text.setText("Could not find associated URI");
return;
}
Registry registry = IResourceServiceProvider.Registry.INSTANCE;
IResourceServiceProvider serviceProvider = registry.getResourceServiceProvider(sourceURI.getURI());
URI traceURI = obj.eResource().getURI();
IStorage localStorage = getLocalStorage(serviceProvider, traceURI);
StorageAwareTrace traceProvider = serviceProvider.get(StorageAwareTrace.class);
traceProvider.setLocalStorage(localStorage);
traceProvider.setTraceToSource(true);
traceProvider.setTraceRegionProvider(new ITraceRegionProvider() {
@Override
public AbstractTraceRegion getTraceRegion() throws TraceNotFoundException {
return trace;
}
});
String newText = traceProvider.toString();
text.setText(newText);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider.Registry in project xtext-eclipse by eclipse.
the class ResourceServiceProviderProviderTest method testResourceServiceProviderProvider.
@Test
public void testResourceServiceProviderProvider() {
String contenttype = "mycontent";
String ext = "TestResourceServiceProviderProvider";
URI uri = URI.createFileURI("foofile." + ext);
Registry registry = IResourceServiceProvider.Registry.INSTANCE;
// the file extension is registered via plugin.xml
IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri, contenttype);
Assert.assertTrue(resourceServiceProvider instanceof TestResourceServiceProvider);
TestResourceServiceProvider provider = (TestResourceServiceProvider) resourceServiceProvider;
Assert.assertEquals(uri, provider.uri);
Assert.assertEquals(contenttype, provider.contentType);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider.Registry in project xtext-eclipse by eclipse.
the class ResourceServiceProviderProviderTest method testResourceServiceProviderProviderWithExecutableExtensionFactory.
@Test
public void testResourceServiceProviderProviderWithExecutableExtensionFactory() {
String contenttype = "mycontent";
String ext = "TestResourceServiceProviderExecutableExtensionFactory";
URI uri = URI.createFileURI("foofile." + ext);
Registry registry = IResourceServiceProvider.Registry.INSTANCE;
// the file extension is registered via plugin.xml
IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri, contenttype);
Assert.assertTrue(resourceServiceProvider instanceof TestResourceServiceProvider);
TestResourceServiceProvider provider = (TestResourceServiceProvider) resourceServiceProvider;
Assert.assertEquals(uri, provider.uri);
Assert.assertEquals(contenttype, provider.contentType);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider.Registry in project smarthome by eclipse.
the class RegistryProvider method createRegistry.
private Registry createRegistry() {
registerDefaultFactories();
IResourceServiceProvider.Registry registry = new ResourceServiceProviderRegistryImpl();
register(registry, new ItemsIdeSetup().createInjector());
register(registry, new PersistenceIdeSetup().createInjector());
register(registry, new RulesIdeSetup().setScriptServiceUtil(scriptServiceUtil).setScriptEngine(scriptEngine).createInjector());
register(registry, new ScriptIdeSetup().setScriptServiceUtil(scriptServiceUtil).setScriptEngine(scriptEngine).createInjector());
register(registry, new SitemapIdeSetup().createInjector());
register(registry, new ThingIdeSetup().createInjector());
return registry;
}
Aggregations