@Override
  public boolean processUsage(
      ChangeInfo changeInfo, UsageInfo usageInfo, boolean beforeMethodChange, UsageInfo[] usages) {
    if (!(changeInfo instanceof JavaChangeInfo)) return false;

    PsiElement element = usageInfo.getElement();
    if (element == null) return false;
    if (!GroovyLanguage.INSTANCE.equals(element.getLanguage())) return false;

    if (beforeMethodChange) {
      if (usageInfo instanceof OverriderUsageInfo) {
        processPrimaryMethodInner(
            ((JavaChangeInfo) changeInfo),
            (GrMethod) ((OverriderUsageInfo) usageInfo).getElement(),
            ((OverriderUsageInfo) usageInfo).getBaseMethod());
      }
    } else {
      if (usageInfo instanceof GrMethodCallUsageInfo) {
        processMethodUsage(
            element,
            ((JavaChangeInfo) changeInfo),
            ((GrMethodCallUsageInfo) usageInfo).isToChangeArguments(),
            ((GrMethodCallUsageInfo) usageInfo).isToCatchExceptions(),
            ((GrMethodCallUsageInfo) usageInfo).getMapToArguments(),
            ((GrMethodCallUsageInfo) usageInfo).getSubstitutor());
        return true;
      } else if (usageInfo instanceof DefaultConstructorImplicitUsageInfo) {
        processConstructor(
            (GrMethod) ((DefaultConstructorImplicitUsageInfo) usageInfo).getConstructor(),
            (JavaChangeInfo) changeInfo);
        return true;
      } else if (usageInfo instanceof NoConstructorClassUsageInfo) {
        processClassUsage(
            (GrTypeDefinition) ((NoConstructorClassUsageInfo) usageInfo).getPsiClass(),
            ((JavaChangeInfo) changeInfo));
        return true;
      } else if (usageInfo instanceof ChangeSignatureParameterUsageInfo) {
        String newName = ((ChangeSignatureParameterUsageInfo) usageInfo).newParameterName;
        ((PsiReference) element).handleElementRename(newName);
        return true;
      } else {
        PsiReference ref = element.getReference();
        if (ref != null && changeInfo.getMethod() != null) {
          ref.bindToElement(changeInfo.getMethod());
          return true;
        }
      }
    }
    return false;
  }
  public boolean shouldPreviewUsages(ChangeInfo changeInfo, UsageInfo[] usages) {
    if (!StringUtil.isJavaIdentifier(changeInfo.getNewName())) return true;

    for (UsageInfo usage : usages) {
      if (usage instanceof GrMethodCallUsageInfo) {
        if (((GrMethodCallUsageInfo) usage).isPossibleUsage()) return true;
      }
    }
    return false;
  }
 @Override
 public boolean setupDefaultValues(
     ChangeInfo changeInfo, Ref<UsageInfo[]> refUsages, Project project) {
   if (!(changeInfo instanceof JavaChangeInfo)) return true;
   for (UsageInfo usageInfo : refUsages.get()) {
     if (usageInfo instanceof GrMethodCallUsageInfo) {
       GrMethodCallUsageInfo methodCallUsageInfo = (GrMethodCallUsageInfo) usageInfo;
       if (methodCallUsageInfo.isToChangeArguments()) {
         final PsiElement element = methodCallUsageInfo.getElement();
         if (element == null) continue;
         final PsiMethod caller = RefactoringUtil.getEnclosingMethod(element);
         final boolean needDefaultValue =
             !((JavaChangeInfo) changeInfo).getMethodsToPropagateParameters().contains(caller);
         final PsiMethod referencedMethod = methodCallUsageInfo.getReferencedMethod();
         if (needDefaultValue
             && (caller == null
                 || referencedMethod == null
                 || !MethodSignatureUtil.isSuperMethod(referencedMethod, caller))) {
           final ParameterInfo[] parameters = changeInfo.getNewParameters();
           for (ParameterInfo parameter : parameters) {
             final String defaultValue = parameter.getDefaultValue();
             if (defaultValue == null && parameter.getOldIndex() == -1) {
               ((ParameterInfoImpl) parameter).setDefaultValue("");
               if (!ApplicationManager.getApplication().isUnitTestMode()) {
                 final PsiType type =
                     ((ParameterInfoImpl) parameter)
                         .getTypeWrapper()
                         .getType(element, element.getManager());
                 final DefaultValueChooser chooser =
                     new DefaultValueChooser(
                         project, parameter.getName(), PsiTypesUtil.getDefaultValueOfType(type));
                 chooser.show();
                 if (chooser.isOK()) {
                   if (chooser.feelLucky()) {
                     parameter.setUseAnySingleVariable(true);
                   } else {
                     ((ParameterInfoImpl) parameter).setDefaultValue(chooser.getDefaultValue());
                   }
                 } else {
                   return false;
                 }
               }
             }
           }
         }
       }
     }
   }
   return true;
 }