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

Bug 350894

Summary: [editor] cannot refer to external type in oclIsKindOf
Product: [Modeling] OCL Reporter: Ed Willink <ed>
Component: CoreAssignee: OCL Inbox <mdt-ocl-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2.0   
Target Milestone: M1   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Bug Depends on:    
Bug Blocks: 353793    

Description Ed Willink CLA 2011-07-01 01:43:31 EDT
With the Indigo OclInEcore editor:

import aa : 'a.ecore#/';

package b : bb = 'bbb'
{
	class B1
	{
		property ref : aa::A1[1] { ordered };
	}
	class B2 extends B1
	{
		invariant : ref.oclIsKindOf(aa::A2);
	}
	class Root
	{
		property as : aa::A1[*] { composes };
		property ab : B1[*] { composes };
	}
}

fails to save and reload, since the oclIsKindOf is saved in textual form in the Ecore and that has no corresponding import statement. On reload, the package qualification is lost.
Comment 1 Ed Willink CLA 2011-08-04 01:49:13 EDT
A similar repro for ImportTests not using Ecore files at all.

public void testImport_OCLinEcore_Bug353793() throws Exception {
	String testFileA =
		"package packA : packA = 'packA'{\n" +
		"    class A;\n" +
		"}\n";
	createFile("TBug353793A.oclinecore", testFileA);
	String testFileB =
		"import packA : 'TBug353793A.oclinecore';\n" +
		"package packB : packB = 'packB'\n" +
			"{\n" +
		"    class B extends packA::A;\n" +
		"}\n";
	doLoadFromString("Bug353793B.oclinecore", testFileB);
}	

fails on "Unresolved type 'A'" in "packA::A".
Comment 2 Ed Willink CLA 2011-08-08 01:14:14 EDT
(In reply to comment #1)
> A similar repro for ImportTests not using Ecore files at all.
> 
> public void testImport_OCLinEcore_Bug353793() throws Exception {

This is nothing to do with this problem. Bug 353793 is solved by itself.

(In reply to comment #0)
> On reload, the package qualification is lost.

This is initially a problem with the PrettyPrinter that fails to generate qualified names corrected. 

Once fixed the serialisation is ref.oclIsKindOf(_'xxxx.ecore'::aa::A2) where xxxx is the source file name segment that named the root package. This avoids the loss but is not readable.

Option 1: replace _'xxxx.ecore' by an alias that maps to a URI and is propagated as an additional EPackage EAnnotation. This requires an additional EAnnotation to be documented and handled. It also requires reification during Ecore2Pivot even though the OpaqueExpression is still opaque.

Option 2: redefine _'xxxx.ecore' as a URI, and allow the use of URIs as the first segment of a qualified name. No EAnnotations, no aliases to keep unique, a potentially useful facility. User is required to keep URIs unique.
Comment 3 Ed Willink CLA 2011-08-09 02:52:14 EDT
PrettyPrinter qualified names fixed.

First name in qualified name now resolved as URI relative to primary document if nothing else matches.

Pushed to master.
Comment 4 Ed Willink CLA 2013-05-20 11:37:39 EDT
CLOSED after a year in the RESOLVED state.