@Override
  protected void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyStatement element) {
    Document document = editor.getDocument();
    PyMatchStatement matchStatement = as(element, PyMatchStatement.class);
    if (matchStatement != null) {
      PsiElement colon = PyPsiUtils.getFirstChildOfType(element, PyTokenTypes.COLON);
      assert colon != null;
      int colonEndOffset = colon.getTextRange().getEndOffset();
      // It's not enough to check matchStatement.getCaseClauses().isEmpty()
      boolean hasEmptyBody = colonEndOffset == matchStatement.getTextRange().getEndOffset();
      if (hasEmptyBody) {
        String matchIndent = PyIndentUtil.getElementIndent(element);
        String indent = PyIndentUtil.getIndentFromSettings(element.getContainingFile());
        String caseClausePlaceholder = "\n" + matchIndent + indent + PyNames.CASE + " :";
        document.insertString(colonEndOffset, caseClausePlaceholder);
        processor.registerUnresolvedError(colonEndOffset + caseClausePlaceholder.length() - 1);
      }
      return;
    }

    PyTypeDeclarationStatement typeDeclaration = as(element, PyTypeDeclarationStatement.class);
    // "match:" case
    if (typeDeclaration != null && isMatchIdentifier(typeDeclaration.getTarget())) {
      PyAnnotation annotation = typeDeclaration.getAnnotation();
      if (annotation != null && annotation.getValue() == null) {
        processor.registerUnresolvedError(annotation.getTextRange().getStartOffset());
        return;
      }
    }

    Couple<PsiElement> pair = findMatchKeywordAndSubjectInExpressionStatement(element);
    PsiElement matchKeyword = pair.getFirst();
    if (matchKeyword == null) {
      return;
    }
    PsiElement subject = pair.getSecond();
    if (subject != null) {
      int endOffset = subject.getTextRange().getEndOffset();
      String matchIndent = PyIndentUtil.getElementIndent(matchKeyword);
      String indent = PyIndentUtil.getIndentFromSettings(element.getContainingFile());
      String caseClausePlaceholder = ":\n" + matchIndent + indent + PyNames.CASE + " :";
      document.insertString(endOffset, caseClausePlaceholder);
      processor.registerUnresolvedError(endOffset + caseClausePlaceholder.length() - 1);
    }
    else {
      int endOffset = element.getTextRange().getEndOffset();
      document.insertString(endOffset, " :");
      processor.registerUnresolvedError(endOffset + 1);
    }
  }
@Override
  protected void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyStatement element)