| [Xtend 2.1]Setting a default output path for the code generator [message #758542] |
Wed, 23 November 2011 10:48  |
Cedric Moonen Messages: 214 Registered: August 2009 |
Senior Member |
|
|
In Xtend 2.1, a compiler property page is available in the generated Xtext editor. This property page allows the user to select the output directory of the code generator for the specific grammar.
Is there a way to change the default "src-gen" directory ? The reason is that we would like to have a fixed output directory and remove the property page extension (so that the user can't modify it).
|
|
|
|
|
|
|
|
|
|
| Re: [Xtend 2.1]Setting a default output path for the code generator [message #758734 is a reply to message #758730] |
Thu, 24 November 2011 07:33   |
Cedric Moonen Messages: 214 Registered: August 2009 |
Senior Member |
|
|
Christian, I looked a bit deeper in that part of the code and the EclipseOutputConfigurationProvider extends the IOutputConfigurationProvider.Delegate class which provides a default implementation of "getOutputConfigurations" (simply delegating it to its delegate in fact).
The EclipseOutputConfigurationProvider doesn't override this method but it simply provides an additional public method: getOutputConfigurations(IProject project). This method internally calls the super.getOutputConfigurations() which result calling the delegate.
This means that if I only provide my own IOutputConfigurationProvider which overrides the default path, this should work fine (as far as I understood) and the Eclipse integration will also be supported.
I debugged this and indeed, a EclipseOutputConfigurationProvider is still created and my CustomOutputConfigurationProvider is correctly injected as the delegate (via the injected EclipseOutputConfigurationProvider constructor).
Now, I think I understood my problem: if you look at the BuilderPreferenceAccess class, you can see that it expects an OutputConfigurationProvider to be injected (in the setOutputConfigurationProvider method). Shouldn't that be a IOutputConfigurationProvider instead ? That's why the default Xtext OutputConfigurationProvider class gets injected instead of my own CustomOutputConfigurationProvider.
I made a litle test: I made my CustomOutputConfigurationProvider extends OutputConfigurationProvider (instead of implementing IOutputConfigurationProvider) and I provided two bindings in my ui module:
public Class<? extends IOutputConfigurationProvider> bindIOutputConfigurationProvider() {
return CustomOutputConfigurationProvider.class;
}
public Class<? extends OutputConfigurationProvider> bindOutputConfigurationProvider() {
return CustomOutputConfigurationProvider.class;
}
If I run that code, my problem is fixed and the default output path is not "./src-gen" in the property page anymore.
Is this a bug or desired behaviour ?
[Updated on: Thu, 24 November 2011 07:34] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01974 seconds