Object (@NotNull DataProvider dataProvider) { Object moduleContext = LangDataKeys.MODULE_CONTEXT.getData(dataProvider); if (moduleContext != null) { return moduleContext; } Project project = extractProject(dataProvider); if (project == null) return null; VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataProvider); if (files == null) { files = (VirtualFile[])new VirtualFileArrayRule().getData(dataProvider); } if (files == null) { return null; } Module singleModule = null; for (VirtualFile file : files) { Module module = ModuleUtilCore.findModuleForFile(file, project); if (module == null) { return null; } if (singleModule == null) { singleModule = module; } else if (module != singleModule) { return null; } } return singleModule; }