Add support for imports
This commit is contained in:
		@ -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,
 | 
			
		||||
 | 
			
		||||
@ -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())
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user