change builder sorter [message #1649886] |
Wed, 04 March 2015 10:01  |
Eclipse User |
|
|
|
Hello,
i'd like to change the order of the files which need to be built during the xtext build.
My problem is the following:
I defined a grammar for a proprieraty programming language. This language splits the code over three different files (*.msi, *.mgi and *.mti).
The msi file contains all the declarations.
During the xtextBuilder doBuild() process, the building files are collected according to an 'as-is' order.
Instead, i'd like to change the predefine order of file so as to list the msi files first, then the mti files and at last the mgi files.
Is it possible?
Thanks in advance,
Silvia
|
|
|
|
|
|
|
|
|
Re: change builder sorter [message #1650201 is a reply to message #1649969] |
Wed, 04 March 2015 13:17   |
Eclipse User |
|
|
|
Sorry for my delay.
Sure I'l explain you my problem.
My DSL describes assignments of variables where parent containers are on the right side of the var name instead of on the left side:
e.g.:
(file class_A.mti)
class "class_A"
method "method_A_a"
"some_var_B" in "some_obj_B" contained_in "some_obj_C" = "some_val_B1"
end_class
where:
"some_obj_C" has type "class_C" and it is declared in "class_A" (file class_A.msi)
"some_obj_B" has type "class_B" and it is declared in "class_C" (file class_B.msi)
"some_var_B" can have values "some_val_B1", "some_val_B2", "some_val_B3", it is declared in "class_B" (file class_B.msi)
In order to make things work, I customized DefaultDeclarativeQualifiedNameProvider. At this point, each object has a container nested qualified name.
However, "some_var_B" came with a wrong qualified name:
class_A.some_var_B
On the contrary, the right qualified name for that var should be:
class_B.some_var_B
The same thing should be for "some_obj_B": the qualified name should be class_C.some_obj_B instead of class_A.some_obj_B.
The only way I found to provide a right qualified name for "some_var_B" and for "some_obj_B" is to extend LinkingHelper and to customize getCrossRefNodeAsString(...).
At the present day, all the references are correctly linked; every CTRL-click on vars and objs can jump into the code. However, the problem view still shows some errors which should not exist anymore.
Those errors seems to be referred to objects whose msi file has been built later than the mti file that contains the references.
This is why I'd like to try to change the builder order files.
Please, if I'm wrong, suggest me a different way.
Thanks,
Silvia
|
|
|
|
Re: change builder sorter [message #1651466 is a reply to message #1650324] |
Thu, 05 March 2015 05:13   |
Eclipse User |
|
|
|
Hi Christian,
my problem is in DefaultLinkingService.getLinkedObjects(Eobject context, EReference ref, INode node).
1. public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node) throws IllegalNodeException {
2. final EClass requiredType = ref.getEReferenceType();
3. if (requiredType == null)
4. return Collections.<EObject> emptyList();
5.
6. final String crossRefString = getCrossRefNodeAsString(node);
7. if (crossRefString != null && !crossRefString.equals("")) {
8. if (logger.isDebugEnabled()) {
9. logger.debug("before getLinkedObjects: node: '" + crossRefString + "'");
10. }
11. final IScope scope = getScope(context, ref);
12. QualifiedName qualifiedLinkName = qualifiedNameConverter.toQualifiedName(crossRefString);
13. IEObjectDescription eObjectDescription = scope.getSingleElement(qualifiedLinkName);
14. if (logger.isDebugEnabled()) {
15. logger.debug("after getLinkedObjects: node: '" + crossRefString + "' result: " + eObjectDescription);
16. }
17. if (eObjectDescription != null)
18. return Collections.singletonList(eObjectDescription.getEObjectOrProxy());
19. }
20. return Collections.emptyList();
21. }
context contains the assigment ("some_var_B" in "some_obj_B" contained_in "some_obj_C" = "some_val_B1");
ref contains the name 'left_var' of the attribute of the assigment;
node points at the grammar node corresponding to the var "some_var_B";
In scope (line 11) I have the list of qualified name of classes and vars and methods and so on;
crossRefString contains the flat name of my var ("some_var_B");
At line 13, I get a null eObjectDescription because getSingleElement() looks for a flat name var into the scope which contains only qualified names;
the var "some_var_B" is contained in the scope but under the name class_B.some_var_B.
This is the reason why I customized getCrossRefNodeAsString(node); after my customization, crossRefString contains the full dotted name for the var "some_var_B".
I'm not sure this is the right way, but before arriving at this point, I tried to work with scopes (both local and global scopes) but I was not able to reach the goal.
Sorry.
Of course, I can reconsider my way, with a little help )
Silvia
|
|
|
|
|
|
|
|
|
Re: change builder sorter [message #1653701 is a reply to message #1651715] |
Fri, 06 March 2015 05:47  |
Eclipse User |
|
|
|
Hi,
I did the test but it didn't work fine.
There were no errors but the vars referenced to wrong instances.
In my example, I wrote two var with the same name, the first contained in the class where the assignment was, the other in another class.
The CTRL-click on the two vars jumped to the same location.
Just a look at my scope provider:
0. class MyScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {
1. override IScope getScope(EObject context, EReference reference) {
2. if(context != null) {
3. if(context instanceof MyAssignment) {
4. if(reference.name.equalsIgnoreCase("variable")) {
5. val my_assignment = context as MyAssignment
6. val MyClass e = my_assignment .ofClass?.class_ref
7. Scopes::scopeFor(e.variableList)
8. }
9. else if(reference.name.equalsIgnoreCase("ofClass")) {
10. val my_assignment = context as Assegnazione
11. val MyClass e = my_assignment .throughClass?.class_ref
12. Scopes::scopeFor(e.classList)
13. }
14. else if(reference.name.equalsIgnoreCase("throughClass")) {
15. val MyClass e = context.getContainerOfType(typeof(MyClass))
16. Scopes::scopeFor(e.classList)
17. }
18. }
19. }
20. super.getScope(context, reference)
21. }
22.}
At line 7, e.variableList is always NULL because vars are declared in file .msi, while assignment is contained in file .mti.
At line 12 and 16, e.classList is always diffent from NULL because 'imported classes' are declared in file .mti.
Thanks,
Silvia
|
|
|
Powered by
FUDForum. Page generated in 0.72524 seconds