Bug 436375 - Semantic models not automatically detected when converting into a Modeling Project
Summary: Semantic models not automatically detected when converting into a Modeling Pr...
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 1.0.0M7   Edit
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: 1.0.1   Edit
Assignee: Maxime Porhel CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
: 442763 (view as bug list)
Depends on:
Blocks: 439791
  Show dependency tree
 
Reported: 2014-06-02 10:39 EDT by Pierre-Charles David CLA
Modified: 2015-05-20 07:55 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 Pierre-Charles David CLA 2014-06-02 10:39:27 EDT
This looks like a regression introduced after M6.

Steps to reproduce, with Sirius installed:
1. Go to a non-Sirius perspective (e.g. PDE).
2. Create a new non-Modeling project (e.g. a plug-in project).
3. Inside the new project, create a sub-folder and create a new Ecore file inside of it.
4. Convert the project into a modeling project.
5. Go to the "Modeling" perspective, and expand the project. The ecore file should be loaded and "expandable", as it should have been detected as a semantic model of the session. Works with Sirius 0.9.0 and 1.0.0M6, fails with 1.0.0rc2.

The regression might be related to the changes made for https://bugs.eclipse.org/bugs/show_bug.cgi?id=430263 on the way we auto-detect semantic models.
Comment 1 Pierre-Charles David CLA 2014-06-02 10:40:56 EDT
Note that an easy workaround is to explicitly add the semantic models to the session using eh "Project Dependencies", so this does not need to be fixed for 1.0.0.
Comment 2 Maxime Porhel CLA 2014-06-11 05:50:56 EDT
In ModelingProjectManagerImpl.doAddModelingNature(), the getSession call returns null (l339):

>  if (optionalModelingProject.get().getSession() != null) {
>      // add semantic resources if already existing in the project
>      addSemanticResources(project, ..
>  }

So it does not look for existing semantic resources.

org.eclipse.sirius.business.api.modelingproject.ModelingProject.getMainRepresentationsFileURI(IProgressMonitor) is called in getSession() , but we do not force the computation, and mainRepresentationUri is still null as it has not been computed yet. 

During the add of the modeling nature, we should explicitely compute the main representationURi, it might be done in org.eclipse.sirius.ui.tools.internal.views.common.modelingproject.manager.ModelingProjectManagerImpl.createLocalRepresentationsFile(IProject, IProgressMonitor) juste after the session creation operation.

I think this previously worked because of a listener, adapter, or some asynchronous initialization of the project. But the safe way is to do it explicitely when the ModelingProjectManagerImpl creates the main aird.
Comment 3 Maxime Porhel CLA 2014-07-17 04:23:43 EDT
I confirm my previous comment and analysis. 

In the current use case, when we create a new representation file, the ModelingProject is set as invalid and has no mainRepresentationURI, we known we have to compute it.

Note that if an empty representation file is in the project, when use the convert action, all semantic resources are well added.
Comment 4 Maxime Porhel CLA 2014-07-17 04:53:34 EDT
See https://git.eclipse.org/r/#/c/30021/
Comment 5 Maxime Porhel CLA 2014-07-24 11:13:09 EDT
Corrected by commit 9bf1a1e4b917d04e2c4f2222a8b59fcaccfa0874
Comment 6 Maxime Porhel CLA 2014-08-28 07:43:16 EDT
*** Bug 442763 has been marked as a duplicate of this bug. ***
Comment 7 Pierre-Charles David CLA 2015-05-20 07:55:31 EDT
Available in Sirius 1.0.1.