plugins/devkit/README.md
See org.jetbrains.idea.devkit.inspections.DevKitInspectionUtil for common utility methods.
By default, files located in test sources are not checked,
use DevKitInspectionUtil.isAllowedIncludingTestSources() to include them.
Consider marking inspections with safe-only fixes ready for Code | Code Cleanup...
(com.intellij.codeInspection.CleanupLocalInspectionTool).
Inspections should avoid running whenever they are not applicable in the current context.
Add projectType="INTELLIJ_PLUGIN" in plugin.xml registration to avoid loading inspection in non-plugin projects.
Additional contexts include:
org.jetbrains.idea.devkit.util.PluginPlatformInfo)plugin.xml)com.intellij.openapi.project.IntelliJProjectUtil.isIntelliJPlatformProject())Use org.jetbrains.idea.devkit.inspections.DevKitUastInspectionBase or org.jetbrains.idea.devkit.inspections.DevKitJvmInspection.
See their docs for important considerations.
Implement and register in intellij.devkit.core module.
See Testing Code: JVM Languages.
Use regular LocalInspectionTool with immediate DevKitInspectionUtil.isAllowed(holder.file) check to skip running in non-plugin context.
Implement and register in intellij.kotlin.devkit module.
Extend org.jetbrains.idea.devkit.inspections.DevKitPluginXmlInspectionBase and override checkDomElement() to check specific DOM
elements.
See Testing: Plugin Descriptor
Use light tests only ideally.
See existing base classes like org.jetbrains.idea.devkit.inspections.PluginModuleTestCase
or org.jetbrains.idea.devkit.inspections.quickfix.LightDevKitInspectionFixTestBase.
Add required classes in the test as "mock" containing the minimum set of required signatures.
Same for declaring platform extension points, declare them as "fake" directly in the testdata plugin.xml.
Always write explicit tests for both Java and Kotlin sources.
Tests and test data go to intellij.devkit.java.tests and intellij.devkit.kotlin.tests, respectively.
Related plugin.xml can be put on same level as code test data files.
Test data path constants: org.jetbrains.idea.devkit.DevkitJavaTestsUtil & org.jetbrains.idea.devkit.kotlin.DevkitKtTestsUtil.
Kotlin test data: add @file:Suppress("MISSING_DEPENDENCY_SUPERCLASS") to mute errors from missing Mock SDK classes.
Extend from org.jetbrains.idea.devkit.inspections.PluginXmlDomInspectionTestBase.