Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323741

Summary: [editor] missing semantic validation allows NPE when property/attribute interchanged
Product: [Modeling] OCL Reporter: Joern E. <joern_e>
Component: CoreAssignee: OCL Inbox <mdt-ocl-inbox>
Status: CLOSED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: ed
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Joern E. CLA 2010-08-26 14:27:32 EDT
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
Comment 1 Ed Willink CLA 2010-08-26 16:38:32 EDT
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.
Comment 2 Ed Willink CLA 2011-05-06 07:12:27 EDT
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.
Comment 3 Ed Willink CLA 2011-05-27 03:13:16 EDT
Closing