@NotNull
    private static List<PsiElement> moveDeclaration(@NotNull Project project, @NotNull PsiParameter variable) {
      final Collection<PsiReferenceExpression> references = VariableAccessUtils.getVariableReferences(variable);
      if (references.isEmpty()) return Collections.emptyList();
      final PsiElement scope = variable.getDeclarationScope();
      if (!(scope instanceof PsiMethod method)) return Collections.emptyList();
      if (!IntentionPreviewUtils.prepareElementForWrite(method)) return Collections.emptyList();
      final PsiParameter[] parameters = method.getParameterList().getParameters();
      final List<ParameterInfoImpl> info = new ArrayList<>();
      for (int i = 0; i < parameters.length; i++) {
        PsiParameter psiParameter = parameters[i];
        if (psiParameter == variable) continue;
        info.add(ParameterInfoImpl.create(i).withName(psiParameter.getName()).withType(psiParameter.getType()));
      }
      final ParameterInfoImpl[] newParams = info.toArray(new ParameterInfoImpl[0]);
      final String visibilityModifier = VisibilityUtil.getVisibilityModifier(method.getModifierList());
      PsiElement moved = IntentionPreviewUtils.writeAndCompute(() -> copyVariableToMethodBody(variable, references));
      if (moved == null) return Collections.emptyList();
      SmartPsiElementPointer<PsiElement> newDeclaration = SmartPointerManager.createPointer(moved);
      if (IntentionPreviewUtils.isPreviewElement(variable)) {
        variable.delete();
      } else {
        var processor = JavaRefactoringFactory.getInstance(project).createChangeSignatureProcessor(
          method, false, visibilityModifier, method.getName(), method.getReturnType(), newParams,
          null, null, null, null
        );
        processor.run();
      }
      return Collections.singletonList(Objects.requireNonNull(newDeclaration.getElement()));
    }
@NotNull
    private static List<PsiElement> moveDeclaration(@NotNull Project project, @NotNull PsiParameter variable)