use of org.eclipse.xtext.ui.resource.XtextResourceSetProvider in project dsl-devkit by dsldevkit.
the class CheckMarkerUpdateJob method getResourceSet.
/**
* Gets the resource set. Note that not all sources must be part of the same resource set.
*
* @param storage2UriMapper
* the storage2 uri mapper, must not be {@code null}
* @param uri
* the uri, must not be {@code null}
* @return the resource set, may be {@code null}
*/
private ResourceSet getResourceSet(final IStorage2UriMapper storage2UriMapper, final URI uri) {
Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(uri);
if (!Iterables.isEmpty(storages)) {
IProject project = Iterables.get(storages, 0).getSecond();
XtextResourceSetProvider resourceSetProvider = this.serviceProviderRegistry.getResourceServiceProvider(uri).get(XtextResourceSetProvider.class);
return resourceSetProvider.get(project);
}
return null;
}
use of org.eclipse.xtext.ui.resource.XtextResourceSetProvider in project xtext-eclipse by eclipse.
the class GrammarLinkingInWorkspaceTest method testReferencedGrammarIsPlatformResourceURI.
@Test
public void testReferencedGrammarIsPlatformResourceURI() throws Exception {
IJavaProject project = JavaProjectSetupUtil.createJavaProject("p1");
IFile grammar1 = project.getProject().getFile("src/Grammar1.xtext");
grammar1.create(new StringInputStream("grammar Grammar1 MyRule : 'foo';"), true, null);
Injector injector = Activator.getDefault().getInjector(org.eclipse.xtext.xtext.ui.internal.Activator.ORG_ECLIPSE_XTEXT_XTEXT);
XtextResourceSetProvider resourceSetProvider = injector.getInstance(XtextResourceSetProvider.class);
ResourceSet resourceSet = resourceSetProvider.get(project.getProject());
XtextResourceFactory resourceFactory = injector.getInstance(XtextResourceFactory.class);
Resource resource = resourceFactory.createResource(URI.createURI("synthetic://MyGrammar.xtext"));
resourceSet.getResources().add(resource);
resource.load(new StringInputStream("grammar g2 with Grammar1 OtherRule : MyRule ;"), null);
EcoreUtil.resolveAll(resource);
assertEquals(2, resourceSet.getResources().size());
assertTrue(resourceSet.getResources().get(1).getURI().isPlatformResource());
}
Aggregations