Using refactorings outside of the gui


I've been trying to intellij refactorings outside of the GUI with the idea of using them from maven. Specifically, I was trying to get an "optimize imports" to work in a headless application so that I could later incorpate this into maven builds and have it happen every time we do a build in CI.

I tried using JavaCoreApplicationEnvironment and friends as this seemed like the lightest weight way to do it. This didn't seem to give me enough to perform this operation. I also saw that there are tests for this operation so I tried pulling out bits of this but couldn't get this to work either. From some reading around, it seems like the way to do this might be to create a product that includes a minimal amount of plugins. This sounds a bit more heavyweight than I was hoping for, but it might still be ok.

Would it be possible to get some pointers on this? Which of these (if any) sound like the right aproach? Also, do you know of any example code I could look at of something headless doing code manipulation in this way?


Please sign in to leave a comment.