diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/InspectionVisitorOptimizer.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/InspectionVisitorOptimizer.java index f8e2b8ad565a..e0c4308ded9a 100644 --- a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/InspectionVisitorOptimizer.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/InspectionVisitorOptimizer.java @@ -35,6 +35,7 @@ import java.lang.reflect.Modifier; import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import java.util.function.Function; /** * Infers classes of elements for inspection visitors to skip some of the PSI elements during inspection pass. @@ -80,6 +81,14 @@ public final class InspectionVisitorOptimizer { return acceptingPsiTypes; } + private static final Function, Collection>> TARGET_PSI_CLASSES_INIT = aSuper -> { + List> c = new ArrayList<>(10); + if (!aSuper.isInterface() && !Modifier.isAbstract(aSuper.getModifiers())) { // PSI elements in the tree cannot be abstract + c.add(aSuper); + } + return c; + }; + private static @NotNull Map, Collection>> getTargetPsiClasses(@NotNull List elements) { if (!useOptimizedVisitors) return Collections.emptyMap(); @@ -92,13 +101,7 @@ public final class InspectionVisitorOptimizer { // this check guarantees that items are unique in value collections, so we can use simple lists inside if (uniqueElementClasses.add(elementClass)) { for (Class aSuper : SELF_AND_SUPERS.get(elementClass)) { - Collection> classes = targetPsiClasses.computeIfAbsent(aSuper, aClass -> { - List> c = new ArrayList<>(10); - if (!aSuper.isInterface() && !Modifier.isAbstract(aSuper.getModifiers())) { // PSI elements in the tree cannot be abstract - c.add(aSuper); - } - return c; - }); + Collection> classes = targetPsiClasses.computeIfAbsent(aSuper, TARGET_PSI_CLASSES_INIT); classes.add(elementClass); } }