Closed Wilson008 closed 2 years ago
The overall model is often structured in many files. There might be a file that only contains datatypes that is then imported into another file that contains the actual architecture. We need to be able to support this kind of import.
Solution:
We need import such as datatypes from other .eatxt files, but all the eatxt files should start from EAXML, all the elements in one eatxt file would be a whole, so importing datatypes actually becomes cross-referencing the elements from other .eatxt files.
So, I think issue #5 (import among multi-files) and issue #4 (cross-reference among files) is actually the same one thing.
To implement those operation across files, we need support getting global scope, that's what the default scope provider does, but auto-completion provided by the default one would be mess (e.g. only show short name or show all the path, or show the incomplete path string, etc.). So that was why we use getFullyQualifiedName to unify how the patterns of referenced elements look like (i.e. full path string wrapped with "" and separated by '.' .
In previous code, we only get local scopes (proposals of local elements) is because we get scopes from rootElement:
EObject rootElement = EcoreUtil2.getRootContainer(context);
however this rootElement is only for the EAXML for the current eatxt file, so what I am thinking is to get all the root elements in the same project. Then combined all the candidates:
List<Referrable> candidates = (List<Referrable>) EcoreUtil2.getAllContentsOfType(rootElement,
targetJavaClass);
so as to get all the scopes we want. Once we get here, these two issues could be closed.
Implement:
First, we get the paths (contain file name) of all the files in the same project (this project contains current *.eatxt file):
Then, we get the root elements of all the files in the same project:
Then we get the candidates from each root element and combine all the candidates together, and finally the scopes searched from those candidates are the global scopes:
Result/Example:
New feature