* selection stuff
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)
* trigger CI
* fix bugs
* some edge cut stuff
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* fix sketch mode issues
* fix more tests, selection in sketch related
* more test fixing
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Trigger ci
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Trigger ci
* more sketch mode selection fixes
* fix unit tests
* rename function
* remove .only
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* lint
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* fix bad pathToNode issue
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* fix sketch on face
* migrate a more selections types
* migrate a more selections types
* fix code selection of fillets
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* fix bad path to node, looks like a race
* migrate a more selections types
* migrate a more selections types
* fix cmd bar selections
* fix cmd bar selections
* fix display issues
* migrate a more selections types
* Revert "migrate a more selections types"
This reverts commit 0d0e453bbb
.
* migrate a more selections types
* clean up1
* clean up 2
* fix types after main merge
* review tweaks
* fix wall selection bug
* Update src/lang/std/engineConnection.ts
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
* add franks TODO comment
* fix type after main merge, plus a touch of clean up
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
92 lines
2.5 KiB
TypeScript
92 lines
2.5 KiB
TypeScript
import { toolTips } from 'lang/langHelpers'
|
|
import { Selection, Selections } from 'lib/selections'
|
|
import { PathToNode, Program, Expr } from '../../lang/wasm'
|
|
import { getNodeFromPath } from '../../lang/queryAst'
|
|
import {
|
|
PathToNodeMap,
|
|
getRemoveConstraintsTransforms,
|
|
transformAstSketchLines,
|
|
} from '../../lang/std/sketchcombos'
|
|
import { TransformInfo } from 'lang/std/stdTypes'
|
|
import { kclManager } from 'lib/singletons'
|
|
import { err } from 'lib/trap'
|
|
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
|
import { codeRefFromRange } from 'lang/std/artifactGraph'
|
|
|
|
export function removeConstrainingValuesInfo({
|
|
selectionRanges,
|
|
pathToNodes,
|
|
}: {
|
|
selectionRanges: Selections
|
|
pathToNodes?: Array<PathToNode>
|
|
}):
|
|
| {
|
|
transforms: TransformInfo[]
|
|
enabled: boolean
|
|
updatedSelectionRanges: Selections
|
|
}
|
|
| Error {
|
|
const _nodes = selectionRanges.graphSelections.map(({ codeRef }) => {
|
|
const tmp = getNodeFromPath<Expr>(kclManager.ast, codeRef.pathToNode)
|
|
if (err(tmp)) return tmp
|
|
return tmp.node
|
|
})
|
|
const _err1 = _nodes.find(err)
|
|
if (err(_err1)) return _err1
|
|
const nodes = _nodes as Expr[]
|
|
|
|
const updatedSelectionRanges = pathToNodes
|
|
? {
|
|
otherSelections: [],
|
|
graphSelections: nodes.map(
|
|
(node): Selection => ({
|
|
codeRef: codeRefFromRange([node.start, node.end], kclManager.ast),
|
|
})
|
|
),
|
|
}
|
|
: selectionRanges
|
|
const isAllTooltips = nodes.every(
|
|
(node) =>
|
|
node?.type === 'CallExpression' &&
|
|
toolTips.includes(node.callee.name as any)
|
|
)
|
|
|
|
const transforms = getRemoveConstraintsTransforms(
|
|
updatedSelectionRanges,
|
|
kclManager.ast,
|
|
'removeConstrainingValues'
|
|
)
|
|
if (err(transforms)) return transforms
|
|
|
|
const enabled = isAllTooltips && transforms.every(Boolean)
|
|
return { enabled, transforms, updatedSelectionRanges }
|
|
}
|
|
|
|
export function applyRemoveConstrainingValues({
|
|
selectionRanges,
|
|
pathToNodes,
|
|
}: {
|
|
selectionRanges: Selections
|
|
pathToNodes?: Array<PathToNode>
|
|
}):
|
|
| {
|
|
modifiedAst: Node<Program>
|
|
pathToNodeMap: PathToNodeMap
|
|
}
|
|
| Error {
|
|
const constraint = removeConstrainingValuesInfo({
|
|
selectionRanges,
|
|
pathToNodes,
|
|
})
|
|
if (err(constraint)) return constraint
|
|
const { transforms, updatedSelectionRanges } = constraint
|
|
|
|
return transformAstSketchLines({
|
|
ast: kclManager.ast,
|
|
selectionRanges: updatedSelectionRanges,
|
|
transformInfos: transforms,
|
|
programMemory: kclManager.programMemory,
|
|
referenceSegName: '',
|
|
})
|
|
}
|