Community
Participate
Working Groups
Build Identifier: 20100617-1415 Using OCLinEcore to define derived attributes a NPE is thrown for every access of an (normal) attribute given the following model: import ecore : 'http://www.eclipse.org/emf/2002/Ecore#/'; package my : my = 'http://my/1.0' { class Model { property bs : BType[*] { composes }; } class Entity { attribute name : String[?]; } class AType extends Entity { operation referenced() : BType[?] { body: BType.allInstances()->select(references->includes(self))->asSequence()->first(); } attribute referencedAttr : BType[?] { derived,volatile,transient,readonly } { derivation: BType.allInstances()->select(references->includes(self))->asSequence()->first(); } } class BType extends Entity { property references : AType[*] { composes }; } } Reproducible: Always Steps to Reproduce: 1. Copy and paste model in an empty EMF project/file called My.ecore 2. Generate dynamic instance from "Model" in the outline (right click, "Model.xmi") 3. Add "BType" as child 4. Add "AType" as child 5. Change property "name" to "a1" -> NPE 6. Close "Model.xmi" 7. Remove derived attribute from the model 8. Open "Model.xmi" and repeat from 4. -> no NPE
The NPE aruses because a feature has no getEAttributeType since its a reference. Changing Atype.referencedAttr from 'attribute' to 'property' fixes the problem. The bug is therefore that the Xtext editors do not yet have semantic validation.
This problem goes away using the intermediate pivot model for which attributes and referemces are all properties. Unfortunately Bug 344948 prevents the repro being followed. Need to use the Sample Ecore Editor to do Create Dynamic Instance.
Closing