void (@NotNull PsiElementFactory factory, @NotNull CodeStyleManager codeStyleManager, @NotNull PsiExpression arrayExpression, @NotNull PsiExpression indexExpression, @NotNull PsiElement anchor) { final PsiElement listAccess = factory.createExpressionFromText( arrayExpression.getText() + ".get(" + indexExpression.getText() + ")", anchor); anchor.replace(codeStyleManager.reformat(listAccess)); }