use of org.eclipse.xtext.resource.XtextResourceFactory 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