Ecore - method bodies [message #1794488] |
Fri, 31 August 2018 05:26  |
Eclipse User |
|
|
|
Hello everyone,
I am pretty new to Ecore, and I would like to ask if it's possible to fill the method bodies with the generated code. I know one can use OCL to make preconditions and postconditions for the methods, but is it's possible to autogenerate method body code as well? I believe adding body code to the autogenerated method manually is very bad idea if I regenerate my model again.
What is the alternative that Ecore provides? I found here https://www.eclipse.org/modeling/emf/docs/presentations/EclipseCon/EclipseCon2006_EMF_Intro.pdf , that one can use annotations e.g. "@generated NOT", but I think this is only not regenerating the method again.
Also I couldn't figure out what is a syntax for preconditions and postconditions in OCLInEcore. Usual OCL syntax:
context <classifier>::<operation> (<parameters>)
pre [<constraint name>]:
<Boolean OCL expression>
did not work for me.
e.g.
class Web
{
operation addKeyword(keyword : String[?])
{
pre: not keyword.oclIsUndefined();
}
}
Another question is, does Ecore support C++ code generation or only Java is supported?
Thank you in advance,
Ivan
|
|
|
|
|
Re: Ecore - method bodies [message #1794706 is a reply to message #1794490] |
Wed, 05 September 2018 05:37   |
Eclipse User |
|
|
|
Hi,
Ed Merks wrote on Fri, 31 August 2018 09:46
The Ecore editor for Photon makes it easy to create such annotations because the specialized properties view for defining GenModel annotations as well as specialized creation support for creating the GenModel annotation.
Sorry, and maybe this question is stupid, but I recently switched to Photon, and have now some difficulties with the EMF editor. While adding the GenModel Annotation is now very easy, editing the "body" part is difficult, because it allows only one line of code. Previously, I could open a multi-line editor, but this is not longer possible. Am I missing a certain plugin, or is there a new way of doing it?
Best
Jan-Patrick
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02841 seconds