void (@NotNull List<? extends PsiElement> elements, @NotNull PsiElementVisitor elementVisitor, Map<Class<?>, Collection<Class<?>>> targetPsiClasses, List<Class<?>> acceptingPsiTypes) { if (acceptingPsiTypes == InspectionVisitorsOptimizer.ALL_ELEMENTS_VISIT_LIST) { for (int i = 0, elementsSize = elements.size(); i < elementsSize; i++) { PsiElement element = elements.get(i); element.accept(elementVisitor); ProgressManager.checkCanceled(); } } else { Set<Class<?>> accepts = InspectionVisitorsOptimizer.getVisitorAcceptClasses(targetPsiClasses, acceptingPsiTypes); if (accepts == null || accepts.isEmpty()) { return; // nothing to visit in this run } for (int i = 0, elementsSize = elements.size(); i < elementsSize; i++) { PsiElement element = elements.get(i); if (accepts.contains(element.getClass())) { element.accept(elementVisitor); ProgressManager.checkCanceled(); } } } }