(commandArgument: CommandArgument)
| 37 | } |
| 38 | |
| 39 | async runCommand(commandArgument: CommandArgument) { |
| 40 | try { |
| 41 | if (this.graph.debug.active) { |
| 42 | this.graph.debug.log(`commandArgument:`); |
| 43 | this.graph.debug.log(JSON.stringify(commandArgument, null, 3)); |
| 44 | } |
| 45 | |
| 46 | const { |
| 47 | spokenForm, |
| 48 | action: actionName, |
| 49 | targets: partialTargets, |
| 50 | extraArgs, |
| 51 | usePrePhraseSnapshot, |
| 52 | } = canonicalizeAndValidateCommand(commandArgument); |
| 53 | |
| 54 | const readableHatMap = await this.graph.hatTokenMap.getReadableMap( |
| 55 | usePrePhraseSnapshot |
| 56 | ); |
| 57 | |
| 58 | const action = this.graph.actions[actionName]; |
| 59 | |
| 60 | if (action == null) { |
| 61 | throw new Error(`Unknown action ${actionName}`); |
| 62 | } |
| 63 | |
| 64 | const targets = inferFullTargets( |
| 65 | partialTargets, |
| 66 | action.getTargetPreferences(...extraArgs) |
| 67 | ); |
| 68 | |
| 69 | if (this.graph.debug.active) { |
| 70 | this.graph.debug.log("Full targets:"); |
| 71 | this.graph.debug.log(JSON.stringify(targets, null, 3)); |
| 72 | } |
| 73 | |
| 74 | const processedTargetsContext: ProcessedTargetsContext = { |
| 75 | currentSelections: |
| 76 | vscode.window.activeTextEditor?.selections.map((selection) => ({ |
| 77 | selection, |
| 78 | editor: vscode.window.activeTextEditor!, |
| 79 | })) ?? [], |
| 80 | currentEditor: vscode.window.activeTextEditor, |
| 81 | hatTokenMap: readableHatMap, |
| 82 | thatMark: this.thatMark.exists() ? this.thatMark.get() : [], |
| 83 | sourceMark: this.sourceMark.exists() ? this.sourceMark.get() : [], |
| 84 | getNodeAtLocation: this.graph.getNodeAtLocation, |
| 85 | }; |
| 86 | |
| 87 | const selections = processTargets(processedTargetsContext, targets); |
| 88 | |
| 89 | if (this.testCaseRecorder.active) { |
| 90 | const context = { |
| 91 | targets, |
| 92 | thatMark: this.thatMark, |
| 93 | sourceMark: this.sourceMark, |
| 94 | hatTokenMap: readableHatMap, |
| 95 | spokenForm, |
| 96 | }; |
no test coverage detected