Bug 478902 - An EPackage can ends up being ignored by the interpreter
Summary: An EPackage can ends up being ignored by the interpreter
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1.0   Edit
Assignee: Cedric Brun CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2015-10-02 08:51 EDT by Cedric Brun CLA
Modified: 2015-10-16 09:09 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cedric Brun CLA 2015-10-02 08:51:57 EDT
I found this issue while investigating tests failures of org.eclipse.sirius.tests.unit.table.unit.export.ExportToCsvTest after migrating it to AQL.
Issue : some metamodels are "unknown" by a specific interpreter whereas it is explicitely referenced in the .odesign in such specific conditions.
Symptoms : failures to parse or evaluate

Analysis : 

in DViewOperations.updateSelectedViewpointsData(IProgressMonitor) the metamodels are gathered and then passed to the model accessor 
and to the interpreters for initialization : 

            Collection<MetamodelDescriptor> metamodels = MetamodelDescriptorManager.INSTANCE.provides(getSelectedViewpoints(false));
            if (accessor != null) {
                accessor.activateMetamodels(metamodels);
            }
            session.getInterpreter().activateMetamodels(metamodels);

Accessor first and then the interpreter. Initializing the ModelAccessor ends up calling 
EcoreIntrinsicExtender.updateMetamodels(Collection<? extends MetamodelDescriptor>) which will diff the given list of metamodel descriptors with the one which has been previously registered
BUT the diff is done by modifying the list passed as a parameters. Because of this some descriptors might have been removed when the interpreter.activiateMetamodels() method is called.

You might wonder : how come we have not seen this problem before ? First this might explain some "hard to reproduce" problems with the MTL interpreter not knowing some metamodels. These 
are typically hard to reproduce as the bug will only manifest itself depending on the previously selected viewpoints.
Second : up until the fix for Bug 474807 AQL would not drop the AST's when the metamodel would change, hence would have been very likely to keep a valid one even if the next "activateMetamdels" call would not 
contain the needed EPackage instance.

To validate this ticket : just make sure ExportToCsvTest, migrated to AQL, is green.
Comment 1 Eclipse Genie CLA 2015-10-02 08:55:38 EDT
New Gerrit change created: https://git.eclipse.org/r/57288
Comment 3 Maxime Porhel CLA 2015-10-05 05:29:23 EDT
Cédric could you provide a simple test case or scenario for the validation of the correction ?
Comment 4 Cedric Brun CLA 2015-10-05 05:39:45 EDT
(In reply to Maxime Porhel from comment #3)
> Cédric could you provide a simple test case or scenario for the validation
> of the correction ?

org.eclipse.sirius.tests.unit.table.unit.export.ExportToCsvTest once migrated to AQL (which it is now that https://git.eclipse.org/r/#/c/57274/ is merged) reveal this issue by failling with a table which has no elements whereas it should have lines for all the classes.

That's the simplest reproduction case. To reproduce it "by hand" you would need to 
1°) initialize a modeling project with an UML model for instance and a Viewpoint not using AQL at all but refering to the UML metamodel
2°) enable a Viewpoint with a reference to the same metamodel but which uses AQL with expressions leveraging type literals (self.eAllContents(uml::Class) for instance), these expression will fail at runtime.
Comment 5 Cedric Brun CLA 2015-10-05 07:56:07 EDT
Fixed for 3.1.0
Comment 6 Florian Barbin CLA 2015-10-09 11:44:54 EDT
The test passed on Sirius master
Comment 7 Pierre-Charles David CLA 2015-10-16 09:09:55 EDT
Available in Sirius 3.1.0.