IntelliJ IDEA 中的 PsiLambdaExpression

The PsiLambdaExpression in the IntelliJ IDEA

是否有现成的解决方案(实用程序)从 PsiLambdaExpression 获取 lambda 接口(函数、谓词、供应商、消费者等)?

这样的东西好像是你想要的?

import com.intellij.psi.*;
...
PsiType type = PsiFunctionalExpression.getFunctionalInterfaceType;
if (type instanceof PsiClassType) {
  PsiClass lambaInterface = ((PsiClassType)type).resolve();
}
import com.intellij.psi.LambdaUtil;

PsiType functionalInterfaceType = LambdaUtil.getFunctionalInterfaceType(expression, true); // expression: Map<Object, Object> map -> map.get(1)
functionalInterfaceType.getCanonicalText(); // java.util.function.Function<? super java.util.HashMap<java.lang.Object,java.lang.Object>,?>

expression.getFunctionalInterfaceType();