Home » Modeling » TMF (Xtext) » Xtext and scopes
| Xtext and scopes [message #895574] |
Fri, 13 July 2012 11:38  |
Aaron Digulla Messages: 234 Registered: July 2009 Location: Switzerland |
Senior Member |
|
|
Hello,
I've tried for the fifth time to wrap my brain about the explanation of scopes in the documentation (http://www.eclipse.org/Xtext/documentation.html#scoping). I know a little bit about Java and parsers (proof: I have 80K points on stackoverflow.com)
But I just don't get it and that made me wonder why not? So here is my view/feelings/thoughts about the current state of the documentation.
I think the problem lies not in the amount and depth of the documentation. When I read the documentation then I learn a lot about scopes and IScopeProviders and a dozen other related types.
But I don't understand how I could achieve some desired goal. Let's look at the beginning:
Quote:A single IScope (src) represents an element of a linked list of scopes. That means that a scope can be nested within an outer scope. Each scope works like a symbol table or a map where the keys are strings and the values are so called IEObjectDescription (src), which is effectively an abstract description of a real EObject (src).
That's good to know but it doesn't answer any of my questions:
How do I create an IEObjectDescription?
In the paragraph above this one, you mention "target candidates". What's that? Is that related to IEObjectDescription in some way? How?
Actually, I don't care that much about scopes. My question is usually "I have property 'x' in type Foo and have some filter that tells me which instances of my model are allowed as value for 'x'. How does that translate into Xtext code?
You see, the documentation explains a lot of details but I'm missing code examples which explains the two most common cases:
1. Supply a list of possible values for a property
2. Take an existing scope and reduce the values by applying a filter
Instead of focusing on the theoretical background, start with some simple examples and build on that. UML diagrams are nice to see how types are related but they don't explain how to use them.
Code that I'd like to see:
1. How do I find all instances of a certain type in a resource/resource set? (= how do I get all the possible values)
2. How do I filter this list, for example, to remove the node for which I create the list?
3. How do I turn this list into an IScope?
4. How do I configure Xtext to use this new scope?
I'm sure most of these questions are very simple to answer for someone who knows Xtext but I only have "ERROR:Couldn't resolve reference to Foo 'base'" and Xtext refuses to tell me where it looked for "base".
Regards,
A. Digulla
|
|
|
Goto Forum:
Current Time: Wed May 22 10:48:00 EDT 2013
Powered by FUDForum. Page generated in 0.01938 seconds
|