GlobalSearchScope (@Nullable String key, @NotNull Project project, @NotNull Module ownModule) { if (key == null) return null; Set<Module> modules = new LinkedHashSet<>(); for (IProperty property : PropertiesImplUtil.findPropertiesByKey(project, key)) { Module module = ModuleUtilCore.findModuleForPsiElement(property.getPsiElement()); if (module == null) { return GlobalSearchScope.allScope(project); } if (module != ownModule) { modules.add(module); } } if (modules.isEmpty()) return null; return GlobalSearchScope.union(modules.stream().map(Module::getModuleWithDependentsScope).toArray(GlobalSearchScope[]::new)); }