private static void doFix(@NotNull PsiElement tagElement) throws IncorrectOperationException {
    if (tagElement instanceof PsiErrorElement) {
      Collection<OuterLanguageElement> outers = PsiTreeUtil.findChildrenOfType(tagElement, OuterLanguageElement.class);
      String replacement = StringUtil.join(outers, PsiElement::getText, "");
      Document document = getDocument(tagElement);
      if (document != null && !replacement.isEmpty()) {
        TextRange range = tagElement.getTextRange();
        document.replaceString(range.getStartOffset(), range.getEndOffset(), replacement);
      } else {
        tagElement.delete();
      }
    }
    else {
      final ASTNode astNode = tagElement.getNode();
      if (astNode != null) {
        final ASTNode endTagStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(astNode);
        if (endTagStart != null) {
          Document document = getDocument(tagElement);
          if (document != null) {
            document.deleteString(endTagStart.getStartOffset(), tagElement.getLastChild().getTextRange().getEndOffset());
          }
        }
      }
    }
  }
private static void doFix(@NotNull PsiElement tagElement)