MCPcopy Create free account
hub / github.com/github/gh-aw / extractTerminalSubExpressions

Function extractTerminalSubExpressions

pkg/workflow/expression_extraction.go:362–383  ·  view source on GitHub ↗

extractTerminalSubExpressions returns the simple-identifier sub-expressions from a compound expression (one containing `||` or `&&` operators, and optionally parentheses) that the runtime evaluator resolves via deterministic GH_AW_* environment variable names. It delegates parsing to the existing P

(content string)

Source from the content-addressed store, hash-verified

360// "steps.pick-experiment.outputs.name == 'concise'"
361// → [] (hyphenated segment; not a simpleIdentifier)
362func extractTerminalSubExpressions(content string) []string {
363 tree, err := ParseExpression(content)
364 if err != nil {
365 // Unparseable expression (e.g. malformed input) — return empty safely.
366 expressionExtractionLog.Printf("Could not parse expression %q for sub-expression extraction (skipping): %v", content, err)
367 return nil
368 }
369
370 seen := make(map[string]struct {
371 })
372 var result []string
373 _ = VisitExpressionTree(tree, func(node *ExpressionNode) error {
374 expr := strings.TrimSpace(node.Expression)
375 if isQualifyingSubExpression(expr) && !setutil.Contains(seen, expr) {
376 seen[expr] = struct {
377 }{}
378 result = append(result, expr)
379 }
380 return nil
381 })
382 return result
383}
384
385// generateEnvVarName generates a unique environment variable name for an expression
386// For simple JavaScript property access chains (e.g., "github.event.issue.number"),

Calls 5

ContainsFunction · 0.92
ParseExpressionFunction · 0.85
VisitExpressionTreeFunction · 0.85
PrintfMethod · 0.45

Tested by 3

FuzzExtractExpressionsFunction · 0.68