eclipse-epsilon / epsilon

Epsilon is a family of Java-based scripting languages for automating common model-based software engineering tasks, such as code generation, model-to-model transformation and model validation, that work out of the box with EMF (including Xtext and Sirius), UML (including Cameo/MagicDraw), Simulink, XML and other types of models.
https://eclipse.org/epsilon
Eclipse Public License 2.0
67 stars 10 forks source link

[EMF] Misleading "ambiguous type" warnings when the same EClass is accessible through multiple paths #118

Closed agarciadom closed 2 months ago

agarciadom commented 2 months ago

If a module is configured with multiple EMF EPackages, where some of them are subpackages of others, trying to access one of the subpackages' types (e.g. if we list the Sirius description package + one of its subpackages) will produce a warning of this form:

Ambiguous type X: candidates were "X" "X" (picked "X")

While it's true that the reference is somewhat ambiguous due to the multiple paths in which the type can be accessible, there wouldn't actually be a risk of picking the wrong X as all those paths lead to the same exact EClass instance. This is more of a slight misconfiguration from the user, who should have only picked the main EPackage that contains the others. It would be better to change the warning to something like:

The type X is accessible from both "nsURI1" and "nsURI2" (e.g. through sub-package relationships).
It is recommended to only list one of these metamodels in the module configuration.
agarciadom commented 2 months ago

On second thought, it may not be a good idea to raise a warning in this scenario: an Epsilon script running under the default EPackage registry in an Eclipse IDE that had Sirius installed could potentially raise this warning about multiple paths existing for a given type, without there really being any ambiguity.

It may be best to just reduce the EClass candidates to a set, and only report ambiguity if we really had different EClass instances.