Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Ctrl click to file:// URI with relative path(Just can't get it to work)
Ctrl click to file:// URI with relative path [message #1800999] Thu, 10 January 2019 20:44 Go to next message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
Hi,

thank you for your time.

I know the "ctrl+click" feature allows me to write URIs into any files and then I can open the URLs by hovering over them with the mouse, pushing ctrl and clicking.

This works fine in my eclipse e.g. for
http://www.google.com
file://c:\foo.txt (I'm on windows)

But, what I actually want to do is, I want to reference a file in the same directory as the file that contains the reference, I want a relative path link.

So I have e.g.

c:
+MyWorkspace
+source.txt
+dest.txt

Inside source.txt, I am putting file:// and then, I start wondering. According to stackoverflow 7857416, what I want to do is impossible, since an URI cannot contain ".".

But rfc3986 says it can, I believe (although others say it says it does not... I think a base URI could be established by the context as per
5.1. Establishing a Base URI, 5.1.2) Base URI of the encapsulating entity). I think the right URI would be file:.dest.txt. But if I use this, eclipse does not detect this as clickable.

So, is there any way to make this work in Eclipse or not? I think it would be VERY helpful for all kinds of things.

Thank you
Re: Ctrl click to file:// URI with relative path [message #1801001 is a reply to message #1800999] Thu, 10 January 2019 20:52 Go to previous messageGo to next message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
Sorry, the forum did not allow me to post as long as I was linking to sackoverflow and https://tools.ietf.org/html/rfc3986. Seems like RFC is allowed, stackoverflow not.
Re: Ctrl click to file:// URI with relative path [message #1801011 is a reply to message #1801001] Fri, 11 January 2019 03:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
No, having an implementation of URI in EMF, using it heavily for producing cross references, and managing carefully how relative and absolute references work, I can say definitively that a URI that starts with <scheme>: will be recognized as an absolute URI. The presence of a scheme---letters followed by a ':'---is what makes a URI absolute. Whether there is a / immediately after the : is what determines whether the URI in hierarchical or opaque. Only a relative hierarchical URI can (and with EMF will) be resolved against the URI (absolute hierarchical) of the containing resource (the context). This means that a relative URI in some resource should not specify a scheme. This works especially well because then regardless of the URI (http:, file:, platform:/resource/), the relative reference can be resolved, and will access the intended URI; this is why you could work locally with some html using file:/... to access the resource and expect that it will all work properly when the files are copied to and accessed from a server using http://. So given all this, file:<relative-path> is pretty close to meaningless garbage. Firstly, if the path doesn't start with /, then it's technically not even a hierarchical URI (or even an absolute file system path on some systems). Goodness know how any particular technology will interpret that, but most likely it will represent the resource relative to the current working drive's (if there is such a concept on the system) current working directory, and that is highly unlikely to be what you'd want in addition to being obviously totally non-portable.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ctrl click to file:// URI with relative path [message #1801069 is a reply to message #1801011] Fri, 11 January 2019 20:28 Go to previous messageGo to next message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
Hi Ed, thanks for your answer, appreciate your time and detail, although I have to admit I cannot follow fully. Leaving out the details of definition what a URI is and what not, I believe it to be:
"No, it is not possible."
Is that not somehow odd? I can link from my text file in eclipse to the internet, but not to "the file next to me"? In my opinion, by holding ctrl and hovering over a string, the user says "I want Eclipse to check whether this might be going anywhere" and there should be a way to point to a file "next to the current file in the editor". I'm not talking about websites or anything. It is all local text files of various types which are shared through a version control system. And I would find it really convenient if the files could be navigated through easily by referencing each other.

Ah, maybe one more addition: It doesn't have to be by ctrl+click. I wanto to navigate to a place based on a selection of a string where the string is indicating a file next to the current one. Any means to achieve this is welcome.

[Updated on: Fri, 11 January 2019 20:33]

Report message to a moderator

