public @NotNull StubTree calcStubTree() {
    StubTree tree = derefStub();
    if (tree != null) {
      return tree;
    }
    FileElement fileElement = calcTreeElement();
    try {
      synchronized (myPsiLock) {
        tree = derefStub();

        if (tree == null) {
          assertReadAccessAllowed();
          IStubFileElementType<?> contentElementType = getElementTypeForStubBuilder();
          if (contentElementType == null) {
            VirtualFile vFile = getVirtualFile();
            String message = "ContentElementType: " + getContentElementType() +
                             "; file: " + this + (vFile.isValid() ? "" : " (" + vFile + " invalid)") +
                             "\n\t" + "Boolean.TRUE.equals(getUserData(BUILDING_STUB)) = " + Boolean.TRUE.equals(getUserData(BUILDING_STUB)) +
                             "\n\t" + "getTreeElement() = " + getTreeElement() +
                             "\n\t" + "vFile instanceof VirtualFileWithId = " + (vFile instanceof VirtualFileWithId) +
                             "\n\t" + "StubUpdatingIndex.canHaveStub(vFile) = " + StubTreeLoader.getInstance().canHaveStub(vFile);
            rebuildStub();
            throw new AssertionError(message);
          }

          StubElement<?> currentStubTree = contentElementType.getBuilder().buildStubTree(this);
          if (currentStubTree == null) {
            throw new AssertionError("Stub tree wasn't built for " + contentElementType + "; file: " + this);
          }

          tree = new StubTree((PsiFileStub<?>)currentStubTree);
          tree.setDebugInfo("created in calcStubTree");
          updateTrees(myTrees.withStub(tree, fileElement));
        }

        return tree;
      }
    }
    catch (StubTreeLoader.StubTreeAndIndexUnmatchCoarseException e) {
      throw e.createCompleteException();
    }
  }
public @NotNull StubTree calcStubTree()