XmlFileHeader (@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) { Stub root = tree.getRoot(); if (root instanceof FileStub) { return ((FileStub)root).getHeader(); } } } } if (!file.isValid()) return XmlFileHeader.EMPTY; XmlFileHeader header = NanoXmlUtil.parseHeader(file); if (header.getRootTagLocalName() == null) { // nanoxml failed return computeHeaderByPsi(file); } return header; }