Graph<ModuleSourceSet> (@NotNull RootModelProvider provider) { return GraphGenerator.generate(CachingSemiGraph.cache(new InboundSemiGraph<>() { @Override public @NotNull Collection<ModuleSourceSet> getNodes() { Module[] modules = provider.getModules(); List<ModuleSourceSet> result = new ArrayList<>(modules.length * 2); for (Module module : modules) { result.add(new ModuleSourceSet(module, ModuleSourceSet.Type.PRODUCTION)); result.add(new ModuleSourceSet(module, ModuleSourceSet.Type.TEST)); } return result; } @Override public @NotNull Iterator<ModuleSourceSet> getIn(final ModuleSourceSet n) { ModuleRootModel model = provider.getRootModel(n.getModule()); OrderEnumerator enumerator = model.orderEntries().compileOnly(); if (n.getType() == ModuleSourceSet.Type.PRODUCTION) { enumerator = enumerator.productionOnly(); } final List<ModuleSourceSet> deps = new ArrayList<>(); enumerator.forEachModule(module -> { deps.add(new ModuleSourceSet(module, n.getType())); return true; }); if (n.getType() == ModuleSourceSet.Type.TEST) { deps.add(new ModuleSourceSet(n.getModule(), ModuleSourceSet.Type.PRODUCTION)); } return deps.iterator(); } })); }