Home » Modeling » TMF (Xtext) » [xtext] augment generated ecore model
[xtext] augment generated ecore model [message #31204] |
Tue, 10 March 2009 08:29  |
Eclipse User |
|
|
|
Originally posted by: knut.wannheden.gmail.com
Hi,
I would like to make some small alterations to the Ecore model generated
by Xtext. For instance setting default values on EAttributes.
It seems like I currently would have to switch the generation off and
manage the Ecore model manually.
As an experimental alternative I implemented my own generator fragment
which I call right before StandardUiAndRuntime.mwe. This seems to work,
but I'd like to know if there is a better way of doing this or if we
should refrain from this approach altogether.
I was also wondering how I would best go about making changes to the
GenModel. One possibility would be to manage it manually and use its own
reconciler.
Regards,
--knut
|
|
| | |
Re: [xtext] augment generated ecore model [message #31335 is a reply to message #31271] |
Tue, 10 March 2009 15:28   |
Eclipse User |
|
|
|
Hi Knut,
yes, currently the genmodel is just written to disk, so that other
referencing genmodels can refer to it. Shouldn't be too difficult to
tell the generator fragment to use the genmodel if existent. But in that
case it should be maintained in src/ not src-gen/. Please open a bugzilla.
Regarding the modification of derived ecore models: Yes, we've been
thinking about such a hook as well. We're so far just not sure how we
would want to do the transformation. As we use the derived ecore file
for the static analysis in the grammar editor, we think the IDE (Grammar
Editor) should know about the transformation.
Maybe an Xtendfile referenced via naming convention (e.g. a similar
named Xtend file laying next to the *.xtxt resource). As Xtend is
interpreted it would be possible to apply the transformation in the IDE
as well as in the generator. You could file a bug report for this as
well, as AFAIK it doesn't yet exist.
Cheers,
Sven
Knut Wannheden schrieb:
> Hi Ed,
>
> Ed Merks wrote:
>> Knut,
>>
>> Overwriting the GenModel seems bad to me. Once it exists, it likely
>> contains important settings the user will want to preserve. It's very
>> easy to programatically invoke the reconciler. In fact, just opening
>> the "old" GenModel when it points to an updated Ecore model will
>> reconcile it within that editor session.
>>
>>
>
> What you are describing is basically what I would like to achieve :-)
>
> When a TMF Xtext grammar is set to generate an Ecore model it will
> currently also generate (i.e. overwrite) a corresponding GenModel. I
> don't know if and how this can be suppressed to instead have the
> generator use an existing GenModel.
>
> There is a "genmodels" property I can set on the generator, but I think
> it is only used for resolving the GenModel for any referenced models.
>
> So either I want to (a) disable the GenModel generation (and invocation
> of the GenModel generator) and do that step manually or (b) have the
> Xtext generator reconcile and use my existing GenModel.
>
> In addition to that I would like to make some alterations to the
> generated Ecore model, as not all aspects can be controlled from the
> Xtext grammar.
>
> Regards,
>
> --knut
|
|
| |
Re: [xtext] augment generated ecore model [message #31378 is a reply to message #31335] |
Wed, 11 March 2009 09:14  |
Eclipse User |
|
|
|
Guys,
In relation to your efforts, you may want to take a look at these two
bugzillas:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=216701
and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=255469
With these enhancements it should be possible to define derived features and
EOperations with Xtend. They would present themselves as regular
EStructuralFeatures and EOperations, but their invocation can be delegated
to the Xtend interpreter.
Xtext would, however, still have to merge the metamodel inferred from the
grammar and the features defined in the Xtend file into one coherent
metamodel.
Cheers,
Achim
Sven Efftinge wrote:
> Hi Knut,
>
> yes, currently the genmodel is just written to disk, so that other
> referencing genmodels can refer to it. Shouldn't be too difficult to
> tell the generator fragment to use the genmodel if existent. But in that
> case it should be maintained in src/ not src-gen/. Please open a bugzilla.
>
> Regarding the modification of derived ecore models: Yes, we've been
> thinking about such a hook as well. We're so far just not sure how we
> would want to do the transformation. As we use the derived ecore file
> for the static analysis in the grammar editor, we think the IDE (Grammar
> Editor) should know about the transformation.
> Maybe an Xtendfile referenced via naming convention (e.g. a similar
> named Xtend file laying next to the *.xtxt resource). As Xtend is
> interpreted it would be possible to apply the transformation in the IDE
> as well as in the generator. You could file a bug report for this as
> well, as AFAIK it doesn't yet exist.
>
> Cheers,
> Sven
>
>
> Knut Wannheden schrieb:
>> Hi Ed,
>>
>> Ed Merks wrote:
>>> Knut,
>>>
>>> Overwriting the GenModel seems bad to me. Once it exists, it likely
>>> contains important settings the user will want to preserve. It's very
>>> easy to programatically invoke the reconciler. In fact, just opening
>>> the "old" GenModel when it points to an updated Ecore model will
>>> reconcile it within that editor session.
>>>
>>>
>>
>> What you are describing is basically what I would like to achieve :-)
>>
>> When a TMF Xtext grammar is set to generate an Ecore model it will
>> currently also generate (i.e. overwrite) a corresponding GenModel. I
>> don't know if and how this can be suppressed to instead have the
>> generator use an existing GenModel.
>>
>> There is a "genmodels" property I can set on the generator, but I think
>> it is only used for resolving the GenModel for any referenced models.
>>
>> So either I want to (a) disable the GenModel generation (and invocation
>> of the GenModel generator) and do that step manually or (b) have the
>> Xtext generator reconcile and use my existing GenModel.
>>
>> In addition to that I would like to make some alterations to the
>> generated Ecore model, as not all aspects can be controlled from the
>> Xtext grammar.
>>
>> Regards,
>>
>> --knut
|
|
|
Goto Forum:
Current Time: Wed Jul 16 03:23:35 EDT 2025
Powered by FUDForum. Page generated in 0.05303 seconds
|