void (@NotNull VirtualFile file) { boolean flattenPackages = root.getSettings().isFlattenPackages(); if (flattenPackages) { ProjectFileIndex index = getProjectFileIndex(root.getProject()); VirtualFile ancestor = index == null ? null : index.getSourceRootForFile(file); if (ancestor != null && VfsUtilCore.isAncestor(ancestor, file, true)) { // TODO: check that file is located under a source root with packages file = ancestor; } else { flattenPackages = false; } } boolean resolveCompactedFolder = !flattenPackages && file.isDirectory() && root.getSettings().isCompactDirectories(); find(file, null, found -> { if (found instanceof Node node) { if (resolveCompactedFolder) { AbstractTreeNode<?> parent = node.getParent(); if (parent instanceof Node) { node = (Node)parent; } } if (node.childrenValid) { node.childrenValid = false; update(node, true); } } else if (found instanceof AbstractTreeNode) { update((AbstractTreeNode<?>)found, true); } }); }