findFieldValue returns the value expression for the named keyed field of a composite literal, or nil if the field is absent.
(cl *ast.CompositeLit, name string)
| 202 | // findFieldValue returns the value expression for the named keyed field of a |
| 203 | // composite literal, or nil if the field is absent. |
| 204 | func findFieldValue(cl *ast.CompositeLit, name string) ast.Expr { |
| 205 | for _, elt := range cl.Elts { |
| 206 | kv, ok := elt.(*ast.KeyValueExpr) |
| 207 | if !ok { |
| 208 | continue |
| 209 | } |
| 210 | key, ok := kv.Key.(*ast.Ident) |
| 211 | if !ok { |
| 212 | continue |
| 213 | } |
| 214 | if key.Name == name { |
| 215 | return kv.Value |
| 216 | } |
| 217 | } |
| 218 | return nil |
| 219 | } |
| 220 | |
| 221 | // unwrapAnnotationsLiteral attempts to extract the *ast.CompositeLit for |
| 222 | // &mcp.ToolAnnotations{...} or mcp.ToolAnnotations{...} from an expression, |
no outgoing calls
no test coverage detected