ModuleIndex (@NotNull Project project) { return CachedValuesManager.getManager(project).getCachedValue(project, () -> { ModuleIndex index = new ModuleIndex(); for (Module module : ModuleManager.getInstance(project).getModules()) { for (OrderEntry orderEntry : ModuleRootManager.getInstance(module).getOrderEntries()) { if (orderEntry instanceof ModuleOrderEntry) { Module referenced = ((ModuleOrderEntry)orderEntry).getModule(); if (referenced != null) { index.allUsages.putValue(referenced, module); if (((ModuleOrderEntry)orderEntry).isExported()) { index.exportingUsages.putValue(referenced, module); } if (((ModuleOrderEntry)orderEntry).isProductionOnTestDependency()) { index.productionOnTestUsages.putValue(referenced, module); } } } } } return CachedValueProvider.Result.create(index, ProjectRootManager.getInstance(project)); }); }