big refactor of var values for astMods

This commit is contained in:
Kurt Hutten Irev-Dev
2024-09-07 09:04:07 +10:00
parent 72e522dd51
commit 94b0510521
11 changed files with 1196 additions and 491 deletions

View File

@ -16,6 +16,7 @@ import {
VariableDeclaration,
VariableDeclarator,
sketchGroupFromKclValue,
ObjectExpression,
} from './wasm'
import { createIdentifier, splitPathAtLastIndex } from './modifyAst'
import { getSketchSegmentFromSourceRange } from './std/sketchConstraints'
@ -934,3 +935,12 @@ export function hasExtrudableGeometry(ast: Program) {
})
return Object.keys(theMap).length > 0
}
export function getObjExpProperty(
node: ObjectExpression,
propName: string
): { exp: Expr; index: number } | null {
const index = node.properties.findIndex(({ key }) => key.name === propName)
if (index === -1) return null
return { exp: node.properties[index].value, index }
}