Module (PsiElement element) { ProjectFileIndex index = ProjectRootManager.getInstance(element.getProject()).getFileIndex(); VirtualFile file = PsiUtilCore.getVirtualFile(element); return file == null ? null : index.getModuleForFile(file); }