Module (@Nullable Project project, VirtualFile @NotNull [] files) { if (project == null) return null; Module result = null; ProjectFileIndex index = ProjectFileIndex.getInstance(project); for (VirtualFile file : files) { Module module = index.getModuleForFile(file, false); if (module == null) return null; if (result == null) { result = module; } else if (!result.equals(module)) { return null; } } return result; }