Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ResourceDescriptionStrategy for locally defined eObjects
ResourceDescriptionStrategy for locally defined eObjects [message #1030756] Sun, 31 March 2013 18:08 Go to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
I have implemented a custom ResourceDescriptionStrategy.

Within that ResourceDescriptionStrategy, I am adding custom userData.

I've also implemented a custom LinkingService.

For imported resources, I can see the custom userData within my LinkingService. For anything that's defined within the file I'm currently editing, no userData exists.

Looking through the documentation, I see that only objects outside the current resource are indexed.

I understand that, but I'm confused as to why my ResourceDescriptionStrategy is not being used to build IEObjectDescriptions for locally defined eObjects or how to actually implement something that will provide the data I'm looking for without actually having to re-implement the ResourceDescriptionStrategy anywhere and everywhere I might actually want to examine my userData.

Here's an example I'm working with:

I have a function declaration.
 * multiplies two integers and returns the result
function multiply(int x, int y){
  return x * y

Now, within my ResourceDescription Strategy, I want to store the function signature and a template as userData:
userData("signature") = "multiply(int, int)"
userData("template")  = "multiply(${x}, ${y})\n$cursor"
userData("do_a_dance")  = "let's get funky"

Within my LinkingService, when a user uses a function I want to be able to check the signature and link appropriately
final IScope scope = getScope(context, ref);
Iterator<IEObjectDescription> allel = scope.getAllElements().iterator();
	IEObjectDescription desc =;

For anything defined externally, I see the appropriate signature.
For anything defined within the editor, I see nothing.

I understand that there are many different ways to attack this problem, but it seems to me that there's no sense in leveraging a ResourceDescriptionStrategy for anything unless you can also implement it for things that are locally defined.

I'm sure there's a way to do it, I'm just missing it.

I can't seem to find it in the documentation and I swear I had found a forum post at one point that spelled it out, but I can't seem to find it anymore.
Re: ResourceDescriptionStrategy for locally defined eObjects [message #1030771 is a reply to message #1030756] Sun, 31 March 2013 18:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13709
Registered: July 2009
Senior Member

Need training, onsite consulting or any other kind of help for Xtext?
Go visit or send a mail to xtext at itemis dot de

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Re: ResourceDescriptionStrategy for locally defined eObjects [message #1030798 is a reply to message #1030771] Sun, 31 March 2013 19:44 Go to previous message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Christian - you are da man!

To summarize the link - until that bug gets resolved you have to customize your ImportedNamespaceAwareLocalScopeProvider as well as your ResourceDescriptionStrategy.

That was a little tricky to figure out how to bind, so for the next guy...

If you search the you'll see:
// contributed by org.eclipse.xtext.generator.scoping.AbstractScopingFragment
public void configureIScopeProviderDelegate( binder) {

Override that function in your runtime module by copying the code and replacing it with your ImportedNamespaceAwareLocalScopeProvider subclass:
    	public void configureIScopeProviderDelegate(Binder binder) {

That's probably obvious for a veteran xtext user. For me... that took a good deal of brain power (and I was already a little low).

I haven't coded the inserting of user data just yet in there, but that's the road I'm going down for the moment. There's some sample code in the bug report, but I haven't quite digested it just yet.

[Updated on: Sun, 31 March 2013 19:45]

Report message to a moderator

Previous Topic:How to import and parse a file with xtext and generate an EMF model out of it?
Next Topic:Model serialization problem
Goto Forum:

Current Time: Tue Jan 19 13:34:08 GMT 2021

Powered by FUDForum. Page generated in 0.01574 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top