Closed lwrage closed 6 years ago
This is needed for ALISA because the current setup causes problems with name resolution if we have validation methods written in Java.
Contributed AADL files will now utilize the IContainer
mechanism instead of being copied into the workspace. There were many points that needed to be customized in order to fix this bug and I am documenting this process here.
IContainer
The contributed AADL files need to be added to an IContainer
so that they are part of the results returned by the IGlobalScopeProvider
. This is accomplished in the class Aadl2ProjectsStateHelper
which extends from the xtext class WorkspaceProjectsStateHelper
:
initVisibleHandles(String)
ensures that the contributed AADL container is visible from all containers including itself.initContainedURIs(String)
populates the container with the contributed AADL files. This is done by specifying the platform plugin URIs of the AADL files.initHandle(URI)
identifies any contributed AADL file as being a part of the contributed container.The Aadl2ProjectsStateHelper
is bound in Aadl2UiModule
and it is used in Aadl2ProjectsState
. Aadl2ProjectsState
is also bound in Aadl2UiModule
.
This adds the contributed AADL files to the global scope, but they still need to be processed by the xtext builder. This is handled in the class PropertiesToBeBuiltComputerContribution
; specifically in the methods updateProject(ToBeBuilt, IProject, IProgressMonitor)
and updateStorage(ToBeBuilt, IStorage, IProgressMonitor)
The class PropertiesToBeBuiltComputerContribution
is bound in the class PropertiesSharedStateContributingModule
, which itself is contributed via the org.eclipse.xtext.ui.shared.sharedStateContributingModule
extension point in the plugin.xml
file.
See bd711d919574fa0b5e3d91869d2b21645e87b3e1, cd8b4df03989f628becde96468334c6e146c0c31, and 570a1f9d86bf1e391c542bcdb0ae97c6e256d2aa.
IStorage
objects for contributed AADL filesAt this point, the contributed AADL files are in the global scope and they are being built, so they can be used from AADL models in the workspace. However, they cannot yet be opened in an editor. If you Control-Click on a reference to a contributed element, you will see that nothing happens. This is because there are no IStorage
objects being created for the contributed AADL files and an editor requires an IStorage
to display its contents.
I created a custom implementation of IStorage
called ContributedAadlStorage
. Instances of ContributedAadlStorage
are supplied by Aadl2Storage2UriMapper
which is bound in Aadl2UiModule
.
See 5d137cb06a34c49da34b327c65dd2ce7fef45a39.
At this point, hyperlinking to contributed AADL files works as well as hyperlinking from one contributed AADL file to another contributed AADL file. However, hyperlinking within a single contributed AADL file doesn't work. When attempting to do this, the URI of the hyperlink is not a platform plugin URI, but it is instead a platform resource URI. It needs to be a platform plugin URI in order for Aadl2Storage2UriMapper
to provide an instance of ContributedAadlStorage
.
If you look at ResourceForIEditorInputFactory.createResourceFor(IStorage)
, you will notice that it explicitly creates a platform resource URI. This is changed in Aadl2ResourceForEditorInputFactory
which is bound in Aadl2UiModule
. In this class, I simply get the URI from the ContributedAadlStorage
which is already a platform plugin URI.
See 75b7650b635460fa1aca35c89c98c5d2e23adff8.
If you quit OSATE while contributed AADL files are open, those files will not reopen when you relaunch OSATE. This is because there is no IPersistableElement
for the IEditorInput
objects of contributed AADL files. If you look at XtextReadonlyEditorInput.getPersistable()
, you will see that it simply returns null.
This is corrected in the class ContributedAadlEditorInput
which does supply an IPersistableElement
. You will notice that the anonymous IPersistableElement
refers to ContributedAadlEditorInputFactory
. This factory is what restores the editors when OSATE relaunches. It is contributed via the org.eclipse.ui.elementFactories
extension point in the plugin.xml
file. The ContributedAadlEditorInput
class is supplied by Aadl2LanguageSpecificURIEditorOpener
which is bound in Aadl2UiModule
.
See 54a2920cfa952df69f69fcb28bbca908a9ac193d.
At this point, the Mark Occurences functionality doesn't work with contributed AADL files. This is because there is no annotation model for contributed AADL files. This is fixed in Aadl2DocumentProvider
which simply supplies a basic AnnotationModel
for instances of ContributedAadlEditorInput
. Aadl2DocumentProvider
is bound in Aadl2UiModule
.
See 9166c6dd984e36af4fb8af97d0c11bfecc73fff8.
Contributed AADL files must not be in a plugin which also contains a .genmodel
file. For plugins with .genmodel
files, every URI which points to that plugin gets transformed from a platform plugin URI to a platform resource URI when normalized. When this transformation happens to a contributed AADL file and there are Java projects in the workspace, then an exception is thrown.
Any language that needs to be able to contain references to contributed AADL must bind Aadl2ProjectsStateHelper
and Aadl2ProjectsState
in its <LanguageName>UiModule
.
This was already done for the Alisa languages Common and Verify, but I just realized that it needed to be done for ErrorModel as well. It is interesting how this was discovered for annexes. If the binding is not present in the annex language, then references to contributed AADL do not work in the annex if the containing AADL file does not have any core cross references, but it does work if there are at least one core references. This is why this problem went unnoticed until now because I had only tested libraries and subclauses which were in files that also contained core references.
See osate/ErrorModelV2@efa9978b4b005f9331074f99f3ca3df26576399f.
Will this change break existing AADL property set contributions using the aadlcontribution extension point?
No. The org.osate.pluginsupport.aadlcontribution
extension point and its use by plugins remains unchanged. The change is how these property sets are made available to models in the workspace.
Property sets and packages contributed by plugins are currently copied into the workspace. As they should be read-only, they should be shown in the navigator as a virtual project as we did in OSATE1.