Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How do I write a search-path based scope?
icon5.gif  How do I write a search-path based scope? [message #759916] Wed, 30 November 2011 14:55 Go to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
I have a set of "models" which use libraries to define common parts implemented in Xtext. This works very well.

To allow customers to create their own models, I created a project which contains only the libraries. All my unit tests succeed with this setup. This probably because I resolve resources myself and pass InputStreams to Xtext (not my code Smile )

But when I create a new project, I get errors in the DSL editors even after adding the library project to the build path as a "required project".

My guess is that this is because the library is references with "lib base;" in the DSL but the actual file is in the package "com.pany.product.config.dsl.libs".

I read a lot of articles in this forum and the Xtext documentation.

I think I need to implement a IContainer.Manager which takes a set of paths and tries to locate the library name in those paths. I looked at ResourceSetBasedAllContainersState which seems almost like what I need but how do I configure it?

From the code in ResourceSetBasedAllContainersStateProvider, the container2Uris Multimap translates container names to a set of URIs.

How do I map the library name "base" to the URI "classpath:/com/pany/product/config/dsl/libs/base.lib"? Or is the ResourceSetBasedAllContainersState smart enough to do that for me? Or am I on the wrong track here? All I want is a static mapping from library name to URI.

[Updated on: Wed, 30 November 2011 14:56]

Report message to a moderator

Re: How do I write a search-path based scope? [message #759996 is a reply to message #759916] Wed, 30 November 2011 20:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

what kind of scoping do you use? importUri based? customize ImportUriResolver or ImportUriGlobalScopeProvider to transpose the uri. namespace based? the it should work out of the box

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How do I write a search-path based scope? [message #760077 is a reply to message #759996] Thu, 01 December 2011 08:54 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
As I said, my approach is "search path based". The resources are in a certain package on the classpath. It works when the resources are in the same project but I get errors in the editor when I move them to a different project (even though they are still in the same place on the classpath).

[Updated on: Thu, 01 December 2011 08:55]

Report message to a moderator

Re: How do I write a search-path based scope? [message #760080 is a reply to message #760077] Thu, 01 December 2011 08:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
And how does your "search path based" stuff work?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How do I write a search-path based scope? [message #760098 is a reply to message #760080] Thu, 01 December 2011 10:19 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Remember that there are two modes of operation: Product and Eclipse editor. The product is web based, so no Eclipse/OSGi/p2 is involved.

Product mode: I have a configuration which lists all packages where resources can be found. At startup, I read the config and create a "DSL loader" which searches and loads all configured libraries in a shared resource. Scripts are then loaded into the same resource. Since the libraries are already present, the proxy resolver has no problem to find them.

Eclipse editor mode: Within the editor, something else happens. My guess is that the JavaProjectsState class is somehow involved but the code is hard to understand - this is one of the drawbacks of DI: If you don't know which part of the code contains a certain functionality, you're lost since you can't easily figure it out by looking the code.

What I don't understand is why it works when the resources are in the same project but why it fails when I split the resources over several projects. In the JavaProjectsState class, I see WorkspaceProjectsStateHelper and JavaProjectsStateHelper which suggests that the Xtext runtime can resolve resources via the classpath but for some reason, this isn't happening.

One odd thing that I noticed: There is no "Referenced Libraries" node in the Package Explorer :-/ Makes me wonder if I'm missing a plug-in when I start an Eclipse Application via "Run...".

PS: The errors suddenly vanished. I cleaned the configuration, the workspace and built the plug-ins once more. No idea which of the three fixed the problem. Is there a way to debug the resource resolution?
Re: How do I write a search-path based scope? [message #760102 is a reply to message #760098] Thu, 01 December 2011 10:30 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

id debug into DefaultGlobalScopeProvider.getVisibleContainers/getScope

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 01 December 2011 10:30]

Report message to a moderator

Previous Topic:[xtext 2.0] protected region support?
Next Topic:[emf] question regarding ResourceSetImpl#uriResourceMap
Goto Forum:
  


Current Time: Thu Apr 25 10:36:04 GMT 2024

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

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

Back to the top