How to show a pop up at a specific location of the code editor?
Answered
I'm working on a plugin for Android Studio. One feature I want to implement is when the user takes some action for the first time (e.g., apply a quickfix), the plugin can show a pop up at the specific location of the code (e.g., where the quickfix modifies the code) with some explanatory messages. I found this feature from the GitHub Copilot plugin that is exactly what I want to have in my plugin (see the screenshot below). Could anyone share some pointers about how to implement it? Thanks a lot!

Please sign in to leave a comment.
Hi,
You want to use com.intellij.ui.GotItTooltip:
Also, see:
https://jetbrains.design/intellij/controls/got_it_tooltip/
for the best practices.
Hi Karol,
Thanks for your quick reply. This API is what I'm looking for. However, I found it only worked with IntelliJ IDEA and when I tried to install my plugin on Android Studio it caused the following error:
java.lang.NoSuchMethodError: com.intellij.ui.GotItTooltip.show(Ljavax/swing/JComponent;Lkotlin/jvm/functions/Function1;)V
Is there a way to fix it? Since I want to build this plugin mainly for Android developers, I really hope there's a way that I can use these got-it tooltips in Android Studio. Thanks in advance for your help!
-----
A quick follow-up:
I tried to install the plugin on the latest version of IntelliJ IDEA Community Edition (2022.2) and encountered the same error. And then I tried to install it on an older version (2021.1.3) and the tooltips worked fine this time! 2021.1.3 was also the same version I chose when building the plugin for debugging. Not sure if it has something to do with the IDE version because I suppose if it works in older version it should also work in newer version?
Besides, I first saw the tooltip from the copilot plugin installed on an IntelliJ IDEA 2021.3 (Ultimate Edition), while when I installed my plugin in this version, I got "NoSuchMethodError". This makes it feels like I can fix it by correctly adding some dependencies when building my plugin.
Hi,
There is no need to set up any dependencies as GotItTooltip is a part of the platform code and is available in all IntelliJ-based IDEs.
The show() method's signature was changed over time, and it cannot be found in some IDE versions as the function name and/or parameters have changed.
To solve the compatibility issues, you can maintain multiple branches with the code adjusted to the specific target platform versions or just support a narrower set of versions (the one with the latest show() method signature).
Also, consider using Plugin Verifier in your build setup to report compatibility issues during development. See:
https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#runpluginverifier-task
You can check what IntelliJ IDEA versions are used by specific Android Studio versions on the page:
https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html