|
|
|
|
Re: Customizing generated java classes [message #658076 is a reply to message #658070] |
Sun, 06 March 2011 00:27 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
Since the imported model is generated from ecore, you could just use the
'@generated not' pattern and let the emf code generator handle your
changes. Then you do not have to do any additional work in your xtext
grammar.
As a recommendation, I would keep the imported model as anemic as
possible, and with as few manually modified methods as possible. Place
all other code (processing, runtime state, etc) elsewhere using suitable
patterns.
In my first language implementation with Xtext I started out with far
too much implementation inside the classes used in the grammar, and this
turned out to be a bad idea - not so much from a code generation
standpoint, but more that functionality tended to be spread out and
require lots of editing in lots of places. I was much happier with an
anemic model and using Xtext polymorphic dispatchers to keep related
logic together. I also found adapters to be very useful to keep the
model lean (I used them for things like type inference information).
BTW, I am also curious about best practices when using the "generation
gap" pattern for an imported model. I can imagine customizing the
MyDSLFactory and returning instances of the concrete impl classes
instead of the generated "abstract" classes - is that how it is supposed
to be done?
Regards
- henrik
On 3/5/11 11:43 PM, Balint Torok wrote:
> Hi,
>
> great answers. I had success with the imported metamodel. But I'm
> curious about this generation gap pattern. I think I got the message,
> but I'm not sure how to use it. I have the generated classes for the
> model. I have my "manually modified" classes that are subclasses of the
> generated classes. Now how can I make the xtext-generated editor use my
> "manual" classes instead of the generated classes?
>
> Thanks,
> Balint
|
|
|
Re: Customizing generated java classes [message #658211 is a reply to message #658076] |
Mon, 07 March 2011 12:27 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
You could also use the MWE component
org.eclipse.emf.mwe2.ecore.EcoreGenerator
to generate your EMF classes. This one can be configured to
automatically pick up manually enhanced implementation classes following
a naming convention.
Am 06.03.11 01:27, schrieb Henrik Lindberg:
> Since the imported model is generated from ecore, you could just use the
> '@generated not' pattern and let the emf code generator handle your
> changes. Then you do not have to do any additional work in your xtext
> grammar.
>
> As a recommendation, I would keep the imported model as anemic as
> possible, and with as few manually modified methods as possible. Place
> all other code (processing, runtime state, etc) elsewhere using suitable
> patterns.
>
> In my first language implementation with Xtext I started out with far
> too much implementation inside the classes used in the grammar, and this
> turned out to be a bad idea - not so much from a code generation
> standpoint, but more that functionality tended to be spread out and
> require lots of editing in lots of places. I was much happier with an
> anemic model and using Xtext polymorphic dispatchers to keep related
> logic together. I also found adapters to be very useful to keep the
> model lean (I used them for things like type inference information).
>
> BTW, I am also curious about best practices when using the "generation
> gap" pattern for an imported model. I can imagine customizing the
> MyDSLFactory and returning instances of the concrete impl classes
> instead of the generated "abstract" classes - is that how it is supposed
> to be done?
>
> Regards
> - henrik
>
>
>
> On 3/5/11 11:43 PM, Balint Torok wrote:
>> Hi,
>>
>> great answers. I had success with the imported metamodel. But I'm
>> curious about this generation gap pattern. I think I got the message,
>> but I'm not sure how to use it. I have the generated classes for the
>> model. I have my "manually modified" classes that are subclasses of the
>> generated classes. Now how can I make the xtext-generated editor use my
>> "manual" classes instead of the generated classes?
>>
>> Thanks,
>> Balint
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.03748 seconds