static @Nullable @NonNls String createMethodReferenceText(final PsiElement element,
                                                 final PsiType functionalInterfaceType,
                                                 final PsiVariable[] parameters) {
    if (element instanceof PsiMethodCallExpression methodCall) {

      JavaResolveResult result = methodCall.resolveMethodGenerics();
      final PsiMethod psiMethod = (PsiMethod)result.getElement();
      if (psiMethod == null) {
        return null;
      }

      if (JavacQuirksInspectionVisitor.getInaccessibleMethodReferenceClass(element, psiMethod) != null) {
        return null;
      }

      final PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
      final String qualifierByMethodCall = getQualifierTextByMethodCall(methodCall, functionalInterfaceType, parameters, psiMethod, result.getSubstitutor());
      if (qualifierByMethodCall != null) {
        return qualifierByMethodCall + "::" + ((PsiMethodCallExpression)element).getTypeArgumentList().getText() + methodExpression.getReferenceName();
      }
    }
    else if (element instanceof PsiNewExpression) {
      final String qualifierByNew = getQualifierTextByNewExpression((PsiNewExpression)element);
      if (qualifierByNew != null) {
        return qualifierByNew + ((PsiNewExpression)element).getTypeArgumentList().getText() + "::new";
      }
    }
    else if (element instanceof PsiInstanceOfExpression instanceOfExpression) {
      if(isSoleParameter(parameters, instanceOfExpression.getOperand())) {
        PsiTypeElement type = instanceOfExpression.getCheckType();
        if(canUseTypeInClassExpression(type)) {
          return type.getText() + ".class::isInstance";
        }
      }
    }
    else if (element instanceof PsiBinaryExpression binOp) {
      PsiExpression operand = ExpressionUtils.getValueComparedWithNull(binOp);
      if(operand != null && isSoleParameter(parameters, operand)) {
        IElementType tokenType = binOp.getOperationTokenType();
        if(JavaTokenType.EQEQ.equals(tokenType)) {
          return "java.util.Objects::isNull";
        } else if(JavaTokenType.NE.equals(tokenType)) {
          return "java.util.Objects::nonNull";
        }
      }
      if(binOp.getOperationTokenType().equals(JavaTokenType.PLUS)) {
        PsiExpression left = binOp.getLOperand();
        PsiExpression right = binOp.getROperand();
        if (parameters.length == 2 && 
            ((ExpressionUtils.isReferenceTo(left, parameters[0]) && ExpressionUtils.isReferenceTo(right, parameters[1])) ||
            (ExpressionUtils.isReferenceTo(left, parameters[1]) && ExpressionUtils.isReferenceTo(right, parameters[0])))) {
          PsiType type = binOp.getType();
          if (type instanceof PsiPrimitiveType && TypeConversionUtil.isNumericType(type)) {
            // Can be only int/long/double/float as short/byte/char would be promoted to int
            return ((PsiPrimitiveType)type).getBoxedTypeName() + "::sum";
          }
        }
      }
    }
    else if (element instanceof PsiTypeCastExpression castExpression) {
      if(isSoleParameter(parameters, castExpression.getOperand())) {
        PsiTypeElement type = castExpression.getCastType();
        if (canUseTypeInClassExpression(type)) {
          return type.getText() + ".class::cast";
        }
      }
    }
    return null;
  }
static @Nullable @NonNls String createMethodReferenceText(final PsiElement element,
                                                 final PsiType functionalInterfaceType,
                                                 final PsiVariable[] parameters)