PsiElement (@NotNull PsiStatement statement, @NotNull @NonNls String newStatementText) { final Project project = statement.getProject(); final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); final PsiElementFactory factory = psiFacade.getElementFactory(); final PsiStatement newStatement = factory.createStatementFromText(newStatementText, statement); final PsiElement replacementExp = statement.replace(newStatement); final CodeStyleManager styleManager = CodeStyleManager.getInstance(project); return styleManager.reformat(replacementExp); }