@Override
  public TextRange surroundExpression(@NotNull Project project, @NotNull Editor editor, @NotNull PyExpression expression)
    throws IncorrectOperationException {
    TextRange currentCaretPosition = TextRange.from(editor.getCaretModel().getOffset(), 0);
    PyStatement statement = PyElementGenerator.getInstance(project).
      createFromText(LanguageLevel.forElement(expression), PyStatement.class, getTextToGenerate());
    final PyExpression condition = getCondition(statement);
    if (condition == null) {
      return currentCaretPosition;
    }
    condition.replace(expression);
    statement = (PyStatement)CodeStyleManager.getInstance(project).reformat(statement);
    statement = (PyStatement)expression.getParent().replace(statement);
    PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
    PyStatementListContainer statementListContainer = getStatementListContainer(statement);
    if (statementListContainer == null) {
      return currentCaretPosition;
    }
    PyStatementList statementList = statementListContainer.getStatementList();
    PyStatement[] statements = statementList.getStatements();
    if (statements.length == 0) {
      return currentCaretPosition;
    }
    final TextRange range = statements[0].getTextRange();
    editor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset());
    return TextRange.from(range.getStartOffset(), 0);
  }
@Override
  public TextRange surroundExpression(@NotNull Project project, @NotNull Editor editor, @NotNull PyExpression expression)