Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » JET Template problem accesing to EAnnotation
JET Template problem accesing to EAnnotation [message #664536] Sun, 10 April 2011 20:57 Go to next message
Xavipen Mising name is currently offline Xavipen Mising name
Messages: 49
Registered: March 2011
Member
Hi,

Following the article about OCL: http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-with-OCL/index.html

I have try to use an EAnnotation define on the model at the class level to change how the code for the genoperations should be generated.

For that i worte my template:
implementedGenOperation.TODO.override.javajetinc

In order to access the class Annotations i ahve use first as test the following line.

<%=genClass.getEcoreClass().getEAnnotations().toString()%>

and it works, printing the expected annotations for the class. However, as soon as i replace that line for any of the two lines below. The code generation is broken for the whole model (Only the package is written and nothing else on the .java files)

line 1:
EAnnotation eannot = genClass.getEcoreClass().getEAnnotation("MyAnnotationSource ");

line 2:
EList<EAnnotation> l = genClass.getEcoreClass().getEAnnotations();

All the rest of the code generation i want to implement is working but i am some how stuck with this and i am not able to find what is wrong with the lines above, any help would be appreciated.

Cheers,
J
Re: JET Template problem accesing to EAnnotation [message #664539 is a reply to message #664536] Sun, 10 April 2011 23:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25950
Registered: July 2009
Senior Member
Xavipen,

Comments below.

Xavipen wrote:
> Hi,
>
> Following the article about OCL:
> http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-with-OCL/index.html
>
>
> I have try to use an EAnnotation define on the model at the class
> level to change how the code for the genoperations should be generated.
> For that i worte my template:
> implementedGenOperation.TODO.override.javajetinc
>
> In order to access the class Annotations i ahve use first as test the
> following line.
>
> <%=genClass.getEcoreClass().getEAnnotations().toString()%>
>
> and it works, printing the expected annotations for the class.
> However, as soon as i replace that line for any of the two lines
> below. The code generation is broken for the whole model (Only the
> package is written and nothing else on the .java files)
You've looked in the error log?
> line 1:
> EAnnotation eannot =
> genClass.getEcoreClass().getEAnnotation("MyAnnotationSource ");
Is the extra trailing space a mistake?
>
> line 2:
> EList<EAnnotation> l = genClass.getEcoreClass().getEAnnotations();
>
> All the rest of the code generation i want to implement is working but
> i am some how stuck with this and i am not able to find what is wrong
> with the lines above, any help would be appreciated.
>
> Cheers,
> J
Re: JET Template problem accesing to EAnnotation [message #664547 is a reply to message #664536] Mon, 11 April 2011 01:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi J

You are looking at a very old article.

You will find
http://help.eclipse.org/helios/topic/org.eclipse.ocl.doc/tut orials/oclinecore/oclInEcoreTutorial.html
is much easier and works on both dynamic and static models.

Regards

Ed Willink



On 11/04/2011 01:57, Xavipen wrote:
> Hi,
>
> Following the article about OCL:
> http://www.eclipse.org/articles/article.php?file=Article-EMF -Codegen-with-OCL/index.html
>
> I have try to use an EAnnotation define on the model at the class
> level to change how the code for the genoperations should be generated.
> For that i worte my template:
> implementedGenOperation.TODO.override.javajetinc
>
> In order to access the class Annotations i ahve use first as test the
> following line.
>
> <%=genClass.getEcoreClass().getEAnnotations().toString()%>
>
> and it works, printing the expected annotations for the class.
> However, as soon as i replace that line for any of the two lines
> below. The code generation is broken for the whole model (Only the
> package is written and nothing else on the .java files)
> line 1:
> EAnnotation eannot =
> genClass.getEcoreClass().getEAnnotation("MyAnnotationSource ");
>
> line 2:
> EList<EAnnotation> l = genClass.getEcoreClass().getEAnnotations();
>
> All the rest of the code generation i want to implement is working but
> i am some how stuck with this and i am not able to find what is wrong
> with the lines above, any help would be appreciated.
>
> Cheers,
> J
Re: JET Template problem accesing to EAnnotation [message #664582 is a reply to message #664539] Mon, 11 April 2011 05:49 Go to previous message
Xavipen Mising name is currently offline Xavipen Mising name
Messages: 49
Registered: March 2011
Member
Thanks a lot for your both replies.

The wierd thing was that nothing appeared in the Error Log of the Eclipse. Or did you meant a different error log?

In any case i found where the problem was:

I haven't added org.eclipse.emf.ecore.* to the the imports of the Class.javajet Template. That is why whenever i wrote EAnnotion a = xxxx, it was failing.

The unfortunate part was that i did not get any error msg to be able to find out quicker where was the problem.

Regards,
Javi
Previous Topic:[EEF] Integration with custom Editor
Next Topic:[ACCELEO] Create a new module based on my metamodel
Goto Forum:
  


Current Time: Fri Aug 01 22:34:44 EDT 2014

Powered by FUDForum. Page generated in 0.01920 seconds