private static PsiExpression convertToJavaLambda(PsiExpression expression) {
    if (expression instanceof PsiMethodReferenceExpression) {
      return expression;
    }
    if (expression instanceof PsiLambdaExpression) {
      return expression;
    }
    if (expression instanceof PsiMethodCallExpression call) {
      final PsiMethod method = call.resolveMethod();
      if (method == null) {
        return null;
      }
      final PsiType type = method.getReturnType();
      if (!(type instanceof PsiClassType classType)) {
        return null;
      }
      final PsiClassType.ClassResolveResult result = classType.resolveGenerics();
      final PsiClass lambdaClass = result.getElement();
      if (lambdaClass == null) {
        return null;
      }
      final PsiMethod functionalInterfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(lambdaClass);
      LOG.assertTrue(functionalInterfaceMethod != null);
      final String methodName = functionalInterfaceMethod.getName();
      return JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(expression.getText() + "::" + methodName, null);
    }
    if (expression instanceof PsiReferenceExpression) {
      final PsiType expressionType = expression.getType();
      final PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(expressionType);
      LOG.assertTrue(method != null);
      return JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(expression.getText() + "::" + method.getName(), null);
    }

    final PsiType psiType = expression.getType();
    if (psiType != null && !LambdaUtil.notInferredType(psiType)) {
      return AnonymousCanBeLambdaInspection.replaceAnonymousWithLambda(expression, psiType);
    }
    return null;
  }
private static PsiExpression convertToJavaLambda(PsiExpression expression)