Hyperlinks in Strings/Comments [message #558337] |
Sat, 11 September 2010 06:34  |
Eclipse User |
|
|
|
Hi,
I have the need to provide hyperlinks in comments (as an example
recognize a URL in a comment and making it clickable).
Grateful if someone could suggest how to implement something like that.
Regards
- henrik
|
|
|
|
Re: Hyperlinks in Strings/Comments [message #558607 is a reply to message #558342] |
Mon, 13 September 2010 12:08   |
Eclipse User |
|
|
|
Thanks,
Splitting up the text into fine grained grammar opens up a very large
can of worms, and I was thinking of finding the links in the data type
conversion. I currently use a String for the documentation data, but
could just as well have a type that contains more information.
Or, is there some other place where it is convenient to introduce
"additional parsing" ? I can imagine computing offsets on demand and
storing in an adapter for instance.
Regards
- henrik
On 9/11/10 1:46 PM, Alexander Nittka wrote:
> Hi,
>
> there are a couple of threads in the forum dealing with similar
> problems, an approach is contained in the MWE2 grammar project.
>
> One possibility is changing the grammar, making strings and comments not
> being single terminals but rather composed elements that can contain
> elements of type link. You'd still have to adapt the linking though.
> Also this would make the grammar quite complicated and if you don't want
> to use the comments or strings otherwise (just allow navigation for the
> user), this might be an overkill.
>
> My first suggestion would be to implement your own HyperlinkHelper
> "extending" the createHyperlinkByOffset method. The difficult part will
> be (if you don't change the grammar for comments) "manually" parsing the
> comment node, checking whether there actually is a URL under the current
> cursor position. You can then create your own I/Abstract/XtextHyperlink
> associating whatever you want with the open-method.
>
> Alex
|
|
|
|
|
|
Re: Hyperlinks in Strings/Comments [message #558775 is a reply to message #558662] |
Tue, 14 September 2010 07:19  |
Eclipse User |
|
|
|
Hi Sven, hi Henrik,
the URLHyperlinkeDetector is registered as well. The bound detector is
added to the default list of hyperlinke detectors in the
XtextSourceViewerConfiguration.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 13.09.10 22:07, schrieb Sven Efftinge:
> Am 9/11/10 12:34 PM, schrieb Henrik Lindberg:
>> Hi,
>> I have the need to provide hyperlinks in comments (as an example
>> recognize a URL in a comment and making it clickable).
>>
>> Grateful if someone could suggest how to implement something like that.
>>
>> Regards
>> - henrik
>
> You could override the binding in
> org.eclipse.xtext.ui.DefaultUiModule.bindIHyperlinkDetector( )
>
> and add an implementation which delegates to
> org.eclipse.jface.text.hyperlink.URLHyperlinkDetector
> in addition to the default behavior.
>
> Sven
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06177 seconds