Add ability to create named constant without code (#5840)
* Add support for forcing kcl input create variable * Command palette padding tweak * Make traverse function work for ExpressionStatements * Add utilities for getting earliest safe index in AST * Fix the insertIndex logic to not be based on the selection anymore * Add workflow to create a named constant * Fix bug with nameEndInDigits matcher * Tweak command config * Add a three-dot menu to feature tree pane to create parameters * Add E2E test for create parameter flow * Remove edit flow oops * Fix tsc error * Fix E2E test * Update named constant position in edit flow test * Add tags into consideration for safe insert index Per @Irev-dev's helpful feedback, with unit tests!
This commit is contained in:
@ -92,6 +92,9 @@ export type ModelingCommandSchema = {
|
||||
axis: string
|
||||
length: KclCommandValue
|
||||
}
|
||||
'event.parameter.create': {
|
||||
value: KclCommandValue
|
||||
}
|
||||
'change tool': {
|
||||
tool: SketchTool
|
||||
}
|
||||
@ -582,6 +585,22 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
||||
},
|
||||
},
|
||||
},
|
||||
'event.parameter.create': {
|
||||
displayName: 'Create parameter',
|
||||
description: 'Add a named constant to use in geometry',
|
||||
icon: 'make-variable',
|
||||
status: 'development',
|
||||
needsReview: false,
|
||||
args: {
|
||||
value: {
|
||||
inputType: 'kcl',
|
||||
required: true,
|
||||
createVariable: 'force',
|
||||
variableName: 'myParameter',
|
||||
defaultValue: '5',
|
||||
},
|
||||
},
|
||||
},
|
||||
'Constrain length': {
|
||||
description: 'Constrain the length of one or more segments.',
|
||||
icon: 'dimension',
|
||||
@ -596,7 +615,7 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
||||
length: {
|
||||
inputType: 'kcl',
|
||||
required: true,
|
||||
createVariableByDefault: true,
|
||||
createVariable: 'byDefault',
|
||||
defaultValue(_, machineContext) {
|
||||
const selectionRanges = machineContext?.selectionRanges
|
||||
if (!selectionRanges) return KCL_DEFAULT_LENGTH
|
||||
@ -636,7 +655,7 @@ export const modelingMachineCommandConfig: StateMachineCommandSetConfig<
|
||||
namedValue: {
|
||||
inputType: 'kcl',
|
||||
required: true,
|
||||
createVariableByDefault: true,
|
||||
createVariable: 'byDefault',
|
||||
variableName(commandBarContext, machineContext) {
|
||||
const { currentValue } = commandBarContext.argumentsToSubmit
|
||||
if (
|
||||
|
Reference in New Issue
Block a user