@Override
  protected void performRefactoring(UsageInfo @NotNull [] usages) {
    PsiMethod patternMethod = createMethodToAdd();
    final List<PsiReference> docRefs = new ArrayList<>();
    for (UsageInfo usage : usages) {
      if (usage instanceof InheritorUsageInfo inheritorUsage) {
        final PsiClass inheritor = inheritorUsage.getInheritor();
        addMethodToClass(inheritor, patternMethod, true);
      }
      else if (usage instanceof MethodCallUsageInfo methodCallUsage && !methodCallUsage.isInternal()) {
        final PsiElement expression = methodCallUsage.getMethodCallExpression();
        if (expression instanceof PsiMethodCallExpression call) {
          correctMethodCall(call, false);
        }
        else if (expression instanceof PsiMethodReferenceExpression methodReferenceExpression) {
          PsiExpression qualifierExpression = methodReferenceExpression.getQualifierExpression();

          if (myTargetVariable instanceof PsiParameter parameter && 
              shouldBeExpandedToLambda(methodReferenceExpression, myMethod.getParameterList().getParameterIndex(parameter))) {
            PsiLambdaExpression lambdaExpression = LambdaRefactoringUtil.convertMethodReferenceToLambda(methodReferenceExpression, false, true);
            if (lambdaExpression != null) {
              List<PsiExpression> returnExpressions = LambdaUtil.getReturnExpressions(lambdaExpression);
              if (!returnExpressions.isEmpty()) {
                correctMethodCall((PsiMethodCallExpression)returnExpressions.get(0), false);
              }
            }
          }
          else {
            String exprText;
            if (myTargetVariable instanceof PsiParameter ||
                qualifierExpression instanceof PsiReferenceExpression ref && ref.resolve() == myMethod.getContainingClass()) {
              exprText = myTargetVariable.getType().getCanonicalText();
            }
            else if (qualifierExpression instanceof PsiReferenceExpression) {
              exprText = qualifierExpression.getText() + "." + myTargetVariable.getName();
            }
            else {
              exprText = myTargetVariable.getName();
            }
            PsiExpression newQualifier = JavaPsiFacade.getElementFactory(myProject).createExpressionFromText(exprText, null);
            methodReferenceExpression.setQualifierExpression(newQualifier);
            JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(expression);
          }
        }
      }
      else if (usage instanceof JavadocUsageInfo) {
        docRefs.add(usage.getElement().getReference());
      }
    }

    try {
      final PsiModifierList modifierList = patternMethod.getModifierList();
      if (myTargetClass.isInterface() && !myMethod.hasModifierProperty(PsiModifier.ABSTRACT)) {
        if (!PsiUtil.isAvailable(JavaFeature.EXTENSION_METHODS, myTargetClass)) {
          patternMethod.getBody().delete();
          modifierList.setModifierProperty(PsiModifier.DEFAULT, false);
        }
        else {
          modifierList.setModifierProperty(PsiModifier.DEFAULT, true);
        }
        RefactoringUtil.makeMethodAbstract(myTargetClass, patternMethod);
      }
      else if (myMethod.hasModifierProperty(PsiModifier.DEFAULT)) {
        modifierList.setModifierProperty(PsiModifier.DEFAULT, false);
        VisibilityUtil.setVisibility(modifierList, PsiModifier.PUBLIC);
      }

      final PsiMethod method = addMethodToClass(myTargetClass, patternMethod, false);
      myMethod.delete();
      for (PsiReference reference : docRefs) {
        reference.bindToElement(method);
      }
      VisibilityUtil.fixVisibility(UsageViewUtil.toElements(usages), method, myNewVisibility);

      if (myOpenInEditor) {
        EditorHelper.openInEditor(method);
      }
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }
@Override
  protected void performRefactoring(UsageInfo @NotNull [] usages)