Re: Ctrl click to file:// URI with relative path [message #1801075 is a reply to message #1801069] Sat, 12 January 2019 05:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
I see, I did not know about this Ctrl mouse click behavior being something Eclipse supports already in just any old plain text editor. Not looking at the implementation, I imagine the problem with the implementation is that it checks to see if the text looks like a valid URL and decides that based on it looking like an absolute URL with a recognized scheme (must like linkifiers do when you post text on this forum). I.e., foo://bar does not work either, but file:/// works, though does not actually open the root folder of the current drive as one might expect. It appears to me that the implementation makes no effort to interpret arbitrary text under the cursor as potentially being a relative URI and resolving it against the absolute URI of the containing resource. Of course if it did that, all text would look like a URI and the link behavior would appear everywhere. But the implementation could in principle provide specialized support for arbitrary file: URIs and if the portion after the file: isn't an absolute path, it could resolve that portion against the absolute file: URI of the containing resource. I.e., in principle file:other-file.text and file:../folder/other-file.txt could be made to work in the IDE.

But you'd need to open a Bugzilla to ask for such a feature, and then likely wait forever for someone to implement it. Investigating further, I see it's implemented by this:

https://git.eclipse.org/c/platform/eclipse.platform.text.git/tree/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlinkDetector.java#n55

So I expect with an extension point you could register your own implementation. Did you want this badly enough to actually implement it yourself or to contribute it?

I see that in Java's extension that it figures out the resource like this:

https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/tree/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaElementHyperlinkDetector.java#n79

But for a *.txt open in the editor, the context is null, i.e., nothing has called org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector.setContext(IAdaptable) so resource appears not to be known.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ctrl click to file:// URI with relative path [message #1801085 is a reply to message #1801075] Sat, 12 January 2019 18:35 Go to previous messageGo to next message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
Hi Ed,

we're on the same page now, that's good to see. I would really like to have this, but I'm not sure I'm able to do what it takes. I "just" have to set up an environment in which I can build Eclipse from source. Humm. I'll meditate on this. Thank you for your support and the helpful pointers.

Cheers to you.

[Updated on: Sat, 12 January 2019 21:18]

Report message to a moderator

Re: Ctrl click to file:// URI with relative path [message #1801089 is a reply to message #1801085] Sun, 13 January 2019 03:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Actually setting up a development environment is pretty easy with Oomph because I've tried to automate that. Here are instructions for a development environment for the full source code of the Platform SDK:

https://wiki.eclipse.org/Eclipse_Platform_SDK_Provisioning

But you really only need a development environment with the Platform UI source in it, which can be done the same way using Oomph:

https://wiki.eclipse.org/Platform_UI/How_to_Contribute/Oomph

And I've already told you which file you look in. :-)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ctrl click to file:// URI with relative path [message #1801102 is a reply to message #1801089] Sun, 13 January 2019 23:19 Go to previous messageGo to next message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
I will try that. But it may take some time, but source is already on my disk ;-). When I complete, maybe I'll ask for your help to get this in. You seem to know how things work here. Definitely though, I'll post here to report when it's in.
Re: Ctrl click to file:// URI with relative path [message #1801109 is a reply to message #1801102] Mon, 14 January 2019 03:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
I'm old and I've been around Eclipse for a very long time, so yes, I know how things work around here. I would suggest you open a Bugzilla with this request, and that you create a Gerrit account so you can commit changes for review. Post the Bugzilla here when you get that far and then all discussions can happen in the Bugzilla.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ctrl click to file:// URI with relative path [message #1801183 is a reply to message #1801109] Mon, 14 January 2019 23:10 Go to previous message
Peter LustigFriend
Messages: 8
Registered: January 2019
Junior Member
I found a bug. Or not. A way to improve rather:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=543434
Previous Topic:CheckBoxes in BIRT
Next Topic:Eclipse RCP Application - Window maximize option while launching
Goto Forum:
  


Current Time: Thu Mar 28 12:47:00 GMT 2024

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

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

Back to the top