void (@NotNull final PsiElement expression) { final PyElementGenerator elementGenerator = PyElementGenerator.getInstance(expression.getProject()); final String expressionText = expression.getText(); final StringBuilder stringBuilder = new StringBuilder(expressionText + " ("); final PsiElement next = getNextElement(expression); String commentText = getComment(next); if (next != null) { final String text = next instanceof PyExpressionStatement ? ((PyExpressionStatement)next).getExpression().getText() : next.getText(); stringBuilder.append(text); if (text.endsWith(",")) stringBuilder.append(" end=' '"); next.delete(); } stringBuilder.append(")"); if (commentText != null) { stringBuilder.append(commentText); } expression.replace(elementGenerator.createFromText(LanguageLevel.forElement(expression), PyStatement.class, stringBuilder.toString())); }