UnstableApiUsageInspection: do not run the inspection if no unstable annotation is found in the project.

GitOrigin-RevId: 78b4bfe94f550a5bf92211f90e3e18eb19b1b2b5
This commit is contained in:
Sergey Patrikeev
2019-10-01 10:11:58 +00:00
committed by intellij-monorepo-bot
parent 4c9a3e498a
commit eb9f0e682d
@@ -51,15 +51,23 @@ class UnstableApiUsageInspection : LocalInspectionTool() {
@JvmField
var myIgnoreInsideImports: Boolean = true
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor =
ApiUsageUastVisitor.createPsiElementVisitor(
UnstableApiUsageProcessor(
holder,
myIgnoreInsideImports,
unstableApiAnnotations.toList(),
knownAnnotationMessageProviders
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
val annotations = unstableApiAnnotations.toList()
val psiFacade = JavaPsiFacade.getInstance(holder.project)
val resolveScope = holder.file.resolveScope
return if (annotations.any { psiFacade.findClass(it, resolveScope) != null }) {
ApiUsageUastVisitor.createPsiElementVisitor(
UnstableApiUsageProcessor(
holder,
myIgnoreInsideImports,
annotations,
knownAnnotationMessageProviders
)
)
)
} else {
PsiElementVisitor.EMPTY_VISITOR
}
}
override fun createOptionsPanel(): JPanel {
val checkboxPanel = SingleCheckboxOptionsPanel(