Bug 583185 - [pivot] Intermittent loading of *.oclas in the wrong (not AS) ResourceSet
Summary: [pivot] Intermittent loading of *.oclas in the wrong (not AS) ResourceSet
Status: NEW
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 583182 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-04-23 06:07 EDT by Ed Willink CLA
Modified: 2024-05-27 07:37 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2024-04-23 06:07:01 EDT
Whike debuigging issues around the Validation Tutotial and Validfity View bad things sometimes hapen and it appears that a contrtibutory factor is the load or a *.oclas in the external rather than AS ResourceSet.

This should never happen for clean OCL usage, but could happen if a user explicitly use e.g the SAmple Ecore Editor to open a *.oclas.

Bug 583043 work creates a repro via testValidate_Validate_completeocl resolving a Complete OCL import proxy badly.
Comment 1 Ed Willink CLA 2024-04-23 06:23:46 EDT
(In reply to Ed Willink from comment #0)
> Bug 583043 work creates a repro via testValidate_Validate_completeocl
> resolving a Complete OCL import proxy badly.

The problem arises during the new code to install the AS from the already parsed CS content.

The Complete OCL ImportCS.referredNamespace has a file:/E:/Development/Workspace/_OCL_ValidateTests__testValidate_Validate_completeocl/Validate.ecore.oclas#/ proxy that is resolved within the ResourceSet of the containing CompleteOCLCSResource for file:/E:/Development/Workspace/_OCL_ValidateTests__testValidate_Validate_completeocl/Validate.ocl

the load therefore goes in the wrong ResourceSet.

a) ?? find a way to use the other ResourceSet

b) ?? find a way to convert the AS proxy to ES.

c) ?? use an ES rather than AS proxy

(This bug is intermittent because *.oclas proxies are rarely resolved.)
Comment 2 Ed Willink CLA 2024-04-23 06:57:52 EDT
*** Bug 582947 has been marked as a duplicate of this bug. ***
Comment 3 Ed Willink CLA 2024-04-23 07:01:58 EDT
The 'bad' proxy only occurs if an unload causes an AS reference to be proxified.

The use of Validate.ecore.oclas as the AS proxy for Validate.oclinecore perhaps contribvutes to extra problems that arise when PivotMetamodelManager.loadResource does an unload.

Bug 582947 identified this problem as a potential issue.
Comment 4 Ed Willink CLA 2024-04-23 07:30:31 EDT
While parsing the ImportCS.referredNMamespace resolves the Xtext proxy:
file:/E:/Development/Workspace/_OCL_ValidateTests__testValidate_Validate_completeocl/Validate.ocl#|0
for the line import 'Validate.oclinecore'

Un loading sets the proxy to 
file:/E:/Development/Workspace/_OCL_ValidateTests__testValidate_Validate_completeocl/Validate.ecore.oclas#/

Maybe we just need unloading to set the proxy to

file:/E:/Development/Workspace/_OCL_ValidateTests__testValidate_Validate_completeocl/Validate.ecore#/

(and of course review why unloading occurred at all.)
Comment 5 Ed Willink CLA 2024-04-25 06:10:58 EDT
(In reply to Ed Willink from comment #1)
> b) ?? find a way to convert the AS proxy to ES.

(In reply to Ed Willink from comment #4)
> Maybe we just need unloading to set the proxy to
> 
> file:/E:/Development/Workspace/
> _OCL_ValidateTests__testValidate_Validate_completeocl/Validate.ecore#/

For #/ it is relatively easy to provide a PivotObjectImpl.eSetProxyURI overload to strip the extra AS extension. But for deeper references the fragment needs conversion from AS to CS and in AS context ElementUtil is not accessible.

But ElementUtil.getCsElement us static and mostly uses ICSI2ASMapping which is a pivot interface. An extra ICSI2ASMapping.getCsElement() method and we could be good, provided the EnvironmentFactory is not already dispose.

BUg 583197 identifies a confusion between Validate.oclinecore.oclas abd Validate.ecore.oclas.
Comment 6 Ed Willink CLA 2024-05-20 07:19:25 EDT
*** Bug 583182 has been marked as a duplicate of this bug. ***
Comment 7 Ed Willink CLA 2024-05-27 07:37:40 EDT
Once we try to support re-use of a CSResource, we open a new can of worms when the externalResourceSet is shared concurrently or sequentially with multiple OCLs.

The EMF aspect of CSResource content can only referen ce the AS for a single OCL.

The extended OCL as of a CSResource content needs EnvironmentFactory-dependent AS references.

-----

Consider the Validation tutorial lifecycle.

Open Sample Ecore Model Editor
Load one or more *.ecore/*.xmi
Load OCL documents
  - these CS resources are user visible so legitimately exist in the Editing domain ResourceSet aided by an OCL

Validate on a worker thread creates a new OCL re-using the external resource set and CS.

Re-use of ecore etc is ok since there is no AS reference.

Re-use of CS is not. We either redesign the CS to avoid AS references -painful and rippling, or force a CS reload.

Perhaps the externalResourceSet re-use, does not re-use the ResourceSet, rather a new ResourceSet re-uses non-CS via the uriResourceMap and clones the CS with unresolved proxies.