private static @NotNull XmlFileHeader calcXmlFileHeader(@NotNull XmlFile file) {

    if (file instanceof PsiFileEx && ((PsiFileEx)file).isContentsLoaded() && file.getNode().isParsed()) {
      return computeHeaderByPsi(file);
    }

    if (FileBasedIndex.getInstance().getFileBeingCurrentlyIndexed() == null &&
        XmlUtil.BUILDING_DOM_STUBS.get() != Boolean.TRUE &&
        file.getFileType() == XmlFileType.INSTANCE) {
      VirtualFile virtualFile = file.getVirtualFile();
      if (virtualFile instanceof VirtualFileWithId) {
        ObjectStubTree<?> tree = StubTreeLoader.getInstance().readFromVFile(file.getProject(), virtualFile);
        if (tree != null && tree.getRoot() instanceof FileStub fileStub) {
          return fileStub.getHeader();
        }
      }
    }

    if (!file.isValid()) return XmlFileHeader.EMPTY;

    XmlFileHeader header = NanoXmlUtil.parseHeader(file);
    if (header.getRootTagLocalName() == null) { // nanoxml failed
      return computeHeaderByPsi(file);
    }
    return header;
  }
private static @NotNull XmlFileHeader calcXmlFileHeader(@NotNull XmlFile file)