void (@NotNull PsiJavaFile file, @NotNull JavaPsiFacade facade, @NotNull PsiResolveHelper helper, @NotNull String packageName, @NotNull Collection<String> onDemandRefs, @NotNull List<? super PsiClass> outClassesToReimport) { if (onDemandRefs.isEmpty()) { return; } PsiPackage aPackage = facade.findPackage(packageName); if (aPackage == null) { return; } GlobalSearchScope resolveScope = file.getResolveScope(); for (PsiClass aClass : aPackage.getClasses(resolveScope)) { String name = aClass.getName(); for (String refName : onDemandRefs) { String conflictClassName = refName + "." + name; PsiClass conflictClass = facade.findClass(conflictClassName, resolveScope); if (conflictClass == null || !helper.isAccessible(conflictClass, file, null)) continue; String conflictClassName2 = packageName + "." + name; PsiClass conflictClass2 = facade.findClass(conflictClassName2, resolveScope); if (conflictClass2 != null && helper.isAccessible(conflictClass2, file, null) && ReferencesSearch.search(conflictClass, new LocalSearchScope(file), false).findFirst() != null) { outClassesToReimport.add(conflictClass); } } } }