Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » createEcoreAnnotations is not generated from .xcore file
createEcoreAnnotations is not generated from .xcore file [message #1770372] Thu, 10 August 2017 12:46 Go to next message
Stefan Milchram is currently offline Stefan MilchramFriend
Messages: 33
Registered: September 2012
Member
Hi,

we have a .xcore file with the following annotations at the beginning of the file:
@Ecore(nsURI="someUri")
@Ecore(conversionDelegates="myDelegate")
@GenModel(modelName="myModelName", prefix="myprefix", modelDirectory="/model/src", editDirectory="model.edit/src", importerID="org.eclipse.emf.importer.ecore", rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl", rootExtendsInterface="org.eclipse.emf.cdo.CDOObject", providerRootExtendsClass="org.eclipse.emf.cdo.edit.CDOItemProviderAdapter", modelPluginVariables="org.eclipse.xtext.xbase.lib org.eclipse.emf.ecore.xcore.lib CDO=org.eclipse.emf.cdo", featureDelegation="Reflective", suppressGenModelAnnotations="false", literalsInterface="true")

When generating the java code the @GenModel annotation java method (createGenModelAnnotations) in class MyPackageImpl is created, but the method for the @Ecore (createEcoreAnnotations) is missing.

The Xcore editor is not showing any errors.
I cloned the emf-git repo (git://git.eclipse.org/gitroot/emf/org.eclipse.emf.git) and searched for the generator code, but couldn't find it.
Does anybody here know why the method is not generated or where the generator code is located exactly?

PS: i did not find a dedicated xcore-forum, so i posted the question here.

Thanks in advance
Re: createEcoreAnnotations is not generated from .xcore file [message #1770378 is a reply to message #1770372] Thu, 10 August 2017 14:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
It looks like a bug in org.eclipse.emf.ecore.xcore.util.XcoreEcoreBuilder.handleAnnotations(XModelElement, EModelElement). Certainly I expect @Ecore annotations that specify an attribute by name to update that attribute value in the Ecore model itself, but any other annotation detail should be passed through to become a real EAnnotation. In particular, the end of that method should look like this:
        // Add it if it's not an Ecore annotation or if it is an Ecore annotation but isn't empty.
        if (eClass == null || !details.isEmpty())
        {
          eAnnotations.add(eAnnotation);
          deferredInitializers.add(eAnnotation);
        }
instead of like this:
        if (eClass == null || !eAnnotations.isEmpty())
        {
          eAnnotations.add(eAnnotation);
          deferredInitializers.add(eAnnotation);
        }
I.e., it should test for the details being empty not the overall list of annotations. Please open a Bugzilla. Note I think you can work around this by putting your second @Ecore annotation to be after then @GenModel annotation.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: createEcoreAnnotations is not generated from .xcore file [message #1770735 is a reply to message #1770378] Wed, 16 August 2017 15:38 Go to previous messageGo to next message
Stefan Milchram is currently offline Stefan MilchramFriend
Messages: 33
Registered: September 2012
Member
Ed Merks wrote on Thu, 10 August 2017 10:14
Note I think you can work around this by putting your second @Ecore annotation to be after then @GenModel annotation.

Putting the @Ecore annotation after @GenModel works.
I will create the Bugzilla report tomorrow, and link it here.

Thank you very much for your help Ed!
Re: createEcoreAnnotations is not generated from .xcore file [message #1770743 is a reply to message #1770735] Wed, 16 August 2017 16:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
I started working on EMF 2.14 development this week so I opened https://bugs.eclipse.org/bugs/show_bug.cgi?id=520945 and committed the fix already.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to strip invalid XML characters when saving Resource
Next Topic:Modeling Symposium @ EclipseCon Europe 2017
Goto Forum:
  


Current Time: Sat Apr 20 00:21:14 GMT 2024

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

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

Back to the top