osate / osate2

Open Source AADL2 Tool Environment
http://osate.org
Eclipse Public License 2.0
39 stars 8 forks source link

References to AADL model elements from models of other meta-models are shifted when elements are deleted / added in the AADL declarative model. #247

Closed dblouin closed 11 years ago

dblouin commented 11 years ago

Other models such as requirements from the requirements annex language need to refer to AADL model elements from the declarative model. In the actual state, the references are created by indexing the elements according to their position in the file (the default EMF reference mechanism is used). The problem is that when AADL model elements are created or deleted, the references are shifted and requirements do not refer to the proper element anymore. A similar problem occurs with the instance model that refers to types in the declarative model.

Following a discussion with Peter, a simple solution consists of using the AADL symbolic names (qualified names) for reference. This can be easily achieved by providing a custom fragement provider class to XText, which is declared in the runtime module class of the OSATE Xtext plugin.

There was already a class named Aadl2QualifiedNameFragmentProvider in the OSATE Xtext plugin, but it required some fixes. I have fixed it and used it and it fixes the reference problem. However, it also required modifying the PublicPackageSection class that was returning the same name as the containing package (the getName() method was overriden to return the name of the parent package). I took the same approach as the private package section, which composed its name from the package name concatenated with the "_private" suffix. This was required because otherwise, both the package and public package section have the same name, which was causing problems in the references and in the outline view for instance. As mentioned by Peter, we still have a problem with packages whose public and private parts are spread in distinct files with this solution, but at the moment, OSATE does not seem to handle this feature.

If you agree on this fix, I can submit the patch we are using.

reteprelief commented 11 years ago

Hi Dominique,

This fix sound reasonable. Please send the patch. We will then need to check to make sure the way Xtext records global references in a global index still works for the lookup. If you do F3 in the text editor it will bring up a dialog box showing all identifiers that are globally accessible (across files/packages/property sets.

Regarding my comment about separate package files one with the public part and the other with the private part: Symbolic references do not identify the root object, i.e., the package. Instead the first level object is identified. In our case the name of the package was returned for both the public and private section, thus, it looked like the same package exists twice in the global namespace.

Peter

From: dblouin [mailto:notifications@github.com] Sent: Wednesday, June 26, 2013 5:32 AM To: osate/osate2-core Subject: [osate2-core] References to AADL model elements from models of other meta-models are shifted when elements are deleted / added in the AADL declarative model. (#247)

Other models such as requirements from the requirements annex language need to refer to AADL model elements from the declarative model. In the actual state, the references are created by indexing the elements according to their position in the file (the default EMF reference mechanism is used). The problem is that when AADL model elements are created or deleted, the references are shifted and requirements do not refer to the proper element anymore. A similar problem occurs with the instance model that refers to types in the declarative model.

Following a discussion with Peter, a simple solution consists of using the AADL symbolic names (qualified names) for reference. This can be easily achieved by providing a custom fragement provider class to XText, which is declared in the runtime module class of the OSATE Xtext plugin.

There was already a class named Aadl2QualifiedNameFragmentProvider in the OSATE Xtext plugin, but it required some fixes. I have fixed it and used it and it fixes the reference problem. However, it also required modifying the PublicPackageSection class that was returning the same name as the containing package (the getName() method was overriden to return the name of the parent package). I took the same approach as the private package section, which composed its name from the package name concatenated with the "_private" suffix. This was required because otherwise, both the package and public package section have the same name, which was causing problems in the references and in the outline view for instance. As mentioned by Peter, we still have a problem with packages whose public and private parts are spread in distinct files with this solution, but at the moment, OSATE does not seem to handle this feature.

If you agree on this fix, I can submit the patch we are using.

— Reply to this email directly or view it on GitHubhttps://github.com/osate/osate2-core/issues/247.

juli1 commented 11 years ago

Patch applied.