PsiFunctionalExpression (PsiElement reference) { if (reference instanceof PsiFunctionalExpression) { return (PsiFunctionalExpression)reference; } if (reference instanceof PsiIdentifier) { // in "str.trim()" go from "trim" to "str" reference = reference.getParent(); if (reference instanceof PsiReferenceExpression) { reference = PsiUtil.skipParenthesizedExprDown(((PsiReferenceExpression)reference).getQualifierExpression()); } } if (reference instanceof PsiReferenceExpression) { PsiParameter parameter = tryCast(((PsiReferenceExpression)reference).resolve(), PsiParameter.class); if (parameter == null) return null; PsiParameterList parameterList = tryCast(parameter.getParent(), PsiParameterList.class); if (parameterList == null || parameterList.getParametersCount() != 1) return null; return tryCast(parameterList.getParent(), PsiLambdaExpression.class); } return null; }