Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334497 - [builder] EMFBasedPersister requires Eclipse workbench
Summary: [builder] EMFBasedPersister requires Eclipse workbench
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M5   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-17 04:20 EST by Knut Wannheden CLA
Modified: 2017-09-19 18:09 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Knut Wannheden CLA 2011-01-17 04:20:49 EST
The class EMFBasedPersister declares a dependency on the Eclipse IWorkbench:

	@Inject(optional=true)
	private IWorkbench workbench;

The Guice 'optional' parameter only means that there needn't be any binding for the injection key (IWorkbech.class). In this case the point is that the implementation can live with the workbench being 'null'. It should thus instead (or in addition) define the binding as @Nullable:


	@Inject(optional=true) @Nullable
	private IWorkbench workbench;

This then fits together with binding made in the SharedModule:


	bind(IWorkbench.class).toProvider(new Provider<IWorkbench>() {
		public IWorkbench get() {
			if (PlatformUI.isWorkbenchRunning())
				return PlatformUI.getWorkbench();
			return null;
		}
	});
 
The @Nullable should possibly also be used for other bindings in the Xtext code base.

In the case of the EMFBasedPersister I think the IWorkbench binding is wrong altogether. Instead the implementation should use the already present IWorkspace and use addSaveParticipant() to register a callback to save the index.
Comment 1 Sebastian Zarnekow CLA 2011-01-17 04:24:57 EST
Hi Knut,

this sounds reasonable to me. Do you have the time to provide a patch that refactors the persister to use a save participant.
Comment 2 Knut Wannheden CLA 2011-01-19 02:15:00 EST
Pushed fix to MASTER.
Comment 3 Karsten Thoms CLA 2017-09-19 17:58:42 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 4 Karsten Thoms CLA 2017-09-19 18:09:26 EDT
Closing all bugs that were set to RESOLVED before Neon.0