PsiClass (PsiExpression expression) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression instanceof PsiMethodReferenceExpression methodRef) { if (!methodRef.isConstructor()) return null; PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(methodRef.getFunctionalInterfaceType()); if (method == null || !method.getParameterList().isEmpty()) return null; PsiTypeElement type = methodRef.getQualifierType(); if (type == null) { if (methodRef.getQualifier() instanceof PsiReference) { return ObjectUtils.tryCast(((PsiReference)methodRef.getQualifier()).resolve(), PsiClass.class); } return null; } return PsiUtil.resolveClassInClassTypeOnly(type.getType()); } if (expression instanceof PsiLambdaExpression lambda) { if (!lambda.getParameterList().isEmpty()) return null; PsiExpression body = PsiUtil.skipParenthesizedExprDown(LambdaUtil.extractSingleExpressionFromBody(lambda.getBody())); if (!(body instanceof PsiNewExpression newExpression)) return null; PsiExpressionList args = newExpression.getArgumentList(); if (args == null || !args.isEmpty() || newExpression.getAnonymousClass() != null) return null; PsiReference classRef = newExpression.getClassReference(); return classRef == null ? null : ObjectUtils.tryCast(classRef.resolve(), PsiClass.class); } return null; }