boolean (final PsiMethod@NotNull [] allMethods, final Condition<? super PsiMethod> filter) { if (allMethods.length == 0) return true; final List<SmartPsiElementPointer<PsiMethod>> methodPointers = ContainerUtil.map(allMethods, SmartPointerManager::createPointer); final Runnable filterMethods = () -> { final List<SmartPsiElementPointer<PsiMethod>> methods = ReadAction.compute(() -> ContainerUtil.filter(methodPointers, e -> filter.value(e.getElement()))); ApplicationManager.getApplication().invokeLater( () -> methods.stream() .map(e -> e.dereference()) .forEach(myListModel::add) ); }; final ProgressManager progressManager = ProgressManager.getInstance(); return progressManager.runProcessWithProgressSynchronously(filterMethods, ExecutionBundle.message("browse.method.dialog.looking.for.methods"), true, allMethods[0].getProject()); }