Add inlay hint above method


Hello! I am developing plugin for Intellij and want to display some information above the method like it displayed near Stream operations (see attached picture for example). 
How can I do this? I have PsiMethod's reference, do I need this? Should I do this from the editor?
I found this thread: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000059504-add-dynamic-annotation-how-to- but can someone please clarify, how to use Inlay not from debug?
Thanks!

3 comments
Comment actions Permalink

Hello,

If by 'above the method' you mean between document lines (by increasing the distance between following lines' text baselines and displaying additional content between them), such possibility has been added recently (in 2018.3 EAP builds) to editor API - see Editor.getInlayModel(). InlayModel.addBlockElement(). This API is quite low-level though, you'll need also to implement some code atop of it, which will add/remove corresponding visual elements on document modifications. You can use e.g. ParameterHintsPassFactory as an inspiration.

2
Comment actions Permalink

To display a hint 'inside' document line, you can use a higher-level API - just implement InlayParameterHintsProvider.

2
Comment actions Permalink

Thanks for answer, Dmitry!

0

Please sign in to leave a comment.