protected boolean invokeProcessor(@NotNull final Project project,
                                    @NotNull final Editor editor,
                                    @NotNull final PsiFile psiFile,
                                    boolean afterCompletion) {
    final Document document = editor.getDocument();
    final CharSequence textForRollback = document.getImmutableCharSequence();
    try {
      editor.putUserData(SMART_ENTER_TIMESTAMP, editor.getDocument().getModificationStamp());
      myFirstErrorOffset = Integer.MAX_VALUE;
      process(project, editor, psiFile, 0, afterCompletion);
    }
    catch (TooManyAttemptsException e) {
      document.replaceString(0, document.getTextLength(), textForRollback);
    }
    finally {
      editor.putUserData(SMART_ENTER_TIMESTAMP, null);
    }
    return true;
  }
protected boolean invokeProcessor(@NotNull final Project project,
                                    @NotNull final Editor editor,
                                    @NotNull final PsiFile psiFile,
                                    boolean afterCompletion)