Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Global Scoping with ImportUriGlobalScopeProvider
Global Scoping with ImportUriGlobalScopeProvider [message #868923] Wed, 02 May 2012 18:37 Go to next message
Johannes Stelzer is currently offline Johannes StelzerFriend
Messages: 30
Registered: October 2009
Member
Hi forums,

I've implemented global scoping using the ImportUriGlobalScopeProvider approach;
public class InputFileGlobalScopeProvider extends ImportUriGlobalScopeProvider {

    public static URI BUILTINS_URI = URI
            .createURI("classpath:/de/stelzer/sntsworkbench/sntswb.builtin");

    @Override
    protected LinkedHashSet<URI> getImportedUris(Resource resource) {
        LinkedHashSet<URI> temp = super.getImportedUris(resource);
        temp.add(BUILTINS_URI);
        return temp;

    }
}


When I run my JUnit test everything is fine and references are correctly resolved.
But when I run the same file in Eclipse it just doesn't work.

The DirtyStateAwareResourceDescriptions delegates the getResourceDescription() to his globalDescriptions (instance of ClusteringBuilderState).
And the ClusteringBuilderState tries to lookup the ResourceDescription in his resourceDescriptionMap, which doesn't contains a ResourceDescription for my URI (classpath:/de/stelzer/sntsworkbench/sntswb.builtin) - so null is returned for getResourceDescription() - and no references are resolved...

Am I missing something? or can anybody help me?

UPDATE:
Ok i figured out, that the JdtClasspathUriResolver is used to resolve the URI and fails. Correct me if I'm wrong, but the JdtClasspathUriResolver looks in the projects' classpath - but not in my plugins classpath - so i guess in need another URI?

Greetings Johannes

[Updated on: Wed, 02 May 2012 20:28]

Report message to a moderator

Re: Global Scoping with ImportUriGlobalScopeProvider [message #869459 is a reply to message #868923] Thu, 03 May 2012 12:38 Go to previous message
Holger Schill is currently offline Holger SchillFriend
Messages: 75
Registered: July 2009
Member
Hi Johannes,

normally the ImportUriGlobalScopeProvider just works as a filter to the
index. If your resource is not in the index you'll not able to make
things visible.

Just to clarify why it worked in a junit test and not in Eclipse:

I am not aware how you implemented your test but I would bet you loaded
the resource with the classpath URI without starting the stuff with as a
plugin test? In this case the resourceSets resources build the index
with the URI they have been loaded with.
In case of Eclipse the Index is filled with platform:/resource URIs. So
your classpath URI will not match.

So what you have to make sure is that your resource is loaded by the
index CTRL-SHIFT-F3. If the types you want to reference are not visible
the resources are not within the index. Make sure the XtextNature is in
the project where the resource is in. In the default way everything that
is visible in the meaning of a Java-Classpath is visible. The
ImportURIGlobalScopeProvider just filters the content of the Index.
Bring your resource into the index and then use a platform/resource URI.

Cheers,
Holger


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Previous Topic:Creating JSON from EObjects
Next Topic:Cross Linking Complex Types
Goto Forum:
  


Current Time: Fri Dec 04 08:36:08 GMT 2020

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

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

Back to the top