Fix another test, addTagKw
addTag helper was not aware of kw args.
This commit is contained in:
committed by
Nick Cameron
parent
141c38c92b
commit
9e778280b3
@ -545,10 +545,10 @@ export function sketchOnExtrudedFace(
|
||||
const { node: oldSketchNode } = _node1
|
||||
|
||||
const oldSketchName = oldSketchNode.id.name
|
||||
const _node2 = getNodeFromPath<CallExpression>(
|
||||
const _node2 = getNodeFromPath<CallExpression | CallExpressionKw>(
|
||||
_node,
|
||||
sketchPathToNode,
|
||||
'CallExpression'
|
||||
['CallExpression', 'CallExpressionKw']
|
||||
)
|
||||
if (err(_node2)) return _node2
|
||||
const { node: expression } = _node2
|
||||
|
||||
@ -479,7 +479,7 @@ export const line: SketchLineHelperKw = {
|
||||
}
|
||||
},
|
||||
getTag: getTagKwArg(),
|
||||
addTag: addTag(),
|
||||
addTag: addTagKw(),
|
||||
getConstraintInfo: (callExp, ...args) =>
|
||||
commonConstraintInfoHelper(
|
||||
callExp,
|
||||
@ -627,7 +627,7 @@ export const lineTo: SketchLineHelperKw = {
|
||||
}
|
||||
},
|
||||
getTag: getTagKwArg(),
|
||||
addTag: addTag(),
|
||||
addTag: addTagKw(),
|
||||
getConstraintInfo: (callExp, ...args) =>
|
||||
commonConstraintInfoHelper(
|
||||
callExp,
|
||||
@ -2463,6 +2463,38 @@ function addTag(tagIndex = 2): addTagFn {
|
||||
}
|
||||
}
|
||||
|
||||
function addTagKw(): addTagFn {
|
||||
return ({ node, pathToNode }) => {
|
||||
const _node = { ...node }
|
||||
const callExpr = getNodeFromPath<Node<CallExpressionKw>>(
|
||||
_node,
|
||||
pathToNode,
|
||||
'CallExpressionKw'
|
||||
)
|
||||
if (err(callExpr)) return callExpr
|
||||
|
||||
const { node: primaryCallExp } = callExpr
|
||||
|
||||
const tagArg = findKwArg(ARG_TAG, primaryCallExp)
|
||||
const tagDeclarator =
|
||||
tagArg || createTagDeclarator(findUniqueName(_node, 'seg', 2))
|
||||
const isTagExisting = !!tagArg
|
||||
if (!isTagExisting) {
|
||||
const labeledArg = createLabeledArg(ARG_TAG, tagDeclarator)
|
||||
primaryCallExp.arguments.push(labeledArg)
|
||||
}
|
||||
if ('value' in tagDeclarator) {
|
||||
// Now TypeScript knows tagDeclarator has a value property
|
||||
return {
|
||||
modifiedAst: _node,
|
||||
tag: String(tagDeclarator.value),
|
||||
}
|
||||
} else {
|
||||
return new Error('Unable to assign tag without value')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getYComponent(
|
||||
angleDegree: number,
|
||||
xComponent: number
|
||||
|
||||
@ -1580,7 +1580,6 @@ export function getConstraintType(
|
||||
fnName: ToolTip,
|
||||
isAbsolute: boolean
|
||||
): LineInputsType | null {
|
||||
console.error('ADAM: getConstraintType', fnName, isAbsolute, val)
|
||||
// this function assumes that for two val sketch functions that one arg is locked down not both
|
||||
// and for one val sketch functions that the arg is NOT locked down
|
||||
// these conditions should have been checked previously.
|
||||
|
||||
Reference in New Issue
Block a user