| Qualified Name to a custom scope [message #764108] |
Sun, 11 December 2011 06:24  |
Moritz Messages: 22 Registered: July 2011 |
Junior Member |
|
|
Hi,
I am stuck with the qualified name provider. Can someone help me with the right approach for the following?
I try to address an attribute with a path notation as shown in the following example. When using the default behaviour, the FQN only allows me to reference the attributes statical like A.a or B.r; but what I want is to use the scope of the attribute path.
entity A {
attr a
}
entity B {
attr a
attr r : A
}
entity C {
attr r : B
set r = 3 // works
set r.a = 4 // ?
set r.r.a = 5 // ?
}
Here is the grammar for this example.
Model:
(entities += Entity)*;
Entity:
'entity' name = ID '{'
(attributes += Attribute)*
(settings += Setting)*
'}';
Attribute:
'attr' name = ID (':' type = [Entity])?;
Setting:
'set' attributePath = [Attribute|FQN] '=' value = INT;
// 'set' path += [Attribute] ('.' path += [Attribute])* '=' value = INT; // Alternative approach
FQN:
ID ('.' ID)*;
When the attribute path has a fixed length, the path-sensitive scoping works great with a custom scope provider.
To allow a path of arbitrary length, I also tried to use attributePath+=[Attribute]*, but when the ScopeProvider is asked for the next scope, I don't know which path element is currently visited. The FQN approach only lets me choose the static qualified names...
Can someone help me here, please?
Best Regards,
Moritz
|
|
|
|
| Re: Qualified Name to a custom scope [message #764194 is a reply to message #764124] |
Sun, 11 December 2011 11:24   |
Moritz Messages: 22 Registered: July 2011 |
Junior Member |
|
|
Hi,
ok, this looks like Meinte wrote this article just to anticipate an explanation for what seems to be exactly my question + sample. Somehow it didn't came to my mind that "xtext path expression" are already the correct search terms. @Meinte, I googled for "xtext qualified name scope" instead.
Thank you very much, Christian
Best regards
Moritz
P.S. For future readers: There is a link to an updated Post at the end of the article
[Updated on: Sun, 11 December 2011 11:25] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.01586 seconds