void (UsageInfo @NotNull [] usages) { final List<PsiClassType> thrownExceptions = ExceptionUtil.getThrownCheckedExceptions(myInitializer); final Set<PsiVariable> varsUsedInInitializer = new HashSet<>(); final Set<PsiJavaCodeReferenceElement> paramRefsToInline = new HashSet<>(); final Map<PsiElement, PsiElement> replacements = new HashMap<>(); for (UsageInfo usage : usages) { if (usage instanceof LocalReplacementUsageInfo replacementUsageInfo) { final PsiElement element = replacementUsageInfo.getElement(); final PsiElement replacement = replacementUsageInfo.getReplacement(); if (element != null && replacement != null) { replacements.put(element, replacement); } varsUsedInInitializer.add(replacementUsageInfo.getVariable()); } else { LOG.assertTrue(!myCreateLocal); paramRefsToInline.add((PsiJavaCodeReferenceElement)usage.getElement()); } } myInitializer = (PsiExpression)CommonJavaRefactoringUtil.replaceElementsWithMap(myInitializer, replacements); if (myCreateLocal) { final PsiCodeBlock body = myMethod.getBody(); if (body != null) { PsiElement anchor = findAnchorForLocalVariableDeclaration(body); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(myMethod.getProject()); PsiExpression refExpression = factory.createExpressionFromText(myParameter.getName(), anchor); PsiDeclarationStatement localDeclaration = factory.createVariableDeclarationStatement(myParameter.getName(), myParameter.getType(), refExpression); localDeclaration = (PsiDeclarationStatement)body.addAfter(localDeclaration, anchor); final PsiLocalVariable declaredVar = (PsiLocalVariable)localDeclaration.getDeclaredElements()[0]; PsiUtil.setModifierProperty(declaredVar, PsiModifier.FINAL, myParameter.hasModifierProperty(PsiModifier.FINAL)); InlineUtil.inlineVariable(myParameter, myInitializer, (PsiReferenceExpression)declaredVar.getInitializer()); } } else { for (PsiJavaCodeReferenceElement paramRef : paramRefsToInline) { InlineUtil.inlineVariable(myParameter, myInitializer, paramRef); } } //delete var if it becomes unused for (PsiVariable variable : varsUsedInInitializer) { if (variable != null && variable.isValid()) { if (ReferencesSearch.search(variable).findFirst() == null) { variable.delete(); } } } ChangeSignatureProcessorBase.doChangeSignature(myChangeInfo, myChangeSignatureUsages); if (!thrownExceptions.isEmpty()) { for (PsiClassType exception : thrownExceptions) { PsiClass exceptionClass = exception.resolve(); if (exceptionClass != null) { PsiUtil.addException(myMethod, exceptionClass); } } } }