Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323741 - [editor] missing semantic validation allows NPE when property/attribute interchanged
Summary: [editor] missing semantic validation allows NPE when property/attribute inter...
Status: CLOSED FIXED
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-26 14:27 EDT by Joern E. CLA
Modified: 2011-05-27 03:13 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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