cross-reference linking and xbase [message #1734949] |
Tue, 14 June 2016 01:26  |
Eclipse User |
|
|
|
Hi,
I'm having trouble getting cross-references between two containment
subtrees of my dsl to work with xbase, I get "cannot be resolved" for
the reference "L2a.L3a" in the following example. The scope doesn't seem
to be the problem since "L2a.L3a" is proposed by auto completion.
level1 L1 {
level2a L2a {
level3a L3a
}
level2b L2b {
level3b ref L2a.L3a
}
}
Here's the grammar (with common.Terminals the linking works OOTB):
//grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals // -> works
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase
// -> ref cannot be resolved
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
Level1;
Level1:
'level1' name=ID '{'
childrenA+=Level2A*
childrenB+=Level2B*
'}';
Level2A:
'level2a' name=ID '{'
children+=Level3A*
'}';
Level3A:
'level3a' name=ID;
Level2B:
'level2b' name=ID '{'
children+=Level3B*
'}';
Level3B:
'level3b' 'ref' level3a=[Level3A|QualifiedName];
QualifiedName:
(ID '.')* ID;
Thank you for any help on this problem!
|
|
|
|
|
|
Re: cross-reference linking and xbase [message #1828901 is a reply to message #1735029] |
Sun, 21 June 2020 15:18   |
Eclipse User |
|
|
|
Hi all.
I have a similar problem when using Xbase and the default Xbase scope provider.
For the following DSL source which is quite similar like a class hierarchy with fields
package p {
integration u0
in i: String
out o: String
{
.i -> u1.o ;
}
integration u1
in o: String
{}
}
I get a linker error "u1.o cannot be resolved".
When I execute the scope computation explicitly in a test (similar to a suggestion made by Lorenzo Bettini in his Xtext book) I get a list of all aliases which also contains "u1.o"
println(u1_o_ref.getScope(ref).allElements.map[name].join(", "))
// prints "i, o, u0, u0.i, u0.o, u1, u1.o, p.u0, p.u0.i, p.u0.o, p.u1, p.u1.o"
However, if I looking up the qualified name specifically, "u1.o" is not found, but the full qualified name "p.u1.o" is found:
println(u1_o_ref.getScope(ref).getSingleElement(QualifiedName.create("p","u1","o")))
// prints "p.u1.o" -- object description found
println(u1_o_ref.getScope(ref).getSingleElement(QualifiedName.create("u1","o")))
// prints "null" -- not found anything
I have read the issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=495047 but my issue here is not related to proposals.
Nevertheless, it seems somehow related to my issues and Xbase and its scope implementation. Unfortunately, I need Xbase due to Java type references (see the "String" reference).
So, I'm wondering whether there is a a workaround for this issue.
Or, am I doing something wrong?
Regards, Denis
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 1.05575 seconds