KCL: Sweep stdlib fn now uses keyword args (#5300)

Before:
```
|> sweep({ path = myPath }, %)
```

After:
```
|> sweep(path = myPath)
```
This commit is contained in:
Adam Chalmers
2025-02-07 12:35:04 -06:00
committed by GitHub
parent f20fc5b467
commit 30b1dae38a
13 changed files with 4730 additions and 1793 deletions

View File

@ -431,10 +431,11 @@ export function addSweep(
} {
const modifiedAst = structuredClone(node)
const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SWEEP)
const sweep = createCallExpressionStdLib('sweep', [
createObjectExpression({ path: createIdentifier(pathDeclarator.id.name) }),
const sweep = createCallExpressionStdLibKw(
'sweep',
createIdentifier(profileDeclarator.id.name),
])
[createLabeledArg('path', createIdentifier(pathDeclarator.id.name))]
)
const declaration = createVariableDeclaration(name, sweep)
modifiedAst.body.push(declaration)
const pathToNode: PathToNode = [
@ -442,8 +443,9 @@ export function addSweep(
[modifiedAst.body.length - 1, 'index'],
['declaration', 'VariableDeclaration'],
['init', 'VariableDeclarator'],
['arguments', 'CallExpression'],
[0, 'index'],
['arguments', 'CallExpressionKw'],
[0, ARG_INDEX_FIELD],
['arg', LABELED_ARG_FIELD],
]
return {