Bug 547162 - Xtend generated files should not be automatically added to an aird file
Summary: Xtend generated files should not be automatically added to an aird file
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 6.2.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 560093
  Show dependency tree
 
Reported: 2019-05-10 08:49 EDT by Rolf Theunissen CLA
Modified: 2020-02-20 08:51 EST (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 Rolf Theunissen CLA 2019-05-10 08:49:36 EDT
1. Create a new (EMF) project
2. Create a aird with representations
3. Create a Xtend class

Result:
Files generated by Xtend are added as semantic resource to the aird file.

Adding a nature to a project should not trigger these kind of automatic behavior. If needed, please make a builder for this behavior that can be disabled.
Comment 1 Pierre-Charles David CLA 2019-05-10 09:33:58 EDT
I assume when you say "Create a new (EMF) project" you mean a Sirius "Modeling" project?

This is the expected behavior of the "Modeling" projects [1]: any file found inside which can be loaded as an EMF model is automatically added to the Sirius session. This automatic behavior is what most users want, including some which use Xtext-based models, so in general we can not decide to ignore Xtend files a special cases.

I see two possibilities:
* the simplest is not to use the "Modeling" nature on your project, and use the "Legacy mode", see [2] (despite its name, it is not planned to be removed). It does not require changing the nature of the project to "Modeling", but in exchange you have to manage the lifecycle and dependencies of the Sirius session explicitly.
* much more involved, you could use the org.eclipse.sirius.resourceStrategy extension point to provide you own implementation of ResourceStrategy.isPotentialSemanticResource(URI) and decide to ignore Xtend files as potential semantic resources for the Sirius session.

[1] https://www.eclipse.org/sirius/doc/user/general/Modeling%20Project.html
[2] https://www.eclipse.org/sirius/doc/user/general/Modeling%20Project.html#LegacyMode
Comment 2 Rolf Theunissen CLA 2019-05-10 10:17:36 EDT
(In reply to Pierre-Charles David from comment #1)
> I assume when you say "Create a new (EMF) project" you mean a Sirius
> "Modeling" project?

Yes mean a Sirius "Modeling" project. Nowadays, a EMF project is a Sirius Modeling project too, when adding diagrams.

> This is the expected behavior of the "Modeling" projects [1]: any file found
> inside which can be loaded as an EMF model is automatically added to the
> Sirius session. This automatic behavior is what most users want, including
> some which use Xtext-based models, so in general we can not decide to ignore
> Xtend files a special cases.

Not only the Xtend files them self are included, but also generated ".<filename>.java._trace" files are included in the aird files. In many cases, this results to changed aird files on checkout from git. Files should not change on check out.

This makes me wonder, should hidden files be automatically included?

> I see two possibilities:
> * the simplest is not to use the "Modeling" nature on your project, and use
> the "Legacy mode", see [2] (despite its name, it is not planned to be
> removed). It does not require changing the nature of the project to
> "Modeling", but in exchange you have to manage the lifecycle and
> dependencies of the Sirius session explicitly.

I will check this one, seems to be less magic than the default one.

> * much more involved, you could use the org.eclipse.sirius.resourceStrategy
> extension point to provide you own implementation of
> ResourceStrategy.isPotentialSemanticResource(URI) and decide to ignore Xtend
> files as potential semantic resources for the Sirius session.

A default ResourceStrategy that allows some configuration to (project specific) filters some files would be an improvement. This would also allow to filter hidden resources by default too.

> [1] https://www.eclipse.org/sirius/doc/user/general/Modeling%20Project.html
> [2]
> https://www.eclipse.org/sirius/doc/user/general/Modeling%20Project.
> html#LegacyMode
Comment 3 Rolf Theunissen CLA 2019-07-24 04:51:10 EDT
The inclusion of Xtend files in the aird, and how Sirius handles resources results in another horrible side effect: Xtend files get changed by Sirius.

We had some perfectly valid Xtend files (no compile errors), that could somehow not be parsed by Sirius. The error log showed errors that some Xtext reference could not be resolved. After that, the Xtend files were changed and some function calls were replaced by others. This results in compile errors in the Xtend files.
These files were checked in to Git, but trying to revert them was of no use. As soon as the files were reverted, Sirius kicked in and insisted on breaking the Xtend files.
After removing the Xtend files from the aird file, the files could be reverted and were not broken anymore.

Another issue, less serious but still very annoying, is that sometimes the line-endings are changed to the platform default, instead of having the Git and Eclipse preferred settings.