Community
Participate
Working Groups
Build Identifier: 20100617-1415 In the following template [template public generateBad(genModel : GenModel)] [genModel.genPackages.ecorePackage.name->first()/] [/template] the ecorePackage reference is seen as having a null type and nothing can be done with it. Executing the template results in the following output : org.eclipse.emf.ecore.impl.DynamicEObjectImpl@161d10f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@e441ee (name: OclInvalid_Class) (instanceClassName: null) (abstract: false, interface: false)) While executing the same template with this text instead [genModel.genPackages.ecorePackage->first()/] outputs the expected result : org.eclipse.emf.ecore.impl.EPackageImpl@420177 (name: kparser) (nsURI: http://www.obeo.fr/knowledge/kparser/v1.0, nsPrefix: kparser) There's a work around however. Use a query to get the first package and call the query just like it is done in the generateGood template in the attached example. Reproducible: Always Steps to Reproduce: 1.put the template attached to this bug in an Acceleo project 2.run the generation 3.open up the result.
Created attachment 178792 [details] Acceleo template that illustrates the bug and allows reproducing it
if "[genModel.genPackages.ecorePackage->first()/]" generate the same thing for me: "org.eclipse.emf.ecore.impl.EPackageImpl@7be2149c (name: scala) (nsURI: http://github.com/sbegaudeau/acceleo/scalametamodel/2011/01, nsPrefix: scala)" And "[genModel.genPackages.ecorePackage.name->first()/]" generate what I am expecting: "scala". I tried both ways: - [genModel.genPackages.ecorePackage.name->first()/] and - [getFirstPackage(genModel).name/] - [query public getFirstPackage(genModel : GenModel) : EPackage = genModel.genPackages.ecorePackage->first()/] And the result is the same. since both are doing the same thing. Are you sure, that you did not change your metamodel between the execution ? Since your metamodel seems to have a valid name "kparser", I don't see why this: "[genModel.genPackages.ecorePackage.name->first()/]" would not work expect in a query. I'll close this bug for now, if you can reproduce it reopen it.