public Collection<PsiElement> getAdditionalElementsToDelete(
      @NotNull final PsiElement element,
      @NotNull final Collection<PsiElement> allElementsToDelete,
      final boolean askUser) {
    if (element instanceof PsiField) {
      PsiField field = (PsiField) element;
      final Project project = element.getProject();
      String propertyName =
          JavaCodeStyleManager.getInstance(project)
              .variableNameToPropertyName(field.getName(), VariableKind.FIELD);

      PsiClass aClass = field.getContainingClass();
      if (aClass != null) {
        boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
        PsiMethod[] getters =
            GetterSetterPrototypeProvider.findGetters(aClass, propertyName, isStatic);
        if (getters != null) {
          final List<PsiMethod> validGetters = new ArrayList<>(1);
          for (PsiMethod getter : getters) {
            if (!allElementsToDelete.contains(getter) && (getter != null && getter.isPhysical())) {
              validGetters.add(getter);
            }
          }
          getters =
              validGetters.isEmpty()
                  ? null
                  : validGetters.toArray(new PsiMethod[validGetters.size()]);
        }

        PsiMethod setter = PropertyUtil.findPropertySetter(aClass, propertyName, isStatic, false);
        if (allElementsToDelete.contains(setter) || setter != null && !setter.isPhysical())
          setter = null;
        if (askUser && (getters != null || setter != null)) {
          final String message =
              RefactoringMessageUtil.getGetterSetterMessage(
                  field.getName(),
                  RefactoringBundle.message("delete.title"),
                  getters != null ? getters[0] : null,
                  setter);
          if (!ApplicationManager.getApplication().isUnitTestMode()
              && Messages.showYesNoDialog(
                      project,
                      message,
                      RefactoringBundle.message("safe.delete.title"),
                      Messages.getQuestionIcon())
                  != Messages.YES) {
            getters = null;
            setter = null;
          }
        }
        List<PsiElement> elements = new ArrayList<>();
        if (setter != null) elements.add(setter);
        if (getters != null) Collections.addAll(elements, getters);
        return elements;
      }
    }
    return null;
  }
 private static boolean shouldPropagateToNonPhysicalMethod(
     PsiMethod method,
     ArrayList<UsageInfo> result,
     PsiClass containingClass,
     final Collection<PsiMethod> propagateMethods) {
   for (PsiMethod psiMethod : propagateMethods) {
     if (!psiMethod.isPhysical()
         && Comparing.strEqual(psiMethod.getName(), containingClass.getName())) {
       result.add(new DefaultConstructorImplicitUsageInfo(psiMethod, containingClass, method));
       return true;
     }
   }
   return false;
 }
  public boolean processUsage(
      ChangeInfo changeInfo, UsageInfo usage, boolean beforeMethodChange, UsageInfo[] usages) {
    if (!isJavaUsage(usage)) return false;
    if (!(changeInfo instanceof JavaChangeInfo)) return false;

    if (beforeMethodChange) {
      if (usage instanceof CallerUsageInfo) {
        final CallerUsageInfo callerUsageInfo = (CallerUsageInfo) usage;
        processCallerMethod(
            (JavaChangeInfo) changeInfo,
            callerUsageInfo.getMethod(),
            null,
            callerUsageInfo.isToInsertParameter(),
            callerUsageInfo.isToInsertException());
        return true;
      } else if (usage instanceof OverriderUsageInfo) {
        OverriderUsageInfo info = (OverriderUsageInfo) usage;
        final PsiMethod method = info.getElement();
        final PsiMethod baseMethod = info.getBaseMethod();
        if (info.isOriginalOverrider()) {
          processPrimaryMethod((JavaChangeInfo) changeInfo, method, baseMethod, false);
        } else {
          processCallerMethod(
              (JavaChangeInfo) changeInfo,
              method,
              baseMethod,
              info.isToInsertArgs(),
              info.isToCatchExceptions());
        }
        return true;
      }

    } else {
      PsiElement element = usage.getElement();
      LOG.assertTrue(element != null);

      if (usage instanceof DefaultConstructorImplicitUsageInfo) {
        final DefaultConstructorImplicitUsageInfo defConstructorUsage =
            (DefaultConstructorImplicitUsageInfo) usage;
        PsiMethod constructor = defConstructorUsage.getConstructor();
        if (!constructor.isPhysical()) {
          final boolean toPropagate =
              changeInfo instanceof JavaChangeInfoImpl
                  && ((JavaChangeInfoImpl) changeInfo)
                      .propagateParametersMethods.remove(constructor);
          final PsiClass containingClass = defConstructorUsage.getContainingClass();
          constructor = (PsiMethod) containingClass.add(constructor);
          PsiUtil.setModifierProperty(
              constructor,
              VisibilityUtil.getVisibilityModifier(containingClass.getModifierList()),
              true);
          if (toPropagate) {
            ((JavaChangeInfoImpl) changeInfo).propagateParametersMethods.add(constructor);
          }
        }
        addSuperCall(
            (JavaChangeInfo) changeInfo,
            constructor,
            defConstructorUsage.getBaseConstructor(),
            usages);
        return true;
      } else if (usage instanceof NoConstructorClassUsageInfo) {
        addDefaultConstructor(
            ((JavaChangeInfo) changeInfo),
            ((NoConstructorClassUsageInfo) usage).getPsiClass(),
            usages);
        return true;
      } else if (usage instanceof MethodCallUsageInfo) {
        final MethodCallUsageInfo methodCallInfo = (MethodCallUsageInfo) usage;
        processMethodUsage(
            methodCallInfo.getElement(),
            (JavaChangeInfo) changeInfo,
            methodCallInfo.isToChangeArguments(),
            methodCallInfo.isToCatchExceptions(),
            methodCallInfo.getReferencedMethod(),
            methodCallInfo.getSubstitutor(),
            usages);
        return true;
      } else if (usage instanceof ChangeSignatureParameterUsageInfo) {
        String newName = ((ChangeSignatureParameterUsageInfo) usage).newParameterName;
        String oldName = ((ChangeSignatureParameterUsageInfo) usage).oldParameterName;
        processParameterUsage((PsiReferenceExpression) element, oldName, newName);
        return true;
      } else if (usage instanceof CallReferenceUsageInfo) {
        ((CallReferenceUsageInfo) usage).getReference().handleChangeSignature(changeInfo);
        return true;
      } else if (element instanceof PsiEnumConstant) {
        fixActualArgumentsList(
            ((PsiEnumConstant) element).getArgumentList(),
            (JavaChangeInfo) changeInfo,
            true,
            PsiSubstitutor.EMPTY);
        return true;
      } else if (!(usage instanceof OverriderUsageInfo)) {
        PsiReference reference =
            usage instanceof MoveRenameUsageInfo ? usage.getReference() : element.getReference();
        if (reference != null) {
          PsiElement target = changeInfo.getMethod();
          if (target != null) {
            reference.bindToElement(target);
          }
        }
      }
    }
    return false;
  }