Do InlayHints work with Gateway?

Answered

I have a plugin that renders some UI elements in the editor using InlayHints. When used with JetBrains Gateway, 99% of the plugin works just fine when it is installed on the host (this includes editor insertions, keyboard shortcuts, commands), but the Inlay Hints never render. Are they expected to? If not, is there a workaround to get the plugin working with gateway?

0
5 comments

Hi,

Could you please share the exact APIs you use and code snippets using them?

0

First I create an EditorCustomElementRenderer:

class CompletionInlayRenderer(
    private val lines: List<String>,
    private val inlayType: InlayType,
    private val offset: Int,
) : EditorCustomElementRenderer {


override fun paint(inlay: Inlay<*>,
      g: Graphics,
      targetRegion: Rectangle,
      textAttributes: TextAttributes
  ) {
    val g2 = g.create() as Graphics2D
    GraphicsUtil.setupAAPainting(g2 as Graphics)
...


then:

val inlayModel = editor.inlayModel
  ApplicationManager.getApplication().runReadAction {
    val renderers = getInlayRenderers(editor)
    ApplicationManager.getApplication().invokeLater {
      renderers.forEach { renderer ->
        val rendererOffset = renderer.getOffset()
        val inlay =
            when (renderer.getInlayType()) {
              InlayType.INLINE -> {
                inlayModel.addInlineElement(rendererOffset, true, renderer)
              }
              InlayType.BLOCK -> {
                inlayModel.addBlockElement(rendererOffset, true, false, 0, renderer)
              }
              InlayType.AFTER_LINE -> {
                inlayModel.addAfterLineEndElement(rendererOffset, true, renderer)
              }
            }
      }
      }

 

0

Hi,

If you are trying to implement completion through inlays, there is an experimental API for this use case: com.intellij.codeInsight.inline.completion.InlineCompletionProvider.

It is not supported for the client yet. Please vote and follow the issue: https://youtrack.jetbrains.com/issue/RDCT-401/Support-inline-completion-for-client.

If you still need to render your custom inlays, please check https://youtrack.jetbrains.com/issue/RDCT-400 and add your cases if they are missing from the ticket.

0

Hi Karol Lewandowski

I noticed that the first issue is now marked as fixed! Do you know how I can tell when a version with this support will be released?

0

Hi,

As far as I can see, it is planned for 2023.3, so it will take some time until it is available.

0

Please sign in to leave a comment.