MCPcopy Create free account
hub / github.com/coder/coder / extractStringSlice

Function extractStringSlice

scripts/metricsdocgen/scanner/scanner.go:312–320  ·  view source on GitHub ↗

extractStringSlice extracts a []string from a composite literal. Example: - []string{"a", "b", myConst}: ["a", "b", ]

(lit *ast.CompositeLit, decls declarations)

Source from the content-addressed store, hash-verified

310// Example:
311// - []string{"a", "b", myConst}: ["a", "b", <resolved value of myConst>]
312func extractStringSlice(lit *ast.CompositeLit, decls declarations) []string {
313 var labels []string
314 for _, elt := range lit.Elts {
315 if label := resolveStringExpr(elt, decls); label != "" {
316 labels = append(labels, label)
317 }
318 }
319 return labels
320}
321
322// collectDecls collects const and var declarations from a file.
323// This is used to resolve constant and variable references in metric definitions.

Callers 2

collectDeclsFunction · 0.85
extractLabelsFunction · 0.85

Calls 1

resolveStringExprFunction · 0.85

Tested by

no test coverage detected