void (String newExpression, PyBinaryExpression expression) { PsiElement expressionToReplace = expression; String expString = "not(" + newExpression + ')'; final PsiElement parent = expression.getParent().getParent(); if (isNegation(parent)) { expressionToReplace = parent; expString = newExpression; } final PyElementGenerator generator = PyElementGenerator.getInstance(expression.getProject()); final PyExpression newCall = generator.createExpressionFromText(LanguageLevel.forElement(expression), expString); expressionToReplace.replace(newCall); // codeStyleManager = expression.getManager().getCodeStyleManager() // TODO codeStyleManager.reformat(insertedElement) }