SearchScope (@NotNull Project project, @NotNull String descriptor, @NotNull Type scopeType) { return switch (scopeType) { case PROJECT -> GlobalSearchScope.projectScope(project); case MODULE -> { final Module module = ModuleManager.getInstance(project).findModuleByName(descriptor); yield (module == null) ? null : GlobalSearchScope.moduleScope(module); } case DIRECTORY -> { final boolean recursive = StringUtil.startsWithChar(descriptor, '*'); if (recursive) { descriptor = descriptor.substring(1); } final String path = FileUtil.toSystemIndependentName(descriptor.substring(1)); final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path); yield (virtualFile == null) ? null : new GlobalSearchScopesCore.DirectoryScope(project, virtualFile, recursive); } case NAMED -> findScopeByName(project, descriptor); }; }