ActionCallback (JTree tree, Object object, VirtualFile file) { if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug( "AsyncProjectViewSupport.select: " + "object=" + object + ", file=" + file ); } if (object instanceof AbstractTreeNode node) { object = node.getValue(); LOG.debug("select AbstractTreeNode"); if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug("Retrieved the value from the node: " + object); } } PsiElement element = object instanceof PsiElement ? (PsiElement)object : null; LOG.debug("select object: ", object, " in file: ", file); SmartList<TreePath> pathsToSelect = new SmartList<>(); TreeVisitor visitor = AbstractProjectViewPane.createVisitor(element, file, pathsToSelect); if (visitor == null) return ActionCallback.DONE; ActionCallback callback = new ActionCallback(); //noinspection CodeBlock2Expr SelectInProjectViewImplKt.getLOG().debug("Updating nodes before selecting"); myNodeUpdater.updateImmediately(() -> expand(tree, promise -> { SelectInProjectViewImplKt.getLOG().debug("Updated nodes"); promise.onSuccess(o -> callback.setDone()); if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug("Collecting paths to select"); } acceptOnEDT(visitor, () -> { if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug("Collected paths to the element: " + pathsToSelect); } boolean selected = selectPaths(tree, pathsToSelect, visitor); if (selected || element == null || file == null || Registry.is("async.project.view.support.extra.select.disabled")) { if (selected) { SelectInProjectViewImplKt.getLOG().debug("Selected successfully. Done"); } else { SelectInProjectViewImplKt.getLOG().debug("Couldn't select, but there's nothing else to do. Done"); } promise.setResult(null); } else { SelectInProjectViewImplKt.getLOG().debug("Couldn't select the element, falling back to selecting the file"); // try to search the specified file instead of element, // because Kotlin files cannot represent containing functions pathsToSelect.clear(); TreeVisitor fileVisitor = AbstractProjectViewPane.createVisitor(null, file, pathsToSelect); acceptOnEDT(fileVisitor, () -> { if (SelectInProjectViewImplKt.getLOG().isDebugEnabled()) { SelectInProjectViewImplKt.getLOG().debug("Collected paths to the file: " + pathsToSelect); } boolean selectedFile = selectPaths(tree, pathsToSelect, fileVisitor); if (selectedFile) { SelectInProjectViewImplKt.getLOG().debug("Selected successfully. Done"); } else { SelectInProjectViewImplKt.getLOG().debug("Couldn't select, but there's nothing else to do. Done"); } promise.setResult(null); }); } }); })); return callback; }