Compare commits

...

2 Commits

Author SHA1 Message Date
1f27aa7b51 let's see if this fixes anything 2025-04-23 17:57:45 -05:00
f3c0c96549 Loft uses kwargs
Loft already uses keyword args, but some parts of the AST codemod
weren't aware of that.
2025-04-23 11:00:53 -05:00
2 changed files with 11 additions and 9 deletions

View File

@ -451,9 +451,11 @@ export function loftSketches(
const modifiedAst = structuredClone(node) const modifiedAst = structuredClone(node)
const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.LOFT) const name = findUniqueName(node, KCL_DEFAULT_CONSTANT_PREFIXES.LOFT)
const elements = declarators.map((d) => createLocalName(d.id.name)) const elements = declarators.map((d) => createLocalName(d.id.name))
const loft = createCallExpressionStdLib('loft', [ const loft = createCallExpressionStdLibKw(
'loft',
createArrayExpression(elements), createArrayExpression(elements),
]) []
)
const declaration = createVariableDeclaration(name, loft) const declaration = createVariableDeclaration(name, loft)
modifiedAst.body.push(declaration) modifiedAst.body.push(declaration)
const pathToNode: PathToNode = [ const pathToNode: PathToNode = [
@ -461,8 +463,7 @@ export function loftSketches(
[modifiedAst.body.length - 1, 'index'], [modifiedAst.body.length - 1, 'index'],
['declaration', 'VariableDeclaration'], ['declaration', 'VariableDeclaration'],
['init', 'VariableDeclarator'], ['init', 'VariableDeclarator'],
['arguments', 'CallExpression'], ['unlabeled', UNLABELED_ARG],
[0, 'index'],
] ]
return { return {
@ -1379,10 +1380,11 @@ export async function deleteFromSelection(
extrudeNameToDelete = dec.id.name extrudeNameToDelete = dec.id.name
} }
if ( if (
dec.init.type === 'CallExpression' && dec.init.type === 'CallExpressionKw' &&
dec.init.callee.name.name === 'loft' && dec.init.callee.name.name === 'loft' &&
dec.init.arguments?.[0].type === 'ArrayExpression' && dec.init.unlabeled !== null &&
dec.init.arguments?.[0].elements.some( dec.init.unlabeled.type === 'ArrayExpression' &&
dec.init.unlabeled.elements.some(
(a) => a.type === 'Name' && a.name.name === varDecName (a) => a.type === 'Name' && a.name.name === varDecName
) )
) { ) {

View File

@ -873,10 +873,10 @@ export async function deleteEdgeTreatment(
if (inPipe) { if (inPipe) {
// Retrieve the CallExpression path // Retrieve the CallExpression path
const callExp = const callExp =
getNodeFromPath<CallExpression>( getNodeFromPath<CallExpression | CallExpressionKw>(
ast, ast,
selection?.codeRef?.pathToNode, selection?.codeRef?.pathToNode,
'CallExpression' ['CallExpression', 'CallExpressionKw']
) ?? null ) ?? null
if (err(callExp)) return callExp if (err(callExp)) return callExp