MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / registerCodeAction

Function registerCodeAction

src/activate/registerCodeActions.ts:16–53  ·  view source on GitHub ↗
(context: vscode.ExtensionContext, command: CodeActionId, promptType: CodeActionName)

Source from the content-addressed store, hash-verified

14}
15
16const registerCodeAction = (context: vscode.ExtensionContext, command: CodeActionId, promptType: CodeActionName) => {
17 let userInput: string | undefined
18
19 context.subscriptions.push(
20 vscode.commands.registerCommand(getCodeActionCommand(command), async (...args: any[]) => {
21 // Handle both code action and direct command cases.
22 let filePath: string
23 let selectedText: string
24 let startLine: number | undefined
25 let endLine: number | undefined
26 let diagnostics: any[] | undefined
27
28 if (args.length > 1) {
29 // Called from code action.
30 ;[filePath, selectedText, startLine, endLine, diagnostics] = args
31 } else {
32 // Called directly from command palette.
33 const context = EditorUtils.getEditorContext()
34
35 if (!context) {
36 return
37 }
38
39 ;({ filePath, selectedText, startLine, endLine, diagnostics } = context)
40 }
41
42 const params = {
43 ...{ filePath, selectedText },
44 ...(startLine !== undefined ? { startLine: startLine.toString() } : {}),
45 ...(endLine !== undefined ? { endLine: endLine.toString() } : {}),
46 ...(diagnostics ? { diagnostics } : {}),
47 ...(userInput ? { userInput } : {}),
48 }
49
50 await ClineProvider.handleCodeAction(command, promptType, params)
51 }),
52 )
53}

Callers 1

registerCodeActionsFunction · 0.85

Calls 5

getCodeActionCommandFunction · 0.90
registerCommandMethod · 0.80
getEditorContextMethod · 0.80
handleCodeActionMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected