Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to add a custom method to ECore model?(Xtext "Generator" in combination with "IXtext2EcorePostProcessor " is now deprecated - What is the replacement?)
How to add a custom method to ECore model? [message #1768932] Tue, 25 July 2017 05:57 Go to next message
Michael Schnell is currently offline Michael SchnellFriend
Messages: 6
Registered: October 2013
Location: Hamburg (Germany)
Junior Member
Hi all,

It seems that the way of adding some additional custom code to the generated Ecore model changed in the current Xtext version.

So far I used the "IXtext2EcorePostProcessor" to achieve the goal of adding an additonal method to a generated Ecore class:

https://github.com/fuinorg/org.fuin.dsl.ddd/blob/master/org.fuin.dsl.ddd.dsl/src/org/fuin/dsl/ddd/postprocessor/DomainDrivenDesignDslXtext2EcorePostProcessor.xtend

This worked fine with earlier Xtext versions, but now the "ExtendedGenerator" that registers above post processor doesn't compile anymore: https://github.com/fuinorg/org.fuin.dsl.ddd/blob/master/org.fuin.dsl.ddd.dsl/src/org/fuin/dsl/ddd/ExtendedGenerator.java

What would be the right way to do it with a current Xtext Version?

Cheers,
Michael

Re: How to add a custom method to ECore model? [message #1768933 is a reply to message #1768932] Tue, 25 July 2017 06:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=483209

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to add a custom method to ECore model? [message #1768936 is a reply to message #1768933] Tue, 25 July 2017 06:38 Go to previous messageGo to next message
Michael Schnell is currently offline Michael SchnellFriend
Messages: 6
Registered: October 2013
Location: Hamburg (Germany)
Junior Member
OK, so removing the "@deprecated" annotation would do the trick.

Looking at the discussion, it seems that this way of adding additional behaviour to the model is not really the way it should be done. Is there any way of doing this directly in the grammar? https://github.com/fuinorg/org.fuin.dsl.ddd/blob/master/org.fuin.dsl.ddd.dsl/src/org/fuin/dsl/ddd/DomainDrivenDesignDsl.xtext

The problem is as follows:
AbstractEntity:
	Entity | Aggregate;
AbstractEntityId:
	EntityId | AggregateId;
Entity:
	'entity' name=ID ('identifier' idType=[EntityId])?
Aggregate:
	'aggregate' name=ID ('identifier' idType=[AggregateId])?

The requirement is to have an "AbstractEntityId getIdType()" method on "AbstractEntity".

How to achieve this only using the grammar?







Re: How to add a custom method to ECore model? [message #1768937 is a reply to message #1768936] Tue, 25 July 2017 06:40 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
you cant

as the ticket says:
you need to
-switch to a xcore/external ecore
-use the workaround in the bug
-install xpand, add it to the dependencies, and write the trafo in old xtend1 (.ext file)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:INT interferes with defined terminals
Next Topic:Handling semantic whitespace: forcefully avoiding it
Goto Forum:
  


Current Time: Fri Mar 29 10:21:39 GMT 2024

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

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

Back to the top