Module (@NotNull Project project) { VirtualFile baseDir = project.getBaseDir(); if (baseDir == null) { return null; } ModuleManager moduleManager = ModuleManager.getInstance(project); return ContainerUtil.find(moduleManager.getModules(), module -> Arrays.asList(ModuleRootManager.getInstance(module).getContentRoots()).contains(baseDir)); }