PsiDirectory () { final Project project = getElement().getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile file = getElement().getContainingFile().getOriginalFile().getVirtualFile(); if (file != null) { final VirtualFile contentRoot = fileIndex.getContentRootForFile(file); if (contentRoot != null) { final PsiManager psiManager = PsiManager.getInstance(project); return psiManager.findDirectory(contentRoot); } } return null; }