MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / applyCodeAction

Function applyCodeAction

src/cm/lsp/codeActions.ts:250–276  ·  view source on GitHub ↗

* Apply a code action following the LSP spec: * "If both edit and command are supplied, first the edit is applied, then the command is executed"

(
	view: EditorView,
	action: CodeAction,
)

Source from the content-addressed store, hash-verified

248 * "If both edit and command are supplied, first the edit is applied, then the command is executed"
249 */
250async function applyCodeAction(
251 view: EditorView,
252 action: CodeAction,
253): Promise<boolean> {
254 const plugin = LSPPlugin.get(view);
255 if (!plugin) return false;
256
257 plugin.client.sync();
258
259 // Resolve to get the edit if not already present
260 const resolved = await resolveCodeAction(plugin, action);
261 let success = false;
262
263 // Step 1: Apply workspace edit if present
264 if (resolved.edit) {
265 success = await applyWorkspaceEdit(view, resolved.edit);
266 }
267
268 // Step 2: Execute command if present (after edit per LSP spec)
269 if (resolved.command) {
270 const commandSuccess = await executeCommand(plugin, resolved.command);
271 success = success || commandSuccess;
272 }
273
274 plugin.client.sync();
275 return success;
276}
277
278export interface CodeActionItem {
279 title: string;

Callers 1

executeCodeActionFunction · 0.85

Calls 4

resolveCodeActionFunction · 0.85
applyWorkspaceEditFunction · 0.85
executeCommandFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected