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.

0

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.

0

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.

1

Colin Fleming

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

0

请先登录再写评论。