How to run and debug Intellij plugin
Answered
I've inherited and Intellij plugin that generate code for Android project
It stopped working with Android Studio Bumblebee so I want to debug and fix it.
However, there seems to be no "Plugin" type for run configuration
And when I chose generic application, there is no main class to run
Do I need Intellij Ultimate or something?
plugins.xml
<idea-plugin>
<id>com.coffeemeetsbagel.android_kotlin_component_plugin</id>
<name>Android Kotlin Component Generation</name>
<description>RIB code generation</description>
<idea-version>2020.2.4</idea-version>
<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.java</depends>
<depends>org.jetbrains.android</depends>
<actions>
<action id="generate_component" class="com.myapp.component_generation.GenerateComponent"
text="Generate Kotlin Component"
description="Generates components">
<add-to-group group-id="NewGroup" anchor="last"/>
</action>
</actions>
</idea-plugin>
GenerateComponent.java
public class GenerateComponent extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
PsiDirectory directory = (PsiDirectory) e.getDataContext().getData(LangDataKeys.PSI_ELEMENT);
Project project = e.getDataContext().getData(LangDataKeys.PROJECT);
GenerateComponentDialog dialog = new GenerateComponentDialog(directory, project);
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
@Override
public void update(AnActionEvent e) {
PsiElement psiElement = e.getDataContext().getData(LangDataKeys.PSI_ELEMENT);
if (psiElement instanceof PsiDirectory) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(true);
return;
}
e.getPresentation().setVisible(false);
e.getPresentation().setEnabled(false);
}
}
GenerateComponentDialog seems to be just Java Swing GUI
I can share the plugin full source code upon request
But it's loosely based on https://github.com/uber/RIBs/tree/master/android/tooling/rib-intellij-plugin
Please sign in to leave a comment.
Make sure plugin "Plugin DevKit" is enabled. Please see https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html#running-a-simple-gradle-based-intellij-platform-plugin
Turns out the "plugin development kit" not enabled in Android Studio but it is in Intellij Community Edition which is perfect for me
TIL I can run Intellij inside Intellij with the guide you shared
It's amazingly easy and delightful, thanks a lot Yann Cebron