Almost all user actions in IntelliJ are implemented as instances of AnAction class (including basic things like moving cursor or deleting characters). This means it is possible to simulate user actions in a script similar to recording a macros (Main Menu -> Edit -> Macros
) but in a more flexible way.
There are several ways to find existing actions in IDE:
import static liveplugin.PluginUtil.* import static liveplugin.implementation.ActionSearch.allActionIds if (isIdeStartup) return show(allActions().findAll { it.class.simpleName.contains("ToolWindow") }) show(allActionIds().findAll { it.contains("ToolWindow") }) def action = actionById("ActivateProjectToolWindow") // or ActionManager.instance.getAction("ActivateProjectToolWindow") // Once you have instance of an action, you can invoke it like this action.actionPerformed(anActionEvent())
As an example of a non-linear macro, here is an automated version of Null Pointer Driven Development enterprise best practice (to be clear, this is sarcasm):
import static liveplugin.PluginUtil.* if (isIdeStartup) return doInBackground { registerConsoleListener("NPEConsoleListener") { consoleText -> if (consoleText.contains("NullPointerException")) { invokeOnEDT { actionById("Stop").actionPerformed(anActionEvent()) } show("The process was stopped because of NullPointerException") unregisterConsoleListener("NPEConsoleListener") } } invokeOnEDT { executeRunConfiguration("VeryEnterpriseProjectMain", project) } }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4