void (PsiReference reference, String name, AutoImportQuickFix quickFix) { final PsiElement element = reference.getElement(); final Project project = element.getProject(); Module module = ModuleUtilCore.findModuleForPsiElement(element); GlobalSearchScope scope = module == null ? ProjectScope.getAllScope(project) : module.getModuleWithDependenciesAndLibrariesScope(false); PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project); final PsiClass[] classesByName = cache.getClassesByName(name, scope); for (PsiClass psiClass : classesByName) { final String qualifiedName = psiClass.getQualifiedName(); if (qualifiedName == null) { continue; } final QualifiedName packageQName = QualifiedName.fromDottedString(qualifiedName).removeLastComponent(); quickFix.addImport(psiClass, psiClass.getContainingFile(), packageQName); } }