Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315075

Summary: Collision of generated generator workflow and UI
Product: [Modeling] TMF Reporter: Alexander Nittka <alex>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: enhancement    
Priority: P3    
Version: 0.7.2   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Alexander Nittka CLA 2010-05-31 09:27:13 EDT
Build Identifier: I20090611-1540

A sensible step in plugin development based on Xtext is providing the User with a UI-action for generating from the currently open file. If this action is based on invoking the generated generator workflow, there is a clash of concepts.
The MWEReader component by default gets the StandaloneSetup class as parameter. The latter creates the injector and registers the Resource factory.
For a complete standalone invokation this is OK, however, if this method is called within the UI, a factory that is already registered gets overridden.

org.eclipse.xtext.resource.IResourceFactory resourceFactory = injector.getInstance(org.eclipse.xtext.resource.IResourceFactory.class);
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(fileExtesion, resourceFactory);

Now the question is, who is making the mistake: the developer who programmatically invokes the generated workflow (well, it is allowed, isn't it), rather than using the XPandFacade directly or the framework that assumes that a workflow is always invoked in a standalone environment (here again, is it a problem in the workflow definition or in the StandaloneSetup).

Reproducible: Always
Comment 1 Sven Efftinge CLA 2012-11-14 04:06:38 EST
The IGenerator interface should be used to implement code generators, that work from within Eclipse and in Standalone.