Add sectional argument and edit flow for point-and-click Sweep (#5480)

* WIP: Expose the sectional argument in the Sweep command flow
Fixes #5301

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* Working edit flow

* Lint

* Allow in place editing, more consistent code

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* Remove validation on non-selection arg

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* Comment out bad test

* Clean up for review

* Hack sectional

* Made selection args hidden

* Fix edit issue in e2e

* Clean up

* Add face filtering filter for opposite and next adjacent faces

* Lint

* Fixme back

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* Use updateModelingState in codemod

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* Improve filtering readibility

* Fix base test

* I liked return but clippy didn't

* Working tests, isolating the change to sectional sweep, don't like the api change

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* Clean up snapshots

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Pierre Jacquier
2025-03-20 20:42:41 -04:00
committed by GitHub
parent 12b546ea24
commit 054bb5b500
9 changed files with 332 additions and 51 deletions

View File

@ -515,30 +515,54 @@ export function addShell({
}
}
export function addSweep(
node: Node<Program>,
profileDeclarator: VariableDeclarator,
pathDeclarator: VariableDeclarator
): {
export function addSweep({
node,
targetDeclarator,
trajectoryDeclarator,
sectional,
variableName,
insertIndex,
}: {
node: Node<Program>
targetDeclarator: VariableDeclarator
trajectoryDeclarator: VariableDeclarator
sectional: boolean
variableName?: string
insertIndex?: number
}): {
modifiedAst: Node<Program>
pathToNode: PathToNode
} {
const modifiedAst = structuredClone(node)
const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SWEEP)
const sweep = createCallExpressionStdLibKw(
const name =
variableName ?? findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.SWEEP)
const call = createCallExpressionStdLibKw(
'sweep',
createIdentifier(profileDeclarator.id.name),
[createLabeledArg('path', createIdentifier(pathDeclarator.id.name))]
createIdentifier(targetDeclarator.id.name),
[
createLabeledArg('path', createIdentifier(trajectoryDeclarator.id.name)),
createLabeledArg('sectional', createLiteral(sectional)),
]
)
const declaration = createVariableDeclaration(name, sweep)
modifiedAst.body.push(declaration)
const variable = createVariableDeclaration(name, call)
const insertAt =
insertIndex !== undefined
? insertIndex
: modifiedAst.body.length
? modifiedAst.body.length
: 0
modifiedAst.body.length
? modifiedAst.body.splice(insertAt, 0, variable)
: modifiedAst.body.push(variable)
const argIndex = 0
const pathToNode: PathToNode = [
['body', ''],
[modifiedAst.body.length - 1, 'index'],
[insertAt, 'index'],
['declaration', 'VariableDeclaration'],
['init', 'VariableDeclarator'],
['arguments', 'CallExpressionKw'],
[0, ARG_INDEX_FIELD],
[argIndex, ARG_INDEX_FIELD],
['arg', LABELED_ARG_FIELD],
]