@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); }
public static ElementStub getRootStub(@TestDataFile String filePath, JavaCodeInsightTestFixture fixture) { PsiFile psiFile = fixture.configureByFile(filePath); StubTreeLoader loader = StubTreeLoader.getInstance(); VirtualFile file = psiFile.getVirtualFile(); assertTrue(loader.canHaveStub(file)); ObjectStubTree stubTree = loader.readFromVFile(fixture.getProject(), file); assertNotNull(stubTree); ElementStub root = (ElementStub)stubTree.getRoot(); assertNotNull(root); return root; }
public void testNullTag() throws Exception { VirtualFile virtualFile = myFixture.copyFileToProject("nullTag.xml"); assertNotNull(virtualFile); PsiFile psiFile = ((PsiManagerEx)getPsiManager()).getFileManager().findFile(virtualFile); StubTreeLoader loader = StubTreeLoader.getInstance(); VirtualFile file = psiFile.getVirtualFile(); assertTrue(loader.canHaveStub(file)); ObjectStubTree stubTree = loader.readFromVFile(getProject(), file); assertNull(stubTree); // no stubs for invalid XML }
@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; if (XmlUtil.isStubBuilding() && file.getFileType() == XmlFileType.INSTANCE) { FileContent fileContent = file.getUserData(DomStubBuilder.CONTENT_FOR_DOM_STUBS); if (fileContent != null) { //noinspection IOResourceOpenedButNotSafelyClosed return NanoXmlUtil.parseHeader(new CharSequenceReader(fileContent.getContentAsText())); } } return NanoXmlUtil.parseHeader(file); }
public static ElementStub getRootStub(String filePath, JavaCodeInsightTestFixture fixture) { PsiFile psiFile = fixture.configureByFile(filePath); StubTreeLoader loader = StubTreeLoader.getInstance(); VirtualFile file = psiFile.getVirtualFile(); assertTrue(loader.canHaveStub(file)); ObjectStubTree stubTree = loader.readFromVFile(fixture.getProject(), file); assertNotNull(stubTree); ElementStub root = (ElementStub)stubTree.getRoot(); assertNotNull(root); return root; }
protected XmlFile prepareFile(String path) { XmlFile file = (XmlFile)myFixture.configureByFile(path); assertFalse(file.getNode().isParsed()); VirtualFile virtualFile = file.getVirtualFile(); assertNotNull(virtualFile); ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), virtualFile, file); assertNotNull(tree); ((PsiManagerImpl)getPsiManager()).cleanupForNextTest(); file = (XmlFile)getPsiManager().findFile(virtualFile); assertNotNull(file); return file; }
public void testNullTag() throws Exception { PsiFile psiFile = myFixture.configureByFile("nullTag.xml"); StubTreeLoader loader = StubTreeLoader.getInstance(); VirtualFile file = psiFile.getVirtualFile(); assertTrue(loader.canHaveStub(file)); ObjectStubTree stubTree = loader.readFromVFile(getProject(), file); assertNull(stubTree); // no stubs for invalid XML }