List<OrderEntry> (@NotNull VirtualFile file) { List<VirtualFile> roots = getHierarchy(file, myAllRoots, myRootInfo); if (roots == null) { return Collections.emptyList(); } Stack<Node> stack = new Stack<>(roots.size()); for (VirtualFile root : roots) { Collection<Node> nodes = myRoots.get(root); for (Node node : nodes) { stack.push(node); } } Set<Node> seen = new HashSet<>(stack.size()); List<OrderEntry> result = new ArrayList<>(stack.size()); while (!stack.isEmpty()) { Node node = stack.pop(); if (!seen.add(node)) { continue; } for (Edge edge : node.myEdges) { result.add(edge.myOrderEntry); if (edge.myRecursive) { Node targetNode = myGraph.myNodes.get(edge.myKey); if (targetNode != null) { stack.push(targetNode); } } } } Pair<VirtualFile, List<Condition<? super VirtualFile>>> libraryClassRootInfo = myRootInfo.findLibraryRootInfo(roots, false); Pair<VirtualFile, List<Condition<? super VirtualFile>>> librarySourceRootInfo = myRootInfo.findLibraryRootInfo(roots, true); result.addAll(myRootInfo.getLibraryOrderEntries(roots, Pair.getFirst(libraryClassRootInfo), Pair.getFirst(librarySourceRootInfo), myLibClassRootEntries, myLibSourceRootEntries)); VirtualFile moduleContentRoot = myRootInfo.findNearestContentRoot(roots); if (moduleContentRoot != null) { ContainerUtil.addIfNotNull(result, myRootInfo.getModuleSourceEntry(roots, moduleContentRoot, myLibClassRootEntries)); } result.sort(BY_OWNER_MODULE); return List.copyOf(result); }