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); if (next == null) { stringBuilder.append(")"); expression.replace(elementGenerator.createFromText(LanguageLevel.forElement(expression), PyElement.class, stringBuilder.toString())); return; } final String commentText = getComment(next); if (next instanceof PyExpressionStatement) { final PyExpression expr = ((PyExpressionStatement)next).getExpression(); if (expr instanceof PyBinaryExpression) { final PsiElement operator = ((PyBinaryExpression)expr).getPsiOperator(); if (operator instanceof LeafPsiElement && ((LeafPsiElement)operator).getElementType() == PyTokenTypes.IN_KEYWORD) { addInArguments(stringBuilder, (PyBinaryExpression)expr); } else { stringBuilder.append(next.getText()); } } else if (expr instanceof PyTupleExpression) { final PyExpression[] elements = ((PyTupleExpression)expr).getElements(); if (elements.length > 1) { if (elements[0] instanceof PyBinaryExpression) { addInArguments(stringBuilder, (PyBinaryExpression)elements[0]); } stringBuilder.append(", "); stringBuilder.append(elements[1].getText()); } } else { stringBuilder.append(((PyExpressionStatement)next).getExpression().getText()); } } else { stringBuilder.append(next.getText()); } next.delete(); stringBuilder.append(")"); if (commentText != null) { stringBuilder.append(commentText); } expression.replace(elementGenerator.createFromText(LanguageLevel.forElement(expression), PyStatement.class, stringBuilder.toString())); }