org.eclipse.xtext.ui.resource.XtextResourceSetProvider Java Examples

The following examples show how to use org.eclipse.xtext.ui.resource.XtextResourceSetProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrammarLinkingInWorkspaceTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: SharedCommonTypesModule.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void configure(Binder binder) {
	binder.bind(IEObjectHoverProvider.class).to(JdtHoverProvider.class);
	binder.bind(IEObjectHoverDocumentationProvider.class).to(JdtHoverDocumentationProvider.class);
	binder.bind(IResourceServiceProvider.class).to(SharedCommonTypesResourceServiceProvider.class);
	binder.bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class);
	binder.bindConstant().annotatedWith(Names.named(Constants.FILE_EXTENSIONS)).to("java");

	binder.bind(IQualifiedNameProvider.class).to(JvmIdentifiableQualifiedNameProvider.class);
	binder.bind(ICopyQualifiedNameService.class).to(DefaultCopyQualifiedNameService.class);
	binder.bind(IJvmTypeProvider.Factory.class).to(JdtTypeProviderFactory.class);
	binder.bind(IRenameRefactoringProvider.class).to(DefaultRenameRefactoringProvider.class);
	binder.bind(AbstractRenameProcessor.class).to(JvmMemberRenameProcessor.class);
	binder.bind(IRenameStrategy.Provider.class).to(JvmMemberRenameStrategy.Provider.class);
	binder.bind(RefactoringResourceSetProvider.class).to(JvmRefactoringResourceSetProvider.class);
	binder.bind(String.class).annotatedWith(Names.named(Constants.LANGUAGE_NAME)).toInstance("Java");

	binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE))
			.to(LiveShadowedResourceDescriptions.class);
	binder.bind(IResourceDescriptions.class)
			.annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE))
			.to(CurrentDescriptions.ResourceSetAware.class);
	binder.bind(IResourceDescriptions.class)
			.annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS))
			.to(IBuilderState.class);

	binder.bind(IWorkspaceRoot.class).toInstance(ResourcesPlugin.getWorkspace().getRoot());
	binder.bind(ITraceForStorageProvider.class).to(TraceForStorageProvider.class);

	binder.bind(IReferenceUpdater.class).to(NullReferenceUpdater.class);
}
 
Example #3
Source File: CheckMarkerUpdateJob.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #4
Source File: ProjectXtextResourceProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Resource getResource(EObject context) {
    final XtextResourceSetProvider xtextResourceSetProvider = injector.getInstance(XtextResourceSetProvider.class);
    final IProject project = RepositoryManager.getInstance().getCurrentRepository().getProject();
    final ResourceSet resourceSet = xtextResourceSetProvider.get(project);
    return resourceSet.createResource(URI.createFileURI("somefile.cmodel"));
}
 
Example #5
Source File: TestsStandaloneSetup.java    From joynr with Apache License 2.0 5 votes vote down vote up
private Module getStaticTestModule() {
    return new AbstractModule() {

        @Override
        protected void configure() {
            bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class);
        }
    };
}
 
Example #6
Source File: DefaultUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IResourceSetProvider> bindIResourceSetProvider() {
	return XtextResourceSetProvider.class;
}