Search code examples
javaintellij-ideaintellij-plugin

Invoke intellij code formatter programmatically on java files


How can I programmatically invoke intellij's java source code formatter on an arbitrary source file on disk?

I don't mind writing a plugin to do this but if there is a way to invoke the formatter from command line that would be great!

Thanks


Solution

  • I ended up writing my own plugin which is available on github. Note that it might need some more fine tuning