how to create a search-scope for a package?
I would like to search for all inheritors of a given class in a given package.
I would like to use :
ClassInheritorsSearch.search(aClass, packageScope, true).findAll()
but I don't find the way to create a scope (class SearchScope, for the second parameter of the method search above) corresponding to the package containing the given class (from aClass of type PsiClass).
I am not interested in searching in the whole project, just in a given package of the project.
aClass.getUseScope() gives me a too large scope.
Any clue?
请先登录再写评论。
Collect the directories of a package, build a DirectoryScope for each of them and combine them with union().
Ok thanks.
And how do I get the directory from a class or from its file (PsiJavaFile) ?
Ok : getContainingDirectory() from the PsiJavaFile :-)
In Idea 10.5 there is GlobalSearchScope.directoryScope(PsiDirectory,bool), but I couldn't find it in Idea 11. How do I create a SearchScope from a directory in Idea 11 ?
GlobalSearchScopes.directoryScope
Thanks!