Search code examples
javaintellij-ideajavac

How to configure Javac plugin in IntelliJ IDEA


I run a custom compiler plugin with the -Xplugin:MyPlugin switch, which injects some extra methods into my classes. I set the additional command line parameters under

Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler

Everything builds just fine, but in the IDEA editor every call of the generated methods is highlighted red, and also autocomplete does not work.

What else can I configure to make it recognize the generated methods?


Solution

  • You need to write a plugin for IntelliJ IDEA to make it aware of the methods you generate. On-the-fly code analysis in IntelliJ IDEA uses its own parser and reference resolution implementation; it does not use javac, and cannot be extended by writing javac plugins.

    The main entry point for such a plugin is the PsiAugmentProvider class.