Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [xtext] augment generated ecore model
[xtext] augment generated ecore model [message #31204] Tue, 10 March 2009 08:29 Go to next message
Eclipse UserFriend
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 #31239 is a reply to message #31204] Tue, 10 March 2009 09:25 Go to previous messageGo to next message
Eclipse UserFriend
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.


Knut Wannheden wrote:
> 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 #31271 is a reply to message #31239] Tue, 10 March 2009 10:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: knut.wannheden.gmail.com

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 #31335 is a reply to message #31271] Tue, 10 March 2009 15:28 Go to previous messageGo to next message
Eclipse UserFriend
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 #31358 is a reply to message #31335] Wed, 11 March 2009 04:15 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sven,

Sven Efftinge wrote:
> 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.

I just posted https://bugs.eclipse.org/bugs/show_bug.cgi?id=268047.

> 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.

Maybe a static description of the transformation would suffice and also
have some advantages. If so then one possibility would be an Ecore
ChangeDescription stored in an XMI file alongside the Xtext grammar. Or
eventually an Epatch file (from the proposed Edapt project).

I will also file an enhancement for this in BugZilla.

Regards,

--knut
Re: [xtext] augment generated ecore model [message #31378 is a reply to message #31335] Wed, 11 March 2009 09:14 Go to previous message
Eclipse UserFriend
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
Previous Topic:[Announce] TMF XTEXT 0.7.0 I200903100545 is available
Next Topic:[Announce] TMF XTEXT 0.7.0 I200903111305 is available
Goto Forum:
  


Current Time: Wed Jul 16 03:23:35 EDT 2025

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

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

Back to the top