@NotNull private static XmlFileHeader calcXmlFileHeader(final XmlFile file) { if (file instanceof PsiFileEx && ((PsiFileEx) file).isContentsLoaded() && file.getNode().isParsed()) { return computeHeaderByPsi(file); } if (!XmlUtil.isStubBuilding() && 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; return NanoXmlUtil.parseHeader(file); }
@Nullable public DomExtensionsRegistrarImpl extend( @NotNull final Project project, @NotNull final DomInvocationHandler handler, @Nullable DomExtensionsRegistrarImpl registrar) { if (myExtender == null) { try { myDomClass = findClass(domClassName); myExtender = instantiate(extenderClassName, project.getPicoContainer()); } catch (Exception e) { LOG.error(e); return null; } } if (myDomClass.isAssignableFrom(handler.getRawType())) { if (!myExtender.supportsStubs() && XmlUtil.isStubBuilding()) return registrar; if (registrar == null) { registrar = new DomExtensionsRegistrarImpl(); } //noinspection unchecked myExtender.registerExtensions(handler.getProxy(), registrar); } return registrar; }