Wednesday, September 16, 2015

Using IDE scripting console in Intellij IDEA

Some time ago, Intellij added option to write simple scripts to automate it's functions, extract information and write simple plugins. It is located under Tools / IDE scripting console. It is very basic now, just scripting file that runs inside of Intellij JVM and has access to Intellij API.

 There is simple Groovy example that automatically adds non-suspending breakpoint with log expression:

import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.project.ProjectManager
import com.intellij.xdebugger.breakpoints.SuspendPolicy

def file = LocalFileSystem.getInstance().findFileByPath("/users/test/project/src/Test.java")
def doc = FileDocumentManager.getInstance().getDocument(file)
def bp = ProjectManager.getInstance().getOpenProjects()[0].getComponent("DebuggerManager").getBreakpointManager().addLineBreakpoint(doc, 11)
bp.getXBreakpoint().setLogExpression('"test"')
bp.getXBreakpoint().setSuspendPolicy(SuspendPolicy.NONE)


Of course, this basic task can be done through XML configuration, but IDE scripting has access to much more and can do trickier tasks. There is very cool demo. Generally, from what I have seen, API is pretty impressive, it is intuitive, powerful and easy to start with.

My biggest complains are that it is pretty verbose (as Java itself), it would be great if in future versions it would be solved at least at tooling levels - with auto imports for packages, autocompletion, and more convenience functions, like attaching to actions, getting projects or files quickly. Second problem is total lack of documentation. Basically, what I have found is only GitHub repo of Intellij community edition. It has multiple modules with API scattered across them, most generic classes are under Core API.

10 comments:

  1. Hi,

    Apologies for promoting my own plugin, but in case you didn't come across it https://github.com/dkandalov/live-plugin

    It has similar features and imho is a bit more practical than IDE console (at least at the moment, no idea what plans jetbrains have for it).

    ReplyDelete
  2. shrewd. PhpStorm 2017, discharged on March 23rd, 2017, is only a fresh out of the plastic new

    ReplyDelete
  3. I beloved as much as you’ll obtain performed proper here. The comic strip is attractive, your authored subject matter stylish. however, you command get got an nervousness over that you want be handing over the following. in poor health indisputably come further previously again since exactly the same nearly a lot often inside case you defend this hike. 7 days to die reddit

    ReplyDelete
  4. I guess I am the only one who came here to share my very own experience. Guess what!? I am using my laptop for almost the past 2 years, but I had no idea of solving some basic issues.
    https://free4crack.net/wp-admin/
    JetBrains PhpStorm Crack

    ReplyDelete
  5. This site have particular software articles which emits an impression of being a significant and significant for you individual, able software installation.This is the spot you can get helps for any software installation, usage and cracked.
    https://crackexe.net/https://crackexe.net/
    phpstorm-crack
    malwarebytes-premium-crack
    apowerrec-crack
    garmin-basecamp-crack
    beecut-crack
    netbalancer-crack
    debut-video-capture-crack
    openshot-video-editor-crack

    ReplyDelete
  6. I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
    Very interesting blog.visit my wepsite https://vstking.net/

    JetBrains PhpStorm Crack

    Resolume Arena crack

    SmartDraw crack

    Wondershare Filmora crack

    ReplyDelete
  7. Many thanks for sharing such incredible knowledge Of TagSpaces Crack. It's really good for your Website.
    The info on your website inspires me greatly. This website I'm bookmarked. Maintain it and thanks again.
    I'm really impressed with your writing skills, as smart as the structure of your weblog.

    JetBrains PhpStorm

    ReplyDelete
  8. I thought this was a pretty interesting read when it comes to this topic. Thank you
    phpstorm-crack
    window-12-pro-crack
    videoproc-crac
    pdf-expert-crack-2

    ReplyDelete