void (PsiMethod method, PsiParameter parameter, PsiExpression defToInline) { final MultiMap<PsiElement, @DialogMessage String> conflicts = new MultiMap<>(); Collection<PsiMethod> methods = new ArrayList<>(); methods.add(method); Project project = method.getProject(); boolean preview = IntentionPreviewUtils.isIntentionPreviewActive(); if (!preview) { if (!ProgressManager.getInstance().runProcessWithProgressSynchronously( () -> { methods.addAll(OverridingMethodsSearch.search(method).findAll()); }, JavaBundle.message("progress.title.search.for.overriding.methods"), true, project)) { return; } if (!CommonRefactoringUtil.checkReadOnlyStatus(project, methods, true)) return; } int parameterIndex = method.getParameterList().getParameterIndex(parameter); Map<PsiParameter, Collection<PsiReference>> paramsToInline = new HashMap<>(); for (PsiMethod psiMethod : methods) { PsiParameter psiParameter = psiMethod.getParameterList().getParameters()[parameterIndex]; RefactoringConflictsUtil.getInstance().analyzeMethodConflictsAfterParameterDelete(psiMethod, psiParameter, conflicts); final Collection<PsiReference> refsToInline = ReferencesSearch.search(psiParameter).findAll(); for (PsiReference reference : refsToInline) { PsiElement referenceElement = reference.getElement(); if (referenceElement instanceof PsiExpression && PsiUtil.isAccessedForWriting((PsiExpression)referenceElement)) { conflicts.putValue(referenceElement, JavaBundle.message("dialog.message.parameter.has.write.usages.inline.not.supported")); break; } } paramsToInline.put(psiParameter, refsToInline); } if (!BaseRefactoringProcessor.processConflicts(project, conflicts)) return; if (preview) { inlineParameters(defToInline, paramsToInline); final boolean vararg = parameter.isVarArgs(); parameter.delete(); Collection<PsiReference> calls = ReferencesSearch.search(method, new LocalSearchScope(method.getContainingFile())).findAll(); for (PsiReference call : calls) { PsiElement parent = call.getElement().getParent(); if (parent instanceof PsiMethodCallExpression methodCallExpression) { PsiExpression[] arguments = methodCallExpression.getArgumentList().getExpressions(); if (vararg) { methodCallExpression.deleteChildRange(arguments[parameterIndex], arguments[arguments.length - 1]); } else { arguments[parameterIndex].delete(); } } } } else { WriteAction.run(() -> inlineParameters(defToInline, paramsToInline)); removeParameter(method, parameter); } }