List<Module> (@NotNull VirtualFile file) { ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); Module module = fileIndex.getModuleForFile(file, false); if (module != null) { return Collections.singletonList(module); } List<OrderEntry> entriesForFile = fileIndex.getOrderEntriesForFile(file); return ContainerUtil.map(entriesForFile, OrderEntry::getOwnerModule); }