use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-eclipse by eclipse.
the class ArithmeticsStandaloneSetupGenerated method register.
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/Xtext/example/Arithmetics")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/Xtext/example/Arithmetics", ArithmeticsPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("calc", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("calc", serviceProvider);
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-eclipse by eclipse.
the class DirtyStateEditorSupportIntegrationTest method setUpEditor.
@Before
public void setUpEditor() {
try {
final IResourceServiceProvider rsp = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("dummy.testlanguage"));
rsp.<Injector>get(Injector.class).injectMembers(this);
final IFile file = IResourcesSetupUtil.createFile("test/foo.testlanguage", "stuff foo");
this.editor = this.openEditor(file);
NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor);
this.editor.getSite().getPage().activate(this.editor);
NullProgressMonitor _nullProgressMonitor_1 = new NullProgressMonitor();
this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor_1);
this.events = CollectionLiterals.<IResourceDescription.Event>newArrayList();
final IResourceDescription.Event.Listener _function = (IResourceDescription.Event it) -> {
this.events.add(it);
};
this.editor.getDirtyStateEditorSupport().getDirtyStateManager().addListener(_function);
this.myDisplay = this.editor.getSite().getShell().getDisplay();
IterableExtensions.<Shell>head(((Iterable<Shell>) Conversions.doWrapArray(this.myDisplay.getShells()))).forceActive();
NullProgressMonitor _nullProgressMonitor_2 = new NullProgressMonitor();
this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor_2);
this.styledText = this.editor.getInternalSourceViewer().getTextWidget();
this.styledText.setCaretOffset(9);
this.styledText.setFocus();
this.syncUtil.waitForReconciler(this.editor);
NullProgressMonitor _nullProgressMonitor_3 = new NullProgressMonitor();
this.syncUtil.yieldToQueuedDisplayJobs(_nullProgressMonitor_3);
Thread.sleep(20);
Assert.assertTrue(this.events.isEmpty());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-eclipse by eclipse.
the class XbaseBreakpointDetailPaneFactory method createDetailPane.
@Override
public IDetailPane createDetailPane(String paneID) {
if (XBASE_DETAIL_PANE.equals(paneID)) {
return new LineBreakpointDetailPane() {
@Override
public void display(IStructuredSelection selection) {
super.display(selection);
AbstractJavaBreakpointEditor editor = getEditor();
Object input = null;
if (selection != null && selection.size() == 1) {
input = selection.getFirstElement();
}
try {
if (input instanceof IJavaStratumLineBreakpoint) {
IJavaStratumLineBreakpoint stratumBreakpoint = (IJavaStratumLineBreakpoint) input;
URI uri = URI.createURI((String) stratumBreakpoint.getMarker().getAttribute(StratumBreakpointAdapterFactory.ORG_ECLIPSE_XTEXT_XBASE_SOURCE_URI));
IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(uri);
if (resourceServiceProvider != null) {
JavaBreakPointProvider javaBreakPointProvider = resourceServiceProvider.get(JavaBreakPointProvider.class);
input = javaBreakPointProvider.getBreakpointWithJavaLocation(stratumBreakpoint);
}
}
editor.setInput(input);
} catch (CoreException e) {
JDIDebugUIPlugin.log(e);
}
}
};
} else {
return super.createDetailPane(paneID);
}
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-eclipse by eclipse.
the class EPackageChooser method createResourceSet.
private ResourceSet createResourceSet(URI genModelUri) {
ResourceSetImpl resourceSet;
if (genModelUri.fileExtension().equals("xcore")) {
IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(genModelUri);
IStorage2UriMapper storage2UriMapper = resourceServiceProvider.get(IStorage2UriMapper.class);
IProject project = storage2UriMapper.getStorages(genModelUri).iterator().next().getSecond();
resourceSet = (ResourceSetImpl) resourceServiceProvider.get(IResourceSetProvider.class).get(project);
} else {
resourceSet = new ResourceSetImpl();
}
Resource ecorePackageResource = EcorePackage.eINSTANCE.eResource();
Map<URI, Resource> uriResourceMap = Maps.newHashMap();
uriResourceMap.put(URI.createPlatformResourceURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
uriResourceMap.put(URI.createPlatformPluginURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
resourceSet.setURIResourceMap(uriResourceMap);
return resourceSet;
}
use of org.eclipse.xtext.resource.IResourceServiceProvider in project xtext-eclipse by eclipse.
the class ReferenceGrammarUiTestLanguageStandaloneSetupGenerated method register.
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/xtext/ui/common/tests/ReferenceGrammar")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/xtext/ui/common/tests/ReferenceGrammar", ReferenceGrammarUiPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("referencegrammaruitestlanguage", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("referencegrammaruitestlanguage", serviceProvider);
}
Aggregations