HotCat is a plugin which provide a set of simple http interfaces. you can use it to get information from idea such as the file or text you selected, or you can send command to idea to control terminal or show dialog and so on.
HotCat is a http api platform, and python plugin is suported. When HotCat is loaded, a http server is started too. The http server receive request then return infomation from IDEA or operate it directly.
python plugin will be called like this:python3 $plugin_dir $local_http_port $idea_event_id
python script then can use local_http_port
to send local http request
All local http request are constructed like this:
requests.post("http://127.0.0.1:$port/api/idea/xxx", data={"eventId": $idea_event_id, "script": $script})
The script
pramater is the most important one, so in the next part, we will make some samples to show how to build it.
-
execute command
script="terminal.setTab(\"this is tab name\") .setScript(\"echo hello\") .addCondition(\"neet input your password\", \"my password\") .start()"
-
get terminal output
script="terminal.getOutPut()"
- start a JVM debug session
script="debugger.setHost(\"debug target host\") .setPort(\"debug target port\") .setDesc(\"this is debug tab name\") .start()"
editor is an instance of com.intellij.openapi.editor.Editor
- get selected text from editor
script="editor.getSelectionModel() .getSelectedText()"
psi_file is an instance of com.intellij.psi.PsiFile
- get selected file path
script="psiFile.getVirtualFile().getPath()"
Download this zip file python_plugin_sample.
Then install it:
Tools -> HotCat -> Install Plugin... -> choose python_plugin_sample.zip
Use it:
Tools -> HotCat -> my-hello-plugin
after click confirm button, you can see echo hello
running in the IDEA terminal.
This IDEA plugin is an orginal version, only few interfaces are complished, and maybe some bugs here. let me know if something troubled you.
test