PsiLambdaExpression (PsiMethodReferenceExpression referenceExpression, boolean doNotAddParameterTypes) { String lambda = createLambdaWithoutFormalParameters(referenceExpression); if (lambda == null) return null; final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(referenceExpression.getProject()); PsiLambdaExpression lambdaExpression = (PsiLambdaExpression)elementFactory.createExpressionFromText(lambda, referenceExpression); final PsiType functionalInterfaceType = referenceExpression.getFunctionalInterfaceType(); boolean needToSpecifyFormalTypes = !doNotAddParameterTypes && !isInferredSameTypeAfterConversion(lambdaExpression, referenceExpression); if (needToSpecifyFormalTypes) { PsiParameterList typedParamList = LambdaUtil.specifyLambdaParameterTypes(functionalInterfaceType, lambdaExpression); if (typedParamList == null) { return null; } } return lambdaExpression; }