Home » Modeling » EMF » EClassifier ordering in generated EPackages
EClassifier ordering in generated EPackages [message #1085306] |
Mon, 12 August 2013 14:42  |
Eclipse User |
|
|
|
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 01:34   |
Eclipse User |
|
|
|
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
|
|
| | | |
Re: EClassifier ordering in generated EPackages [message #1086025 is a reply to message #1085982] |
Tue, 13 August 2013 13:54  |
Eclipse User |
|
|
|
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.
>
>
>
>
|
|
|
Goto Forum:
Current Time: Wed Jul 23 08:52:53 EDT 2025
Powered by FUDForum. Page generated in 0.04993 seconds
|