drag sphere - edit sketch working for xy plane

This commit is contained in:
Kurt Hutten IrevDev
2022-12-07 10:02:21 +11:00
parent 034c903672
commit cecc4b1f01
6 changed files with 374 additions and 137 deletions

View File

@ -1215,6 +1215,38 @@ export function addLine(
}
}
export function changeArguments(
node: Program,
pathToNode: (string | number)[],
args: [number, number]
): { modifiedAst: Program; pathToNode: (string | number)[] }{
const _node = { ...node }
const dumbyStartend = { start: 0, end: 0 }
// const thePath = getNodePathFromSourceRange(_node, sourceRange)
const callExpression = getNodeFromPath(_node, pathToNode) as CallExpression
const newXArg: CallExpression['arguments'][number] = callExpression.arguments[0].type === 'Literal' ? {
type: 'Literal',
...dumbyStartend,
value: args[0],
raw: `${args[0]}`,
} : {
...callExpression.arguments[0]
}
const newYArg: CallExpression['arguments'][number] = callExpression.arguments[1].type === 'Literal' ? {
type: 'Literal',
...dumbyStartend,
value: args[1],
raw: `${args[1]}`,
} : {
...callExpression.arguments[1]
}
callExpression.arguments = [newXArg, newYArg]
return {
modifiedAst: _node,
pathToNode,
}
}
function isCallExpression(tokens: Token[], index: number): number {
const currentToken = tokens[index]
const veryNextToken = tokens[index + 1] // i.e. no whitespace