ExprCall tests if the given expression is a function call and, if so, extracts the function name and the expressions that represent the arguments. If the given expression is not statically a function call, error diagnostics are returned. A particular Expression implementation can support this funct
(expr Expression)
| 15 | // UnwrapExpression to delegate handling of this function to a wrapped |
| 16 | // Expression object. |
| 17 | func ExprCall(expr Expression) (*StaticCall, Diagnostics) { |
| 18 | type exprCall interface { |
| 19 | ExprCall() *StaticCall |
| 20 | } |
| 21 | |
| 22 | physExpr := UnwrapExpressionUntil(expr, func(expr Expression) bool { |
| 23 | _, supported := expr.(exprCall) |
| 24 | return supported |
| 25 | }) |
| 26 | |
| 27 | if exC, supported := physExpr.(exprCall); supported { |
| 28 | if call := exC.ExprCall(); call != nil { |
| 29 | return call, nil |
| 30 | } |
| 31 | } |
| 32 | return nil, Diagnostics{ |
| 33 | &Diagnostic{ |
| 34 | Severity: DiagError, |
| 35 | Summary: "Invalid expression", |
| 36 | Detail: "A static function call is required.", |
| 37 | Subject: expr.StartRange().Ptr(), |
| 38 | }, |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | // StaticCall represents a function call that was extracted statically from |
| 43 | // an expression using ExprCall. |
nothing calls this directly
no test coverage detected