@Nullable private Pair<Set<String>, Set<String>> getAllRoots(boolean includeSourceRoots) { if (myProject.isDefault()) return null; final Set<String> recursive = new HashSet<String>(); final Set<String> flat = new HashSet<String>(); final String projectFilePath = myProject.getProjectFilePath(); final File projectDirFile = new File(projectFilePath).getParentFile(); if (projectDirFile != null && projectDirFile.getName().equals(Project.DIRECTORY_STORE_FOLDER)) { recursive.add(projectDirFile.getAbsolutePath()); } else { flat.add(projectFilePath); final VirtualFile workspaceFile = myProject.getWorkspaceFile(); if (workspaceFile != null) { flat.add(workspaceFile.getPath()); } } for (WatchedRootsProvider extension : Extensions.getExtensions(WatchedRootsProvider.EP_NAME, myProject)) { recursive.addAll(extension.getRootsToWatch()); } final Module[] modules = ModuleManager.getInstance(myProject).getModules(); for (Module module : modules) { flat.add(module.getModuleFilePath()); final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); addRootsToTrack(moduleRootManager.getContentRootUrls(), recursive, flat); if (includeSourceRoots) { addRootsToTrack(moduleRootManager.getSourceRootUrls(), recursive, flat); } final OrderEntry[] orderEntries = moduleRootManager.getOrderEntries(); for (OrderEntry entry : orderEntries) { if (entry instanceof LibraryOrSdkOrderEntry) { final LibraryOrSdkOrderEntry libSdkEntry = (LibraryOrSdkOrderEntry) entry; for (OrderRootType orderRootType : OrderRootType.getAllTypes()) { addRootsToTrack(libSdkEntry.getRootUrls(orderRootType), recursive, flat); } } } } return Pair.create(recursive, flat); }