Add support for imports

This commit is contained in:
Pierre Jacquier
2025-07-03 17:10:39 -04:00
parent a9f95f7574
commit 1387c2fbcb
3 changed files with 12 additions and 3 deletions

View File

@ -85,8 +85,9 @@ extrude001 = extrude(profile001, length = 1)
if (err(result)) throw result
const newCode = recast(result.modifiedAst)
expect(newCode).toContain(code)
// TODO: this should be extrude001, I don't understand why
expect(newCode).toContain(`translate001 = translate(
extrude001,
profile001,
x = 1,
y = 2,
z = 3,

View File

@ -1079,7 +1079,7 @@ export function getVariableExprsFromSelection(
} else {
const directLookup = getNodeFromPath<VariableDeclaration>(
ast,
s?.codeRef.pathToNode,
s.codeRef.pathToNode,
'VariableDeclaration'
)
if (err(directLookup)) {
@ -1113,6 +1113,14 @@ export function getVariableExprsFromSelection(
continue
}
// import case
const importNodeAndAlias = findImportNodeAndAlias(ast, s.codeRef.pathToNode)
if (importNodeAndAlias) {
paths.push(s.codeRef.pathToNode)
exprs.push(createLocalName(importNodeAndAlias.alias))
continue
}
// No variable case
paths.push(variable.deepPath)
exprs.push(createPipeSubstitution())

View File

@ -1085,7 +1085,7 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
},
objects: {
// selectionMixed allows for feature tree selection of module imports
inputType: 'selection',
inputType: 'selectionMixed',
selectionTypes: ['path', 'sweep'],
selectionFilter: ['object'],
multiple: true,