コード例 #1
0
 private void clearStub(@NotNull String reason) {
   StubTree stubHolder = SoftReference.dereference(myStub);
   if (stubHolder != null) {
     ((PsiFileStubImpl<?>) stubHolder.getRoot()).clearPsi(reason);
   }
   myStub = null;
 }
コード例 #2
0
  @Override
  @Nullable
  public StubTree getStubTree() {
    ApplicationManager.getApplication().assertReadAccessAllowed();

    if (Boolean.TRUE.equals(getUserData(BUILDING_STUB))) return null;

    final StubTree derefd = derefStub();
    if (derefd != null) return derefd;
    if (getTreeElement() != null) return null;

    if (!(getContentElementType() instanceof IStubFileElementType)) return null;

    final VirtualFile vFile = getVirtualFile();
    if (!(vFile instanceof VirtualFileWithId)) return null;

    final PsiFile stubBindingRoot = getViewProvider().getStubBindingRoot();
    if (stubBindingRoot != this) {
      LOG.error(
          "Attempted to create stubs for non-root file: "
              + this
              + ", stub binding root: "
              + stubBindingRoot);
      return null;
    }

    ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), vFile, this);
    if (!(tree instanceof StubTree)) return null;
    StubTree stubHolder = (StubTree) tree;

    synchronized (PsiLock.LOCK) {
      if (getTreeElement() != null) return null;

      final StubTree derefdOnLock = derefStub();
      if (derefdOnLock != null) return derefdOnLock;

      //noinspection unchecked
      ((StubBase) stubHolder.getRoot()).setPsi(this);
      myStub = new SoftReference<StubTree>(stubHolder);
      return stubHolder;
    }
  }
コード例 #3
0
 @Nullable
 public StubElement getStub() {
   StubTree stubHolder = getStubTree();
   return stubHolder != null ? stubHolder.getRoot() : null;
 }