PsiDirectory (@NotNull Query<? extends VirtualFile> vFiles, GlobalSearchScope scope, PsiManager manager) { for (VirtualFile vFile : vFiles) { if (!scope.contains(vFile)) continue; PsiDirectory directory = manager.findDirectory(vFile); if (directory != null && directory.isValid() && directory.isWritable()) { return directory; } } return null; }