How to know if a folder is a parent of one of the project source roots

I know how to determine if a particular file is INSIDE the project (using project.getProjectScope().contains(aVirtualFile)).

But is it possible to know if a particular file (which i happen to have a VirtualFile for), is a parent folder (but outside of the project reach) of one of the project's source roots?

I need to know this for vcs things, people may have vcs enabled a parent folder of the current project, and in this case, i can't actually determine this

Comment actions Permalink

I found a way to create a scope for my directory using
PsiFile sandboxPjPsiFile = PsiManager.getInstance(project).findFile(sandboxVFile);
PsiDirectory psiDirectory = sandboxPjPsiFile.getContainingDirectory();
GlobalSearchScope sandboxScope = GlobalSearchScope.directoryScope(psiDirectory, true);

So now I have a scope for both my known VCS enabled directory and for the project scope, and I need to know if their intersection is empty.
I've seen there is an intersect method on the SearchScope interface, but there doesn't seem to be any way to determine if a given scope is empty ?

Comment actions Permalink

As I couldn't find a way through using the scopes, I completely changed directions and ended with

Not sure if this is the most efficient way, but it does the job.

Any comment welcome though


Please sign in to leave a comment.