Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtend 2.1]Setting a default output path for the code generator
[Xtend 2.1]Setting a default output path for the code generator [message #758542] Wed, 23 November 2011 15:48 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
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 #758556 is a reply to message #758542] Wed, 23 November 2011 16:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Have a look at IOutputConfigurationProvider

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend 2.1]Setting a default output path for the code generator [message #758689 is a reply to message #758556] Thu, 24 November 2011 09:17 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Thanks for your answer.
I looked at IOutputConfigurationProvider and found that you provide a default OutputConfigurationProvider which is by default injected by GUICE.
So, I created a custom implementation of IOutputConfigurationProvider and injected in my ui runtime module (XXXXUiModule.java) this way:

	public Class<? extends IOutputConfigurationProvider> bindIOutputConfigurationProvider() {
		return CustomOutputConfigurationProvider.class;
	}


This seems to work partially since the getOutputConfigurations method of my custom class is being called, but it still doesn't solve the problem fully: if I start from a clean workspace and look at the "Compiler" preference page for my grammar, I can see that the output folder is still "./src-gen".

After debugging for a while, I've found that the preference store is not properly initialized: in the BuilderPreferenceAccess class, there is an injected "setOutputConfigurationProvider" method. Putting a breakpoint in this method I can see that the OutputConfigurationProvider class is being injected and not my CustomOutputConfigurationProvider.

Now, I'm far from being an expert with GUICE and I'm wondering what the Inject annotation does on a method ?
How can I make sure that my own CustomOutputConfigurationProvider is injected instead of the default one ? I guess I'm using GUICE in a wrong way here...
Re: [Xtend 2.1]Setting a default output path for the code generator [message #758717 is a reply to message #758689] Thu, 24 November 2011 11:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Did you try to bind a own EclipseOutputConfigurationProvider in the UI Module?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend 2.1]Setting a default output path for the code generator [message #758722 is a reply to message #758717] Thu, 24 November 2011 11:52 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
No and I really don't understand why this is needed.
So, I have to provide my own implementation of IOutputConfigurationProvider and my own implementation of EclipseOutputConfigurationProvider and bind them in my module ?

I understand that I have to provide my own IOutputConfigurationProvider since it is supplying the default output directory, but I don't understand why I have to provide my own EclipseOutputConfigurationProvider...

The only thing I want to change is the default output directory (from "src-gen" to my own custom directory).
Re: [Xtend 2.1]Setting a default output path for the code generator [message #758723 is a reply to message #758722] Thu, 24 November 2011 11:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

this is (as in many cases) and standalone vs ui + builder thing
the ui uses EclipseOutputConfigurationProvider thus you have to customize it

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend 2.1]Setting a default output path for the code generator [message #758726 is a reply to message #758723] Thu, 24 November 2011 12:13 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 11/24/2011 12:58 PM, Christian Dietrich wrote:
> Hi,
>
> this is (as in many cases) and standalone vs ui + builder thing
> the ui uses EclipseOutputConfigurationProvider thus you have to
> customize it
>
> ~Christian

Hi

so we need to bind it both in the runtime and in the ui? Or only in the ui?

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: [Xtend 2.1]Setting a default output path for the code generator [message #758730 is a reply to message #758726] Thu, 24 November 2011 12:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
EclipseOutputConfigurationProvider in UI IOutputConfigurationProvider in runtime if you use it standalone - but i guess no
so bind a EclipseOutputConfigurationProvider and the stuff is done


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
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 12:33 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
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 12:34]

Report message to a moderator

Re: [Xtend 2.1]Setting a default output path for the code generator [message #758737 is a reply to message #758734] Thu, 24 November 2011 12:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

BuilderPreferenceAccess is for the preferences - but if you do it static, why dont you throw away the complete preference page since noone can change it anyway - in the preference page you see the stuff from the preference store - if you dont use it - notbody cares.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend 2.1]Setting a default output path for the code generator [message #758738 is a reply to message #758737] Thu, 24 November 2011 12:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
but it is of course a bug that the not the interface is used. please file a ticket


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xtend 2.1]Setting a default output path for the code generator [message #758745 is a reply to message #758738] Thu, 24 November 2011 13:04 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Yes, I could plainly remove the preference page but I was experimenting with that a bit. In fact in my case I can leave the preference page as long as the default value is my own path.

I submitted a bug report in bugzilla.
Previous Topic:Generation gap pattern and EcoreGenerator
Next Topic:Dependency management during build process
Goto Forum:
  


Current Time: Sat Apr 20 04:31:49 GMT 2024

Powered by FUDForum. Page generated in 0.04377 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top