Showing available intentions for a highlight in a popup at a custom position

Answered

I have a `HighlightInfo`, and would like to display an Alt+Enter style popup, with the available intentions / quick fixes for that `HighlightInfo`, near the cursor when a user clicks somewhere.

For collecting the list of intentions, it looks like I could use `ShowIntentionsPass`, but `#getAvailableFixes` processes all highlights at an offset, not just the `HighlightInfo` I have. The most useful API for this would be `SIP#addAvailableFixesForGroups` which lets me pass a `HighlightInfo`, but this method is private. I cannot replicate this method, because a bunch of the things it uses, such as `HighlightInfo#isFromInjection` or `#getGroup`, are package-private.

The second problem is with positioning the popup. I can call `IntentionHintComponent.showIntentionHint` with the collected intentions, but no option to set the position. The method returns a `IntentionHintComponent` which has no way to access `#myPopup`, and all the `#showPopup` methods are also private. I cannot create a custom popup, because once again, `IntentionHintComponent#IntentionPopup` is package-private with a private constructor.

Could `ShowIntentionsPass#getAvailableFixes` and `IntentionHintComponent#showPopup` overloads, and possibly the package-private getter methods in `HighlightInfo`, be made public for plugins to use?

0
3 comments

Could you please explain what highlighting you're trying to achieve in your plugin and what API you're using to manually construct HighlightInfo?

0

I'm not manually constructing `HighlightInfo`. I'm showing highlight descriptions as inlays, and need to get intentions for a specific `HighlightInfo` so I can show a popup for it when you click the inlay. https://plugins.jetbrains.com/plugin/19678-inspection-lens/

0

Any updates on this?

0

Please sign in to leave a comment.