How do I add extension codeInsight.declarativeInlayProvider
Answered
I am working on a plugin for intellij. I query the lsp for diagnostics on a file and it gives me line numbers for problematic lines. I want to provide an inlay hint at the end of each line with problematic code. But I cannot get my InlayHintsProvider to be registered properly as an extension point.
My code is here
I have been able to run :runIde: gradle task in debug mode and the code never hits any debug point in MyDeclarativeInlayHintsProvider.
My assumption is that I'm doing something wrong in my plugn.xml that is not injecting my InlayHintsProvider properly but I have not been able to diagnose the problem
<idea-plugin require-restart="true">
…
<extensions defaultExtensionNs="com.intellij">
<codeInsight.declarativeInlayProvider
language=""
isEnabledByDefault="true"
implementationClass="com.example.inlays.demo.lsp.MyDeclarativeInlayHintsProvider"
/>
</extensions>
…
</idea-plugin>
Please sign in to leave a comment.
What are you trying to achieve with Inlay Hints? Are you not using LSP instead of PSI (which you must have for inlay hints) for your language? If you have PSI, you must specify
language
attribute in plugin.xml correctly (empty value is invalid).I am using a lsp … in my example code I'm hardcoding the return from the lsp but the lsp return should have the line number I need for placement of the inlay hint. I don't think I have to use PSI do I?
I have tried specifying “Java” as the language, but that does not seem to impact whether or not the inlay provider gets wired into the plugin
Actually … I just figured it out. My solution is language agnostic because the lsp handles all of the language specific stuff for me, so I needed to add a InlayHintFactory like so …
and then update my plugin.xml like so
Followup question … although my hints show up now … I can right click them and disable them and then they're gone and I cannot reenable them without either wiring up a whole bunch of inlay settings that I don't want to build or do a clean rebuild of the plugin. Is there anyway I can disable the DisableDeclarativeInlayAction?
That would be dangerous, and disabling it for specific inlays is not possible.
Fair enough … if I did want to declare it as an inlay setting that I could toggle back on if I wanted, what is the standard way of doing that with a declarative inlay?
Sorry, could you please rephrase your last question? It's not quite clear what you want to achieve to me.