MCPcopy Index your code
hub / github.com/github/github-mcp-server / findFieldValue

Function findFieldValue

pkg/toolvalidation/readonlyhint.go:204–219  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

202// findFieldValue returns the value expression for the named keyed field of a
203// composite literal, or nil if the field is absent.
204func 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,

Callers 2

checkToolLiteralFunction · 0.85
extractToolNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected