public boolean processPrimaryMethod(ChangeInfo changeInfo) {
   if (!StdLanguages.JAVA.equals(changeInfo.getLanguage())
       || !(changeInfo instanceof JavaChangeInfo)) return false;
   final PsiElement element = changeInfo.getMethod();
   LOG.assertTrue(element instanceof PsiMethod);
   if (changeInfo.isGenerateDelegate()) {
     generateDelegate((JavaChangeInfo) changeInfo);
   }
   processPrimaryMethod((JavaChangeInfo) changeInfo, (PsiMethod) element, null, true);
   return true;
 }
  @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;
 }
  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;
  }