public static void cleanupElements(@NotNull Project project,
                                     @Nullable Runnable runnable,
                                     Predicate<? super ProblemDescriptor> shouldApplyFix,
                                     PsiElement @NotNull ... scope) {
    List<PsiElement> psiElements = Stream.of(scope).filter(e -> e != null && e.isPhysical()).toList();
    if (psiElements.isEmpty()) return;
    GlobalInspectionContextBase globalContext =
      (GlobalInspectionContextBase)InspectionManager.getInstance(project).createNewGlobalContext();
    InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getCurrentProfile();
    AnalysisScope analysisScope = new AnalysisScope(new LocalSearchScope(psiElements.toArray(PsiElement.EMPTY_ARRAY)), project);
    globalContext.codeCleanup(analysisScope, profile, null, runnable, false, shouldApplyFix);
  }
public static void cleanupElements(@NotNull Project project,
                                     @Nullable Runnable runnable,
                                     Predicate<? super ProblemDescriptor> shouldApplyFix,
                                     PsiElement @NotNull ... scope)