@NotNull
  private Map<PsiReferenceExpression, PsiClass> findReplacements(@NotNull PsiField @NotNull [] allFields,
                                                                 @NotNull PsiClass implementingClass,
                                                                 @NotNull ModPsiUpdater updater) {
    Map<PsiReferenceExpression, PsiClass> replacements = new LinkedHashMap<>();
    for (final PsiField field : allFields) {
      SearchScope scope = implementingClass.getUseScope();
      final Query<PsiReference> search = ReferencesSearch.search(field, scope, false);
      for (PsiReference reference : search) {
        if (!(reference instanceof PsiReferenceExpression referenceExpression)) {
          continue;
        }
        if (!myReplaceInWholeProject) {
          boolean isInheritor = false;
          PsiClass aClass = PsiTreeUtil.getParentOfType(referenceExpression, PsiClass.class);
          while (aClass != null) {
            isInheritor = InheritanceUtil.isInheritorOrSelf(aClass, implementingClass, true);
            if (isInheritor) break;
            aClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class);
          }
          if (!isInheritor) continue;
        }

        final PsiClass containingClass = Objects.requireNonNull(field.getContainingClass());
        replacements.put(updater.getWritable(referenceExpression), containingClass);
      }
    }
    return replacements;
  }
@NotNull
  private Map<PsiReferenceExpression, PsiClass> findReplacements(@NotNull PsiField @NotNull [] allFields,
                                                                 @NotNull PsiClass implementingClass,
                                                                 @NotNull ModPsiUpdater updater)