类com.intellij.psi.stubs.PsiFileStub源码实例Demo

下面列出了怎么用com.intellij.psi.stubs.PsiFileStub的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: consulo   文件: SubstrateRef.java
@Nonnull
@Override
public PsiFile getContainingFile() {
  StubElement stub = myStub;
  while (!(stub instanceof PsiFileStub)) {
    stub = stub.getParentStub();
  }
  PsiFile psi = (PsiFile)stub.getPsi();
  if (psi != null) {
    return psi;
  }
  return reportError(stub);
}
 
@NonNls
@Nonnull
private static String reason(@Nonnull PsiElement root) {
  if (root == PsiUtilCore.NULL_PSI_ELEMENT) return "NULL_PSI_ELEMENT";

  PsiElement element = root instanceof PsiFile ? root : root.getParent();
  if (element == null) {
    String m = "parent is null";
    if (root instanceof StubBasedPsiElement) {
      StubElement stub = ((StubBasedPsiElement)root).getStub();
      while (stub != null) {
        m += "\n  each stub=" + stub;
        if (stub instanceof PsiFileStub) {
          m += "; fileStub.psi=" + stub.getPsi() + "; reason=" + ((PsiFileStub)stub).getInvalidationReason();
        }
        stub = stub.getParentStub();
      }
    }
    return m;
  }

  while (element != null && !(element instanceof PsiFile)) element = element.getParent();
  PsiFile file = (PsiFile)element;
  if (file == null) return "containing file is null";

  FileViewProvider provider = file.getViewProvider();
  VirtualFile vFile = provider.getVirtualFile();
  if (!vFile.isValid()) return vFile + " is invalid";
  if (!provider.isPhysical()) {
    PsiElement context = file.getContext();
    if (context != null && !context.isValid()) {
      return "invalid context: " + reason(context);
    }
  }

  PsiManager manager = file.getManager();
  if (manager.getProject().isDisposed()) return "project is disposed";

  Language language = file.getLanguage();
  if (language != provider.getBaseLanguage()) return "File language:" + language + " != Provider base language:" + provider.getBaseLanguage();

  FileViewProvider p = manager.findViewProvider(vFile);
  if (provider != p) return "different providers: " + provider + "(" + id(provider) + "); " + p + "(" + id(p) + ")";

  if (!provider.isPhysical()) return "non-physical provider: " + provider; // "dummy" file?

  return "psi is outdated";
}
 
 类所在包
 类方法
 同包方法