boolean (final PsiDirectory directory) { if (directory.getManager() == null) return false; final Project project = directory.getProject(); final VirtualFile virtualFile = directory.getVirtualFile(); final VirtualFile sourceRootForFile = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(virtualFile); return Comparing.equal(virtualFile, sourceRootForFile); }