unwrapAnnotationsLiteral attempts to extract the *ast.CompositeLit for &mcp.ToolAnnotations{...} or mcp.ToolAnnotations{...} from an expression, resolving the MCP package's local alias per file.
(expr ast.Expr, aliases map[string]struct{})
| 222 | // &mcp.ToolAnnotations{...} or mcp.ToolAnnotations{...} from an expression, |
| 223 | // resolving the MCP package's local alias per file. |
| 224 | func unwrapAnnotationsLiteral(expr ast.Expr, aliases map[string]struct{}) *ast.CompositeLit { |
| 225 | if u, ok := expr.(*ast.UnaryExpr); ok && u.Op == token.AND { |
| 226 | expr = u.X |
| 227 | } |
| 228 | cl, ok := expr.(*ast.CompositeLit) |
| 229 | if !ok { |
| 230 | return nil |
| 231 | } |
| 232 | if !isQualifiedType(cl.Type, aliases, "ToolAnnotations") { |
| 233 | return nil |
| 234 | } |
| 235 | return cl |
| 236 | } |
| 237 | |
| 238 | // extractToolName returns the literal value of the Name field of an mcp.Tool |
| 239 | // composite literal, or empty string if the value is not a basic string literal. |
no test coverage detected