Community
Participate
Working Groups
Build Identifier: 20100617-1415 Texo 0.1.0-201008031709 Enums are not generated in the right source location when using annotationsmodel. The java files contain the right package definition from the annotionsmodel, but they are generated in the default src location and not at the location of the annotionsmodel. Further there are some wrong full qualified classes generated into the model factory. See attached ecore and annotionsmodel. Reproducible: Always
Created attachment 179014 [details] Sample ecore
Created attachment 179015 [details] Sample Annotionsmodel
Hi Mark, I reacted in the newsgroup for completeness: Hi Mark, I checked the annotations model and there are some strange in there. For example the Address eclass annotation has this eattribute: qualifiedClassName="texo.test.Address" however, the Person eclass has an ereference annotation for address with this eattribute: type="test.Address" This is the reason that there are compile errors in the generated code for the Person, as it refers to a type which does not get generated. It is best to have a quite empty annotationsmodel (so only annotate what you want to change, the rest is automatically generated). So to solve this I would remove all the ereference annotations. To be sure, did you manually change the annotations model? The reason that the ContactType enum is generated in a separate package is because its annotation has this eattribute set: qualifiedClassName="test.ContactType" so therefore it ends up in the test package and not in the texo.test package. gr. Martin
(In reply to comment #3) > Hi Mark, > I reacted in the newsgroup for completeness: > > Hi Mark, > I checked the annotations model and there are some strange in there. For > example the Address eclass annotation has this eattribute: > qualifiedClassName="texo.test.Address" > however, the Person eclass has an ereference annotation for address with this > eattribute: > type="test.Address" > This is the reason that there are compile errors in the generated code for the > Person, as it refers to a type which does not get generated. It is best to have > a quite empty annotationsmodel (so only annotate what you want to change, the > rest is automatically generated). I just want to create the texo generated stuff in a certain package. My intention was to get something like the Base Package attribute in the genmodel. > To be sure, did you manually change the annotations model? I used the default editor and properties view that open for the annotationsmodel. > The reason that the ContactType enum is generated in a separate package is > because its annotation has this eattribute set: > qualifiedClassName="test.ContactType" I have seen this. But the editor/properties view only allowes the attributes instanceClassName. I changed this to texo.test.ContactType. There is no proerty in the code but the properties view doesn't show this attribute. Regards, Mark
Hi Martin, what about extending the texo-annotations-model.ecore like this: <eClassifiers xsi:type="ecore:EClass" name="AnnotatedModel"> <eStructuralFeatures xsi:type="ecore:EReference" name="annotatedEPackages" upperBound="-1" eType="#//AnnotatedEPackage" containment="true" eOpposite="#//AnnotatedEPackage/annotatedModel"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="basePackage" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> </eClassifiers> If your epackage is called 'test' and the basePackage is 'org.eclipse.texo', then all generate code should have the base: 'org.eclipse.texo.test'. Regards, Mark
Hi Mark, Yes the packagepath eattribute in a way does this (although it is the complete packagename, so the epackagename won't be appended). I checked and with me the annotationsmodel editor allows you to set the qualifiedclassname for an eclass. So the intended usage is: * set the packagepath in an epackage annotation * override any specific classname in the qualifiedclassname eattribute of the eclass annotation, these classes are then generated in another package than the packagepath set on epackage level. gr. Martin
Created attachment 179039 [details] annotationsmodel with only an epackage annotation
(In reply to comment #6) > Hi Mark, > Yes the packagepath eattribute in a way does this (although it is the complete > packagename, so the epackagename won't be appended). > > I checked and with me the annotationsmodel editor allows you to set the > qualifiedclassname for an eclass. You are right, but not for an Enum! It only shows the Instance Class Name. > So the intended usage is: > * set the packagepath in an epackage annotation > * override any specific classname in the qualifiedclassname eattribute of the > eclass annotation, these classes are then generated in another package than the > packagepath set on epackage level. I got it, now it worked for the classes, package and factory. The enum is still in the wrong package. Additionally I deleted the reference annotations. Mark
Hi Mark, Ha good point, I will change this for the enum. Strange that the enum is still in the wrong package. Did you also remove the enum annotation? gr. Martin
(In reply to comment #9) > Hi Mark, > Ha good point, I will change this for the enum. > > Strange that the enum is still in the wrong package. Did you also remove the > enum annotation? > > gr. Martin I got it work. I changed the AnnotatedEENum attributes by hand: instanceClassName, objectClassName and qualifiedClassName to the new path and it worked. The qualifiedClassName seems to generate the enum in the right src folder. The objectClassName seems to be important for the ModelFactory generation. The instanceClassName is important to generate the right references (in my Contact class and the factory) <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEEnum"> <eEnum href="test.ecore#//ContactType"/> <eEnumAnnotations xsi:type="modelannotations:EEnumModelGenAnnotation" name="ContactType" qualifiedClassName="texo.test.ContactType" simpleClassName="ContactType" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0" instanceClassName="texo.test.ContactType" objectClassName="texo.test.ContactType" enum="true" dateType="false" automaticStringConversion="false" itemType="java.lang.Object"/> <annotatedEEnumLiterals> <eEnumLiteral href="test.ecore#//ContactType/PHONE"/> </annotatedEEnumLiterals> <annotatedEEnumLiterals> <eEnumLiteral href="test.ecore#//ContactType/EMAIL"/> </annotatedEEnumLiterals> </annotatedEClassifiers> Regards, Mark
But why don't you just remove the complete enum annotation? That should also work. gr. Martin
(In reply to comment #11) > But why don't you just remove the complete enum annotation? That should also > work. Because sometimes, the trees are so close, that you doesn't see them ;-) (in German: Man sieht den Wald vor lauter Bäumen nicht) I removed the enum annotation, all reference annotations, the attribute annotation the refers to the enum, changed the 'package path' in the epackage annotation to my needs and set the qualified class name in the eclass annotations. Everything is fine. The generated code is without any error! Only the classifier id's are still wrong ;-) Thank you very much. You can close the bug, I think. Regards, Mark
Hmm, the classifier id is correctly generated with me... Did you put generatednot in the ModelPackage file maybe? I am committing some changes to the enum generation, after that (and a successfull build) I will close the issue. gr. Martin
(In reply to comment #13) > Hmm, the classifier id is correctly generated with me... Did you put > generatednot in the ModelPackage file maybe? > > I am committing some changes to the enum generation, after that (and a > successfull build) I will close the issue. > > gr. Martin I use Texo 0.1.0-201008031709 Even if I generate the model from the ecore without any annotationsmodel, I get this classifier problem. I tried various setups and found something in the ecore : <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test" nsURI="http://test" nsPrefix="test"> <eClassifiers xsi:type="ecore:EClass" name="Person"> ... <eClassifiers xsi:type="ecore:EEnum" name="ContactType"> <eLiterals name="ONE" value="0"/> <eLiterals name="TWO" value="1"/> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="Contact"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ContactType"/> </eClassifiers> </ecore:EPackage> causes the problem at me, where: <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test" nsURI="http://test" nsPrefix="test"> ... <eClassifiers xsi:type="ecore:EClass" name="Contact"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ContactType"/> </eClassifiers> <eClassifiers xsi:type="ecore:EEnum" name="ContactType"> <eLiterals name="ONE" value="0"/> <eLiterals name="TWO" value="1"/> </eClassifiers> </ecore:EPackage> makes no problem. No idea why. But another try with a new ecore example failed with the same exception. No matter on which position the enum is defined. So I couldn't verify this problem. Regards, Mark
I published a new build a few mins back. Closing this issue. The classifier problem remains strange, I can't reproduce it myself. Let's discuss this issue further at the other bugzilla you entered. gr. Martin