Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Augmenting importURI handling
Augmenting importURI handling [message #668458] Thu, 05 May 2011 17:21 Go to next message
drew frantz is currently offline drew frantzFriend
Messages: 340
Registered: July 2009
Senior Member
Problem:
a.dsl imports b.dsl
b.dsl imports c.dsl

I want the default handling to make c.dsl elements visible to a.dsl by the
indirect import (via b.dsl).
Re: Augmenting importURI handling [message #668482 is a reply to message #668458] Thu, 05 May 2011 19:54 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2501
Registered: July 2009
Senior Member
On 5/5/11 7:21 PM, Drew wrote:
> Problem:
> a.dsl imports b.dsl
> b.dsl imports c.dsl
>
> I want the default handling to make c.dsl elements visible to a.dsl by
> the indirect import (via b.dsl).
>
I think you need to reexport b.dsl's imports. This is not done by
default. The typical config exports named/qualified named elements, if
you want to export more, you need to hook into that mechanism at a
suitable place.

- henrik
Re: Augmenting importURI handling [message #668500 is a reply to message #668482] Thu, 05 May 2011 20:53 Go to previous messageGo to next message
drew frantz is currently offline drew frantzFriend
Messages: 340
Registered: July 2009
Senior Member
Not sure what the right place is. I have tried the myScope provider, which
works for scope resolution in the text editor, but does not work for F3
navigation to the referenced element.


"Henrik Lindberg" <henrik.lindberg@cloudsmith.com> wrote in message
news:ipuupl$dlu$1@news.eclipse.org...
> On 5/5/11 7:21 PM, Drew wrote:
>> Problem:
>> a.dsl imports b.dsl
>> b.dsl imports c.dsl
>>
>> I want the default handling to make c.dsl elements visible to a.dsl by
>> the indirect import (via b.dsl).
>>
> I think you need to reexport b.dsl's imports. This is not done by default.
> The typical config exports named/qualified named elements, if you want to
> export more, you need to hook into that mechanism at a suitable place.
>
> - henrik
>
Re: Augmenting importURI handling [message #668512 is a reply to message #668500] Thu, 05 May 2011 23:17 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2501
Registered: July 2009
Senior Member
On 5/5/11 10:53 PM, Drew wrote:
> Not sure what the right place is. I have tried the myScope provider,
> which works for scope resolution in the text editor, but does not work
> for F3 navigation to the referenced element.
>

You will probably need a different binding of DefaultResourceDescription
which is set up by DefaultResourceDescriptionManager, but it may be
possible to do this in a different way.

In your runtime module:
public Class<? extends IResourceDescription.Manager>
bindIResourceDescriptionManager() {
return PPResourceDescriptionManager.class;
}

(My override of DefaultResourceDescriptionManager is called
PPResourceDescriptionManager).

In the manager, override a method like this:

@Override
protected IResourceDescription internalGetResourceDescription(Resource
resource,
IDefaultResourceDescriptionStrategy strategy) {
return new PPResourceDescription(resource, strategy, getCache());
}

And in your resource description class... (mine is obviously
PPResourceDescription) do what you need to do (respond to the various
methods asking for imported and exported IEObjectDescriptions). In my
case, I add more imported descriptors.

In my case I also use a specialized resource description strategy.
If you want to look at my code for this - it is at cloudsmith/geppetto
at Github, in the package org.cloudsmith.geppetto.pp.dsl.linking.

There is not much code that has to be written, but it is not shown in
the documentation, and it is a bit tricky to understand what one needs
to do at first.

Suggest you try to override the classes mentioned above and the methods
you think are the ones you want to override, then debug and see when
they are called and what they return.

Hope that helps.

OTOH - I am not using ImportURI and instead use the global index that is
built. There may be some other simpler solution when using ImportURI
(such as just adding the resource pointed to by ImportURI to the
resource set, and then adding all of its resource to the resource set,
and so on... but I am not sure). This is what you need to do by default
in standalone mode anyway.

- henrik
Re: Augmenting importURI handling [message #668532 is a reply to message #668500] Fri, 06 May 2011 06:35 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1162
Registered: July 2009
Senior Member
Hi,

in case you use the import uri mechanism, you could adapt getImportedUris() in ImportUriGlobalScopeProvider in order to (recursively) add the imported uris of imported resources.

In case you use the import namespace mechanism you could play around with the ImportedNamespaceAwareLocalScopeProvider, adding namespaces imported by imported namespaces. internalGetImportNormalizers() might be a starting point.

Alex
Re: Augmenting importURI handling [message #669491 is a reply to message #668532] Tue, 10 May 2011 13:41 Go to previous message
drew frantz is currently offline drew frantzFriend
Messages: 340
Registered: July 2009
Senior Member
That works great. Now how do I make the xtext stanadlone unit tests work
when they see importURI's?


"Alexander Nittka" <alexander.nittka@itemis.de> wrote in message
news:iq04bi$il2$1@news.eclipse.org...
> Hi,
>
> in case you use the import uri mechanism, you could adapt
> getImportedUris() in ImportUriGlobalScopeProvider in order to
> (recursively) add the imported uris of imported resources.
>
> In case you use the import namespace mechanism you could play around with
> the ImportedNamespaceAwareLocalScopeProvider, adding namespaces imported
> by imported namespaces. internalGetImportNormalizers() might be a starting
> point.
>
> Alex
Previous Topic:Element with the same name but different type
Next Topic:IScope Provider issue
Goto Forum:
  


Current Time: Mon Dec 22 02:13:18 GMT 2014

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

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