Comprehensive Guide to Developing IntelliJ IDEA Plugins: Setup, Actions, UI Thread, Background Tasks, VFS, PSI, and UI Components
This article provides a step‑by‑step tutorial on creating IntelliJ IDEA plugins, covering environment preparation, project creation, defining actions, updating plugin.xml, handling UI threads, launching background tasks, using ProgressManager, working with the Virtual File System and PSI, and leveraging the platform's UI components.
Author : Gu Xuan Yu – Android developer at Tongtian Tower Technology Open Group.
Before starting development, install Java SDK, be proficient in Java (preferably Kotlin), and download the IntelliJ IDEA Community edition (required for Android Studio plugin development). Also clone the IDEA community source code and review the official SDK documentation.
Getting Started
Create a new plugin project by selecting IntelliJ Platform Plugin in the wizard and follow the steps.
1. Create a New Action
In the src package, add a new Action class and fill in the required fields in the plugin.xml wizard:
Action ID – unique identifier, usually package.ClassName
Class Name – name of the Action class
Name – text displayed in the UI
Description – brief description
Groups – the group where the action will appear
After confirming, the plugin.xml entry is automatically added:
<actions>
<!-- Add your actions here -->
<action id="xxx" class="xxx" text="xxx"/>
</actions>The anchor attribute determines the action's position within the group (first, last, before, after).
2. Implement the Action Logic
Override public void actionPerformed(AnActionEvent e) and, for a simple Hello World example, show a message dialog:
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
Messages.showMessageDialog(project, "helloworld", "mytitle", Messages.getInformationIcon());
}Run the plugin; the new action appears in the IDE and displays the dialog when invoked.
3. Advanced Topics
Event Thread UI Updates
UI updates must occur on the event thread. Use ApplicationManager.getApplication().invokeLater(...) to schedule UI changes after background work.
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
// update UI
}
});Starting Background Tasks
Use ProgressManager to run long‑running operations without blocking the UI:
ProgressManager.getInstance().run(new Runnable() {
public void run() {
// background work
}
});Progress Bar Tasks
Create a class extending Task.Backgroundable and execute it via BackgroundTaskQueue :
new BackgroundTaskQueue(project, "my-task-name").run(new MyTask());Virtual File System (VFS)
VFS provides a unified API for handling files regardless of their physical location. It supports refreshing, retrieving VirtualFile instances, and attaching persistent data.
Program Structure Interface (PSI)
PSI represents the parsed structure of files, enabling syntax and semantic analysis. It is essential for language‑specific features.
UI Components
The IntelliJ platform offers many custom Swing components such as tool windows, dialogs, popups, notifications, file/class choosers, editor components, and list/tree controls, ensuring a consistent look and feel.
Conclusion
VFS and PSI are core modules for plugin development. Reviewing open‑source plugins and the official documentation helps deepen understanding.
References
AndroidStudio plugin development (HelloWorld) by huachao1001 – https://blog.csdn.net/huachao1001/article/details/53856916
IntelliJ IDEA SDK documentation – http://www.jetbrains.org/intellij/sdk/docs
IntelliJ Community source code – https://github.com/JetBrains/intellij-community
JD Retail Technology
Official platform of JD Retail Technology, delivering insightful R&D news and a deep look into the lives and work of technologists.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.