List<ParameterInfoImpl> (@NotNull Project project, final Editor editor, final PsiFile file, @NotNull PsiMethod method, final int minUsagesNumber, final ParameterInfoImpl[] newParametersInfo, final boolean changeAllUsages, final boolean allowDelegation, @Nullable final Consumer<? super List<ParameterInfo>> callback) { if (!FileModificationService.getInstance().prepareFileForWrite(method.getContainingFile())) return null; final FindUsagesManager findUsagesManager = ((FindManagerImpl)FindManager.getInstance(project)).getFindUsagesManager(); final FindUsagesHandler handler = findUsagesManager.getFindUsagesHandler(method, false); if (handler == null) return null;//on failure or cancel (e.g. cancel of super methods dialog) final JavaMethodFindUsagesOptions options = new JavaMethodFindUsagesOptions(project); options.isImplementingMethods = true; options.isOverridingMethods = true; options.isUsages = true; options.isSearchForTextOccurrences = false; final int[] usagesFound = new int[1]; Runnable runnable = () -> { Processor<UsageInfo> processor = t -> ++usagesFound[0] < minUsagesNumber; handler.processElementUsages(method, processor, options); }; String progressTitle = QuickFixBundle.message("searching.for.usages.progress.title"); if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(runnable, progressTitle, true, project)) return null; if (ApplicationManager.getApplication().isUnitTestMode() || usagesFound[0] < minUsagesNumber) { ChangeSignatureRefactoring processor = JavaRefactoringFactory.getInstance(project) .createChangeSignatureProcessor(method, false, null, method.getName(), method.getReturnType(), newParametersInfo, null, null, null, callback); processor.run(); ApplicationManager.getApplication().runWriteAction(() -> UndoUtil.markPsiFileForUndo(file)); return Arrays.asList(newParametersInfo); } else { final List<ParameterInfoImpl> parameterInfos = newParametersInfo != null ? new ArrayList<>(Arrays.asList(newParametersInfo)) : new ArrayList<>(); final PsiReferenceExpression refExpr = JavaTargetElementEvaluator.findReferenceExpression(editor); JavaChangeSignatureDialog dialog = JavaChangeSignatureDialog.createAndPreselectNew(project, method, parameterInfos, allowDelegation, refExpr, callback); dialog.setParameterInfos(parameterInfos); dialog.show(); return dialog.isOK() ? dialog.getParameters() : null; } }