void (@NotNull ActionContext context, @NotNull PsiLocalVariable variable, @NotNull ModPsiUpdater updater) { final PsiVariable refVariable = findPreviousVariable(variable); if (refVariable == null) return; final PsiExpression initializer = variable.getInitializer(); if (initializer == null) { variable.delete(); return; } boolean wasFinal = refVariable.hasModifierProperty(PsiModifier.FINAL); PsiUtil.setModifierProperty(refVariable, PsiModifier.FINAL, false); final PsiElementFactory factory = JavaPsiFacade.getElementFactory(variable.getProject()); final PsiElement statement = factory.createStatementFromText( variable.getName() + " = " + ExpressionUtils.convertInitializerToExpression(initializer, factory, variable.getType()).getText() + ";", null); variable.getParent().replace(statement); if (wasFinal && refVariable instanceof PsiLocalVariable && HighlightControlFlowUtil.isEffectivelyFinal(refVariable, initializer, null)) { PsiUtil.setModifierProperty(refVariable, PsiModifier.FINAL, true); } }