URL refs in string literals of cusom language


How to make string literals of my custom language have refs if they contain an URL? Is there any built-in technique? I’ve found UrlReferenceProvider that processes PsiLiteralValue elements. It works fine but disabled by default (ide.symbol.url.references key in registry). One more thing that bothers me that it’s coupled with issue navigation - the name of the setting in the registry is Symbol API based issue references.


Does your language’s literal implement PsiLanguageInjectionHost - then it should work out of the box.

Otherwise, see org.jetbrains.kotlin.idea.references.KotlinWebReferenceContributor as simple solution.


I did this for my string literals recently, the magic incantation was: make them implement PsiLiteralValue, and call ReferenceProvidersRegistry.getReferencesFromProviders(this) in its getReferences() method.


Colin Fleming

It worked for me. There is no need to implement PsiLanguageInjectionHost.


Please sign in to leave a comment.