Shiraji's Blog

Tips for Creating Intellij Plugin

Summery

There are tips for creating intellij plugins

  • Logging
  • plugin.xml
  • Action

This is note for myself. I won’t add description if the sample is clear enough for me.

Logging

Simply use Sys-out

1
System.out.println("logging...")

However, sys-out shows logs on the console. If you want to show pop up, use notification

Notification

1
2
3
4
Notifications.Bus.notify(Notification("Plugin ID",
                "Title",
                "Content",
                NotificationType.INFORMATION))

plugin.xml

URL of the plugin

1
<idea-plugin url="https://plugins.jetbrains.com/plugin/8262?pr=" version="2">

vendor

1
<vendor email="isogai.shiraji@gmail.com" url="https://github.com/shiraji">Shiraji</vendor>

idea-version

To use kotlin, IDE version should be higher than 143.

1
<idea-version since-build="143"/>

Action class

Creating new action

1
right click src > New > action

Methods

1
override fun actionPerformed(e: AnActionEvent)

Update method

To decide show the action or not, I need to override the update method.

This method should be less than 0.1 sec to complete.

1
2
3
4
5
6
7
8
9
override fun update(e: AnActionEvent?) {
    e ?: return
    super.update(e)

    if (!FindPullRequestModel(e).isEnable()) {
        e.presentation.isEnabled = false
        e.presentation.isVisible = false
    }
}