Rename TooTip to ToolTip (#541)

This commit is contained in:
Adam Sunderland
2023-09-15 11:48:23 -04:00
committed by GitHub
parent e4f2e66029
commit f7971bddef
8 changed files with 33 additions and 30 deletions

View File

@ -1,4 +1,4 @@
import { Selection, TooTip } from '../useStore' import { Selection, ToolTip } from '../useStore'
import { import {
Program, Program,
CallExpression, CallExpression,
@ -635,7 +635,7 @@ export function giveSketchFnCallTag(
createLiteral(tag || findUniqueName(ast, 'seg', 2))) as Literal createLiteral(tag || findUniqueName(ast, 'seg', 2))) as Literal
const tagStr = String(tagValue.value) const tagStr = String(tagValue.value)
const newFirstArg = createFirstArg( const newFirstArg = createFirstArg(
primaryCallExp.callee.name as TooTip, primaryCallExp.callee.name as ToolTip,
firstArg.val, firstArg.val,
tagValue tagValue
) )

View File

@ -1,5 +1,5 @@
import { PathToNode, ProgramMemory, SketchGroup, SourceRange } from './executor' import { PathToNode, ProgramMemory, SketchGroup, SourceRange } from './executor'
import { Selection, TooTip } from '../useStore' import { Selection, ToolTip } from '../useStore'
import { import {
BinaryExpression, BinaryExpression,
Program, Program,
@ -457,7 +457,7 @@ export function isLinesParallelAndConstrained(
const secondaryFirstArg = getFirstArg(secondaryNode) const secondaryFirstArg = getFirstArg(secondaryNode)
const constraintType = getConstraintType( const constraintType = getConstraintType(
secondaryFirstArg.val, secondaryFirstArg.val,
secondaryNode.callee.name as TooTip secondaryNode.callee.name as ToolTip
) )
const constraintLevel = getConstraintLevelFromSourceRange( const constraintLevel = getConstraintLevelFromSourceRange(
secondaryLine.range, secondaryLine.range,

View File

@ -21,7 +21,7 @@ import {
getNodePathFromSourceRange, getNodePathFromSourceRange,
} from '../queryAst' } from '../queryAst'
import { isLiteralArrayOrStatic } from './sketchcombos' import { isLiteralArrayOrStatic } from './sketchcombos'
import { GuiModes, toolTips, TooTip } from '../../useStore' import { GuiModes, toolTips, ToolTip } from '../../useStore'
import { createPipeExpression, splitPathAtPipeExpression } from '../modifyAst' import { createPipeExpression, splitPathAtPipeExpression } from '../modifyAst'
import { generateUuidFromHashSeed } from '../../lib/uuid' import { generateUuidFromHashSeed } from '../../lib/uuid'
@ -57,7 +57,7 @@ export function getCoordsFromPaths(skGroup: SketchGroup, index = 0): Coords2d {
} }
export function createFirstArg( export function createFirstArg(
sketchFn: TooTip, sketchFn: ToolTip,
val: Value | [Value, Value] | [Value, Value, Value], val: Value | [Value, Value] | [Value, Value, Value],
tag?: Value tag?: Value
): Value { ): Value {
@ -943,7 +943,7 @@ interface CreateLineFnCallArgs {
programMemory: ProgramMemory programMemory: ProgramMemory
to: [number, number] to: [number, number]
from: [number, number] from: [number, number]
fnName: TooTip fnName: ToolTip
pathToNode: PathToNode pathToNode: PathToNode
} }
@ -1029,7 +1029,7 @@ export function replaceSketchLine({
node: Program node: Program
programMemory: ProgramMemory programMemory: ProgramMemory
sourceRange: SourceRange sourceRange: SourceRange
fnName: TooTip fnName: ToolTip
to: [number, number] to: [number, number]
from: [number, number] from: [number, number]
createCallback: TransformCallback createCallback: TransformCallback
@ -1208,7 +1208,7 @@ function getFirstArgValuesForAngleFns(callExpression: CallExpression): {
const tag = firstArg.properties.find((p) => p.key.name === 'tag')?.value const tag = firstArg.properties.find((p) => p.key.name === 'tag')?.value
const angle = firstArg.properties.find((p) => p.key.name === 'angle')?.value const angle = firstArg.properties.find((p) => p.key.name === 'angle')?.value
const secondArgName = ['angledLineToX', 'angledLineToY'].includes( const secondArgName = ['angledLineToX', 'angledLineToY'].includes(
callExpression?.callee?.name as TooTip callExpression?.callee?.name as ToolTip
) )
? 'to' ? 'to'
: 'length' : 'length'

View File

@ -1,4 +1,4 @@
import { TooTip, toolTips } from '../../useStore' import { ToolTip, toolTips } from '../../useStore'
import { import {
Program, Program,
VariableDeclarator, VariableDeclarator,
@ -67,7 +67,10 @@ export function isSketchVariablesLinked(
return false return false
const firstCallExp = // first in pipe expression or just the call expression const firstCallExp = // first in pipe expression or just the call expression
init?.type === 'CallExpression' ? init : (init?.body[0] as CallExpression) init?.type === 'CallExpression' ? init : (init?.body[0] as CallExpression)
if (!firstCallExp || !toolTips.includes(firstCallExp?.callee?.name as TooTip)) if (
!firstCallExp ||
!toolTips.includes(firstCallExp?.callee?.name as ToolTip)
)
return false return false
// convention for sketch fns is that the second argument is the sketch group // convention for sketch fns is that the second argument is the sketch group
const secondArg = firstCallExp?.arguments[1] const secondArg = firstCallExp?.arguments[1]

View File

@ -9,7 +9,7 @@ import {
getConstraintLevelFromSourceRange, getConstraintLevelFromSourceRange,
} from './sketchcombos' } from './sketchcombos'
import { initPromise } from '../rust' import { initPromise } from '../rust'
import { Selections, TooTip } from '../../useStore' import { Selections, ToolTip } from '../../useStore'
import { enginelessExecutor } from '../../lib/testHelpers' import { enginelessExecutor } from '../../lib/testHelpers'
import { recast } from '../../lang/recast' import { recast } from '../../lang/recast'
@ -68,7 +68,7 @@ function getConstraintTypeFromSourceHelper(
Value, Value,
Value Value
] ]
const fnName = (ast.body[0] as any).expression.callee.name as TooTip const fnName = (ast.body[0] as any).expression.callee.name as ToolTip
return getConstraintType(args, fnName) return getConstraintType(args, fnName)
} }
function getConstraintTypeFromSourceHelper2( function getConstraintTypeFromSourceHelper2(
@ -76,7 +76,7 @@ function getConstraintTypeFromSourceHelper2(
): ReturnType<typeof getConstraintType> { ): ReturnType<typeof getConstraintType> {
const ast = parser_wasm(code) const ast = parser_wasm(code)
const arg = (ast.body[0] as any).expression.arguments[0] as Value const arg = (ast.body[0] as any).expression.arguments[0] as Value
const fnName = (ast.body[0] as any).expression.callee.name as TooTip const fnName = (ast.body[0] as any).expression.callee.name as ToolTip
return getConstraintType(arg, fnName) return getConstraintType(arg, fnName)
} }

View File

@ -1,5 +1,5 @@
import { TransformCallback } from './stdTypes' import { TransformCallback } from './stdTypes'
import { Selections, toolTips, TooTip, Selection } from '../../useStore' import { Selections, toolTips, ToolTip, Selection } from '../../useStore'
import { import {
CallExpression, CallExpression,
Program, Program,
@ -54,7 +54,7 @@ export type ConstraintType =
| 'setAngleBetween' | 'setAngleBetween'
function createCallWrapper( function createCallWrapper(
a: TooTip, a: ToolTip,
val: [Value, Value] | Value, val: [Value, Value] | Value,
tag?: Value, tag?: Value,
valueUsedInTransform?: number valueUsedInTransform?: number
@ -101,7 +101,7 @@ function intersectCallWrapper({
} }
export type TransformInfo = { export type TransformInfo = {
tooltip: TooTip tooltip: ToolTip
createNode: (a: { createNode: (a: {
varValA: Value // x / angle varValA: Value // x / angle
varValB: Value // y / length or x y for angledLineOfXlength etc varValB: Value // y / length or x y for angledLineOfXlength etc
@ -112,7 +112,7 @@ export type TransformInfo = {
} }
type TransformMap = { type TransformMap = {
[key in TooTip]?: { [key in ToolTip]?: {
[key in LineInputsType | 'free']?: { [key in LineInputsType | 'free']?: {
[key in ConstraintType]?: TransformInfo [key in ConstraintType]?: TransformInfo
} }
@ -1095,12 +1095,12 @@ export function getRemoveConstraintsTransform(
sketchFnExp: CallExpression, sketchFnExp: CallExpression,
constraintType: ConstraintType constraintType: ConstraintType
): TransformInfo | false { ): TransformInfo | false {
let name = sketchFnExp.callee.name as TooTip let name = sketchFnExp.callee.name as ToolTip
if (!toolTips.includes(name)) { if (!toolTips.includes(name)) {
return false return false
} }
const xyLineMap: { const xyLineMap: {
[key in TooTip]?: TooTip [key in ToolTip]?: ToolTip
} = { } = {
xLine: 'line', xLine: 'line',
yLine: 'line', yLine: 'line',
@ -1167,12 +1167,12 @@ function getTransformMapPath(
constraintType: ConstraintType constraintType: ConstraintType
): ):
| { | {
toolTip: TooTip toolTip: ToolTip
lineInputType: LineInputsType | 'free' lineInputType: LineInputsType | 'free'
constraintType: ConstraintType constraintType: ConstraintType
} }
| false { | false {
const name = sketchFnExp.callee.name as TooTip const name = sketchFnExp.callee.name as ToolTip
if (!toolTips.includes(name)) { if (!toolTips.includes(name)) {
return false return false
} }
@ -1225,7 +1225,7 @@ export function getTransformInfo(
export function getConstraintType( export function getConstraintType(
val: Value | [Value, Value] | [Value, Value, Value], val: Value | [Value, Value] | [Value, Value, Value],
fnName: TooTip fnName: ToolTip
): LineInputsType | null { ): LineInputsType | null {
// this function assumes that for two val sketch functions that one arg is locked down not both // 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 // and for one val sketch functions that the arg is NOT locked down
@ -1445,7 +1445,7 @@ export function transformAstSketchLines({
programMemory, programMemory,
sourceRange: range, sourceRange: range,
referencedSegment, referencedSegment,
fnName: transformTo || (callExp.callee.name as TooTip), fnName: transformTo || (callExp.callee.name as ToolTip),
to, to,
from, from,
createCallback: callBack({ createCallback: callBack({
@ -1511,7 +1511,7 @@ export function getConstraintLevelFromSourceRange(
getNodePathFromSourceRange(ast, cursorRange), getNodePathFromSourceRange(ast, cursorRange),
'CallExpression' 'CallExpression'
) )
const name = sketchFnExp?.callee?.name as TooTip const name = sketchFnExp?.callee?.name as ToolTip
if (!toolTips.includes(name)) return 'free' if (!toolTips.includes(name)) return 'free'
const firstArg = getFirstArg(sketchFnExp) const firstArg = getFirstArg(sketchFnExp)

View File

@ -1,6 +1,6 @@
import { ProgramMemory, Path, SourceRange } from '../executor' import { ProgramMemory, Path, SourceRange } from '../executor'
import { Program, Value } from '../abstractSyntaxTreeTypes' import { Program, Value } from '../abstractSyntaxTreeTypes'
import { TooTip } from '../../useStore' import { ToolTip } from '../../useStore'
import { PathToNode } from '../executor' import { PathToNode } from '../executor'
import { EngineCommandManager } from './engineConnection' import { EngineCommandManager } from './engineConnection'
@ -45,7 +45,7 @@ export type TransformCallback = (
} }
export type SketchCallTransfromMap = { export type SketchCallTransfromMap = {
[key in TooTip]: TransformCallback [key in ToolTip]: TransformCallback
} }
export interface SketchLineHelper { export interface SketchLineHelper {

View File

@ -27,7 +27,7 @@ export type Selections = {
otherSelections: ('y-axis' | 'x-axis' | 'z-axis')[] otherSelections: ('y-axis' | 'x-axis' | 'z-axis')[]
codeBasedSelections: Selection[] codeBasedSelections: Selection[]
} }
export type TooTip = export type ToolTip =
| 'lineTo' | 'lineTo'
| 'line' | 'line'
| 'angledLine' | 'angledLine'
@ -57,7 +57,7 @@ export const toolTips = [
'xLineTo', 'xLineTo',
'yLineTo', 'yLineTo',
'angledLineThatIntersects', 'angledLineThatIntersects',
] as any as TooTip[] ] as any as ToolTip[]
export type GuiModes = export type GuiModes =
| { | {
@ -65,7 +65,7 @@ export type GuiModes =
} }
| { | {
mode: 'sketch' mode: 'sketch'
sketchMode: TooTip sketchMode: ToolTip
isTooltip: true isTooltip: true
waitingFirstClick: boolean waitingFirstClick: boolean
rotation: Rotation rotation: Rotation