|
|
Re: How to obtain Resource URI's in-project relative path (for use in Xtext IGenerator IFileSystemAc [message #1231226 is a reply to message #1230919] |
Tue, 14 January 2014 05:22 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Michael,
Alternatively you might create a Path and use that the trim the first
segment. I'm not so keen on filling the URI class with infrequently
used utilities. It's unusual to want the project relative path. You
might take the approach like I did with Xcore or determining the root
of the file system access once:
URI uri = ((IFileSystemAccessExtension2)fsa).getURI(".");
And using URI.deresolve or URI.replacePrefix to produce URIs relative to
that root.
On 13/01/2014 12:25 PM, Michael Vorburger wrote:
> I've been able to "muddle" it like this, but this String
> manipulation-based approach is more of a workaround really:
>
> if (!uri.isPlatformResource())
> throw new IllegalArgumentException("Not a Platform
> Resource URI: " + uri.toString());
> String sURI = uri.toPlatformString(true);
> String withoutProject = sURI.substring(sURI.indexOf('/', 1) + 1);
>
>
> Is there a better way to do this? If there isn't, is it worthwhile to
> open a (low prio) bugzilla requesting an API for this?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03626 seconds