Java 类com.intellij.psi.stubs.ObjectStubTree 实例源码

项目:intellij-ce-playground    文件:DomServiceImpl.java   
@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);
}
项目:intellij-ce-playground    文件:DomStubTest.java   
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;
}
项目:intellij-ce-playground    文件:DomStubBuilderTest.java   
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
}
项目:tools-idea    文件:DomServiceImpl.java   
@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);
}
项目:tools-idea    文件:DomStubTest.java   
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;
}
项目:tools-idea    文件:DomStubTest.java   
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;
}
项目:tools-idea    文件:DomStubBuilderTest.java   
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
}
项目:consulo-xml    文件:DomServiceImpl.java   
@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);
}