List<VirtualFile> () { List<VirtualFile> topLevelContentRoots = new ArrayList<>(); ProjectRootManager prm = ProjectRootManager.getInstance(myProject); for (VirtualFile root : prm.getContentRoots()) { VirtualFile parent = root.getParent(); if (!isFileUnderContentRoot(parent)) { topLevelContentRoots.add(root); } } Collection<UnloadedModuleDescription> descriptions = ModuleManager.getInstance(myProject).getUnloadedModuleDescriptions(); for (UnloadedModuleDescription description : descriptions) { for (VirtualFilePointer pointer : description.getContentRoots()) { VirtualFile root = pointer.getFile(); if (root != null) { VirtualFile parent = root.getParent(); if (!isFileUnderContentRoot(parent)) { topLevelContentRoots.add(root); } } } } return topLevelContentRoots; }