Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EClassifier ordering in generated EPackages
EClassifier ordering in generated EPackages [message #1085306] Mon, 12 August 2013 18:42 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
Hi,

I noticed that the EClassifiers in a generated jave EPackage are ordered
differently than in the Ecore model from which the EPackage was
generated, it seems that EEnums always come last? Just out of curiosity,
is there a "real" reason behind that, or is it just a matter of
organization?

If I read EClassifers through the EPackages Genpackage, will the
ordering be consistent? (I noticed in the Genmodel editor, the Enums are
on the bottom too...)


Thanks,
Felix
Re: EClassifier ordering in generated EPackages [message #1085598 is a reply to message #1085306] Tue, 13 August 2013 05:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Felix,

Comments below.

On 12/08/2013 8:42 PM, Felix Dorner wrote:
> Hi,
>
> I noticed that the EClassifiers in a generated jave EPackage are
> ordered differently than in the Ecore model from which the EPackage
> was generated, it seems that EEnums always come last?
Yes.
> Just out of curiosity, is there a "real" reason behind that, or is it
> just a matter of organization?
More of an organizational thing, e.g., from this in GenPackageImpl, and
because the GenPackage has separate containment features for GenClass,
GenDataType, and GenEnum.

public List<GenClassifier> getOrderedGenClassifiers()
{
List<GenClassifier> result = new
ArrayList<GenClassifier>(getOrderedGenClasses());
result.addAll(getGenEnums());
result.addAll(getGenDataTypes());
return result;
}
>
> If I read EClassifers through the EPackages Genpackage, will the
> ordering be consistent? (I noticed in the Genmodel editor, the Enums
> are on the bottom too...)
Via the getOrderedGenClassifiers, yes.
>
>
> Thanks,
> Felix


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EClassifier ordering in generated EPackages [message #1085723 is a reply to message #1085598] Tue, 13 August 2013 09:18 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
Hi,

looks much better now.

>> If I read EClassifers through the EPackages Genpackage, will the
>> ordering be consistent? (I noticed in the Genmodel editor, the Enums
>> are on the bottom too...)
> Via the getOrderedGenClassifiers, yes.

I do this and still there's some differences.

Since I have no idea where to look for the code generator/templates I
checked out GenPackageItemProvider where I observe the same ordering
inconsistencies:

getChildrenFeatures():
childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_NestedGenPackages());

childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenClasses());
childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenEnums());

childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenDataTypes());

I assume that the code generator uses something similar, and not
getOrderedGenClasses()/getOrderedGenClassifiers()), this would perfectly
explain my observations.


Felix
Re: EClassifier ordering in generated EPackages [message #1085804 is a reply to message #1085723] Tue, 13 August 2013 11:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Felix,

Comments below.

On 13/08/2013 11:18 AM, Felix Dorner wrote:
> Hi,
>
> looks much better now.
>
>>> If I read EClassifers through the EPackages Genpackage, will the
>>> ordering be consistent? (I noticed in the Genmodel editor, the Enums
>>> are on the bottom too...)
>> Via the getOrderedGenClassifiers, yes.
>
> I do this and still there's some differences.
>
> Since I have no idea where to look for the code generator/templates I
> checked out GenPackageItemProvider where I observe the same ordering
> inconsistencies:
>
> getChildrenFeatures():
> childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_NestedGenPackages());
>
> childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenClasses());
> childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenEnums());
> childrenFeatures.add(GenModelPackage.eINSTANCE.getGenPackage_GenDataTypes());
>
That code is hand modified. Otherwise the feature order in the EClass
would be used.
>
> I assume that the code generator uses something similar, and not
> getOrderedGenClasses()/getOrderedGenClassifiers()), this would
> perfectly explain my observations.
I'm not sure what else you're observing...
>
>
> Felix
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EClassifier ordering in generated EPackages [message #1085982 is a reply to message #1085804] Tue, 13 August 2013 16:23 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
Hi,
>>
>> I assume that the code generator uses something similar, and not
>> getOrderedGenClasses()/getOrderedGenClassifiers()), this would
>> perfectly explain my observations.
> I'm not sure what else you're observing...

If you create a package like this:

MyPackage
- BClass extends AClass
- AClass

And generate code for this, then MyPackage.eInstance.getEClassifiers()
returns a list [B, A], whereas myGenPackage.getOrderedGenClassifiers()
returns [A, B] because it reorders the EClasses so that subclasses come
after their superclasses.

Felix.
Re: EClassifier ordering in generated EPackages [message #1086025 is a reply to message #1085982] Tue, 13 August 2013 17:54 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Felix,

Comments below.

On 13/08/2013 6:23 PM, Felix Dorner wrote:
> Hi,
>>>
>>> I assume that the code generator uses something similar, and not
>>> getOrderedGenClasses()/getOrderedGenClassifiers()), this would
>>> perfectly explain my observations.
>> I'm not sure what else you're observing...
>
> If you create a package like this:
>
> MyPackage
> - BClass extends AClass
> - AClass
>
> And generate code for this, then MyPackage.eInstance.getEClassifiers()
> returns a list [B, A], whereas myGenPackage.getOrderedGenClassifiers()
> returns [A, B] because it reorders the EClasses so that subclasses
> come after their superclasses.
Yes, in PackageClass.javajet, the package contents are created like
this, so the order will be their order in GenPackage.getGenClasses(), in
is reconciled to be ordered like they are in the EPackage.getEClassifiers.

public void createPackageContents()
{
if (isCreated) return;
isCreated = true;
<%if (!genPackage.getGenClasses().isEmpty()) {%>

// Create classes and their features
<%for (Iterator<GenClass>
c=genPackage.getGenClasses().iterator(); c.hasNext();) { GenClass
genClass = c.next();%>

But GenPackage segregates GenClass, GenEnum, and GenDataType into
separate containment features and that will be noticed in the generated
package contents' order.
>
> Felix.
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:XCore : opposite to several fields
Next Topic:EMF: mixed complex type generates invalid XML
Goto Forum:
  


Current Time: Fri Apr 19 08:25:06 GMT 2024

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

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

Back to the top