PsiFileSystemItem (final @NotNull Project project, final @NotNull VirtualFile file) { final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); VirtualFile contentRootForFile = index.getContentRootForFile(file); return contentRootForFile != null ? PsiManager.getInstance(project).findDirectory(contentRootForFile) : null; }