19 июл. 2021 г.

IntelliJ Kotlin plugin internals: On-the-flight diagnostics reporting

Background

Highlighting of a Kotlin file prior to Kotlin 1.5 (and Kotlin IntelliJ plugins based on Kotlin before 1.5) in oversimplified way was sequential:
  • run a compiler for a kotlin file
  • collects diagnostics (i.e. errors and warnings) for each PSI element
  • highlight them in a file

Goal

Provide feedback on compilation errors (or warning) as soon as possible.

Impl, details and trade-offs

The biggest concern in a provided highlighting process:

why we have to wait till the end of kotlin file analysis to show errors and warnings?

If you ever compile some file in a console using gcc or javac directly (w/o make or any other build managers), you definitely recall that compilers print diagnostic messages during compilation while entire compilation process for a single file could takes some seconds more.