Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext] Controlling import search path
[Xtext] Controlling import search path [message #49818] Wed, 10 June 2009 11:23 Go to next message
Eclipse UserFriend
Hi,

I would like to be able to override the file location provided to the import
statement of my DSL. I need the ability to map the path to a different
physical one. Is there a straightforward way to achieve this?

For example, import "linux/server.vml", where the path needs to be
transformed to /{RepoDir}/vml/linux/server.vml.

Thanks
Derek
Re: [Xtext] Controlling import search path [message #49848 is a reply to message #49818] Wed, 10 June 2009 14:18 Go to previous messageGo to next message
Eclipse UserFriend
Hi Derek,

Derek Palma wrote:
> I would like to be able to override the file location provided to the import
> statement of my DSL. I need the ability to map the path to a different
> physical one. Is there a straightforward way to achieve this?
>
> For example, import "linux/server.vml", where the path needs to be
> transformed to /{RepoDir}/vml/linux/server.vml.
>

I presume you're using the default import mechanism as described in the
documentation
(http://wiki.eclipse.org/Xtext/Documentation#Default_Imports). If that is
the case then you should be able to override the ImportUriResolver. You do
this by adding a binding to your XyzRuntimeModule like this:

public Class<? extends ImportUriResolver> bindImportUriResolver() {
return XyzImportUriResolver.class;
}

The XyzImportUriResolver class should then override the getResolver()
method. The EObject passed to the resolver will be the Import object (i.e.
the object with the "importURI" feature).

Hope that helps,

--knut
Re: [Xtext] Controlling import search path [message #49878 is a reply to message #49848] Wed, 10 June 2009 15:04 Go to previous message
Eclipse UserFriend
Hi Derek,

you may even try to simply override resolve() and
perform your transformation on the result of super.resolve().

Regards,
Sebastian

Am 10.06.2009 20:18 Uhr, schrieb Knut Wannheden:
> Hi Derek,
>
> Derek Palma wrote:
>> I would like to be able to override the file location provided to the
>> import statement of my DSL. I need the ability to map the path to a
>> different physical one. Is there a straightforward way to achieve this?
>>
>> For example, import "linux/server.vml", where the path needs to be
>> transformed to /{RepoDir}/vml/linux/server.vml.
>>
>
> I presume you're using the default import mechanism as described in the
> documentation
> (http://wiki.eclipse.org/Xtext/Documentation#Default_Imports). If that
> is the case then you should be able to override the ImportUriResolver.
> You do this by adding a binding to your XyzRuntimeModule like this:
>
> public Class<? extends ImportUriResolver> bindImportUriResolver() {
> return XyzImportUriResolver.class;
> }
>
> The XyzImportUriResolver class should then override the getResolver()
> method. The EObject passed to the resolver will be the Import object
> (i.e. the object with the "importURI" feature).
>
> Hope that helps,
>
> --knut
>
Previous Topic:[Announce] TMF XTEXT 0.7.0RC4 is available
Next Topic:Error serializing CrossRefs: Unable to create a string represenation for refere
Goto Forum:
  


Current Time: Tue Apr 29 00:10:26 EDT 2025

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

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

Back to the top