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)
| 360 | // "steps.pick-experiment.outputs.name == 'concise'" |
| 361 | // → [] (hyphenated segment; not a simpleIdentifier) |
| 362 | func 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"), |