MCPcopy Create free account
hub / github.com/chhoumann/quickadd / execute

Method execute

src/choiceExecutor.ts:107–160  ·  view source on GitHub ↗
(choice: IChoice)

Source from the content-addressed store, hash-verified

105 }
106
107 async execute(choice: IChoice): Promise<void> {
108 this.pendingAbort = null;
109 // Keep a nested execute() (e.g. a {{MACRO}} in a Template/Capture body that runs
110 // another choice through this same executor) transparent to the outcome slot of an
111 // enclosing executeWithOutcome(): snapshot and restore pendingResult so the nested
112 // choice's recorded result never leaks into the outer choice's reported outcome.
113 const savedResult = this.pendingResult;
114 this.beginExecutionContext();
115 const originLeaf = getOpenFileOriginLeaf(this.app);
116 const promptDraftStore = InputPromptDraftStore.getInstance();
117 promptDraftStore.beginExecutionScope();
118 try {
119 await this.runOnePagePreflightIfEnabled(choice);
120
121 switch (choice.type) {
122 case "Template": {
123 const templateChoice: ITemplateChoice =
124 choice as ITemplateChoice;
125 await this.onChooseTemplateType(templateChoice, originLeaf);
126 break;
127 }
128 case "Capture": {
129 const captureChoice: ICaptureChoice = choice as ICaptureChoice;
130 await this.onChooseCaptureType(captureChoice, originLeaf);
131 break;
132 }
133 case "Macro": {
134 const macroChoice: IMacroChoice = choice as IMacroChoice;
135 await this.onChooseMacroType(macroChoice, originLeaf);
136 break;
137 }
138 case "Multi": {
139 const multiChoice: IMultiChoice = choice as IMultiChoice;
140 this.onChooseMultiType(multiChoice);
141 break;
142 }
143 default:
144 break;
145 }
146
147 if (this.pendingAbort) {
148 promptDraftStore.rollbackExecutionScope();
149 return;
150 }
151
152 promptDraftStore.commitExecutionScope();
153 } catch (error) {
154 promptDraftStore.rollbackExecutionScope();
155 throw error;
156 } finally {
157 this.pendingResult = savedResult;
158 this.endExecutionContext();
159 }
160 }
161
162 async executeWithFocusedProperty(
163 choice: IChoice,

Callers 2

runUriChoiceLegacyMethod · 0.95

Calls 12

beginExecutionContextMethod · 0.95
onChooseTemplateTypeMethod · 0.95
onChooseCaptureTypeMethod · 0.95
onChooseMacroTypeMethod · 0.95
onChooseMultiTypeMethod · 0.95
endExecutionContextMethod · 0.95
getOpenFileOriginLeafFunction · 0.85
beginExecutionScopeMethod · 0.80
commitExecutionScopeMethod · 0.80
getInstanceMethod · 0.45

Tested by

no test coverage detected