void (final @NotNull Module module, final @NotNull Set<? super Module> processedModules, final @NotNull Set<? super Library> processedLibraries, final @NotNull Set<? super Sdk> processedSdk, @NotNull Condition<? super OrderEntry> condition) { if (!processedModules.add(module)) return; ModuleRootManager.getInstance(module).orderEntries().recursively().satisfying(condition).process(new RootPolicy<>() { @Override public Object2IntMap<VirtualFile> visitLibraryOrderEntry(@NotNull LibraryOrderEntry libraryOrderEntry, final Object2IntMap<VirtualFile> value) { final Library library = libraryOrderEntry.getLibrary(); if (library != null && processedLibraries.add(library)) { addAll(value, libraryOrderEntry.getRootFiles(OrderRootType.CLASSES)); addAll(value, libraryOrderEntry.getRootFiles(OrderRootType.SOURCES)); } return value; } @Override public Object2IntMap<VirtualFile> visitModuleSourceOrderEntry(final @NotNull ModuleSourceOrderEntry moduleSourceOrderEntry, final Object2IntMap<VirtualFile> value) { processedModules.add(moduleSourceOrderEntry.getOwnerModule()); addAll(value, moduleSourceOrderEntry.getRootModel().getSourceRoots()); return value; } @Override public Object2IntMap<VirtualFile> visitModuleOrderEntry(@NotNull ModuleOrderEntry moduleOrderEntry, Object2IntMap<VirtualFile> value) { final Module depModule = moduleOrderEntry.getModule(); if (depModule != null) { addAll(value, ModuleRootManager.getInstance(depModule).getSourceRoots()); } return value; } @Override public Object2IntMap<VirtualFile> visitJdkOrderEntry(final @NotNull JdkOrderEntry jdkOrderEntry, final Object2IntMap<VirtualFile> value) { final Sdk jdk = jdkOrderEntry.getJdk(); if (jdk != null && processedSdk.add(jdk)) { addAll(value, jdkOrderEntry.getRootFiles(OrderRootType.CLASSES)); addAll(value, jdkOrderEntry.getRootFiles(OrderRootType.SOURCES)); } return value; } }, myEntries); }