Set<UnloadedModuleDescription> (UsageViewDescriptor descriptor) { if (ModuleManager.getInstance(myProject).getUnloadedModuleDescriptions().isEmpty()) { //optimization return Collections.emptySet(); } Set<UnloadedModuleDescription> unloadedModulesInUseScope = new LinkedHashSet<>(); for (PsiElement element : descriptor.getElements()) { SearchScope useScope = element.getUseScope(); if (useScope instanceof GlobalSearchScope) { unloadedModulesInUseScope.addAll(((GlobalSearchScope)useScope).getUnloadedModulesBelongingToScope()); } } return unloadedModulesInUseScope; }