implementing website link like behavior on custom text

Answered

Hi, I would like to implement similar functions to urls in comments/string literals within another component in the IDE.

For example, for the following piece of code:

<tag>Value</tag>

If the user ctrl+hovers over the "Value", I want the string to be underlined and highlighted like this:

<tag>Value</tag>

when the user ctrl+clicks that value, I want it to open a URL based on the text provided in the default browser.

I already implemented a similar action by extending the com.intellij.ide.browsers.WebBrowserUrlProvider class available via extension point com.intellij.webBrowserUrlProvider. The other options I checked, com.intellij.gotoDeclarationHandler and com.intellij.psiReferenceContributor only seem to handle jumping to a different page within the project, but not opening a website on a browser.

How do I go about implementing this Ctrl+Click/Hover action?

0
1 comment

WebBrowserUrlProvider is unrelated for this use-case.

 

Create PsiReferenceContributor for your location(s) and return com.intellij.openapi.paths.WebReference from it

0

Please sign in to leave a comment.