void (@Nullable PsiElement rootElement) { Block rootBlock = rootElement == null ? null : buildBlocks(rootElement); if (rootBlock == null) { myTreeModel = null; myBlockTree.setRootVisible(false); myBlockTree.setVisible(false); return; } myBlockTree.setVisible(true); BlockTreeStructure blockTreeStructure = new BlockTreeStructure(); BlockTreeNode rootNode = new BlockTreeNode(rootBlock, null); StructureTreeModel treeModel = new StructureTreeModel<>(blockTreeStructure, myTreeModelDisposable); initMap(rootNode, rootElement); assert myPsiToBlockMap != null; PsiElement rootPsi = rootNode.getBlock() instanceof ASTBlock ? ((ASTBlock)rootNode.getBlock()).getNode().getPsi() : rootElement; BlockTreeNode blockNode = myPsiToBlockMap.get(rootPsi); if (blockNode == null) { PsiViewerDialog.LOG.error("PsiViewer: rootNode not found\nCurrent language: " + rootElement.getContainingFile().getLanguage(), (Throwable)null, CoreAttachmentFactory.createAttachment(rootElement.getContainingFile().getOriginalFile().getVirtualFile())); blockNode = findBlockNode(rootPsi); } blockTreeStructure.setRoot(blockNode); myTreeModel = new AsyncTreeModel(treeModel, myTreeModelDisposable); myBlockTree.setModel(myTreeModel); myBlockTree.addTreeSelectionListener(new BlockTreeSelectionListener(rootElement)); myBlockTree.setRootVisible(true); myBlockTree.expandRow(0); treeModel.invalidateAsync(); }