void (@NotNull PsiLiteralExpression toReplace, @NotNull String newTextBlock) { Project project = toReplace.getProject(); PsiExpression replacement = JavaPsiFacade.getElementFactory(project).createExpressionFromText(newTextBlock, toReplace); CodeStyleManager.getInstance(project).performActionWithFormatterDisabled(() -> toReplace.replace(replacement)); }