PsiExpressionStatement (PsiLocalVariable local, String fieldname, PsiElementFactory factory) { try { String pattern = fieldname + "=0;"; PsiExpressionStatement statement = (PsiExpressionStatement)factory.createStatementFromText(pattern, local); statement = (PsiExpressionStatement)CodeStyleManager.getInstance(local.getProject()).reformat(statement); PsiAssignmentExpression expr = (PsiAssignmentExpression)statement.getExpression(); final PsiExpression initializer = CommonJavaRefactoringUtil.convertInitializerToNormalExpression(local.getInitializer(), local.getType()); expr.getRExpression().replace(initializer); return statement; } catch (IncorrectOperationException e) { LOG.error(e); return null; } }