Companion object in extensions
Reports incorrect companion objects' usage in IDE extensions.
Kotlin companion object is always created once you try to load its containing class, and IDE extensions are supposed to be cheap to create. Excessive classloading in plugins is a huge problem for IDE startup.
KotlinDocumentationProvider is an extension registered in
In this example
JavaDocumentationProvider will be loaded from disk once someone just calls
Kotlin companion objects in extension implementations can only contain a logger and simple constants. Other declarations may cause excessive classloading or early initialization of heavy resources (e.g. TokenSet, Regex, etc.) when the extension class is loaded.
Instead of being stored in companion object, these declarations must be top-level or stored in an object.
How to rewrite run ConfigurationType?
Move the declaration to top-level:
How to rewrite FileType?
INSTANCE fieldName in
New in 2023.2
IntelliJ IDEA 2023.3, Qodana for JVM 2023.3
Plugin DevKit, 233.SNAPSHOT