( plugin: LSPPlugin, action: CodeAction, )
| 93 | } |
| 94 | |
| 95 | async function resolveCodeAction( |
| 96 | plugin: LSPPlugin, |
| 97 | action: CodeAction, |
| 98 | ): Promise<CodeAction> { |
| 99 | // If action already has an edit, no need to resolve |
| 100 | if (action.edit) return action; |
| 101 | |
| 102 | const capabilities = plugin.client.serverCapabilities; |
| 103 | const provider = capabilities?.codeActionProvider; |
| 104 | const supportsResolve = |
| 105 | typeof provider === "object" && |
| 106 | provider !== null && |
| 107 | "resolveProvider" in provider && |
| 108 | provider.resolveProvider === true; |
| 109 | |
| 110 | if (!supportsResolve) return action; |
| 111 | |
| 112 | // Resolve to get the edit property (lazy computation per LSP 3.16+) |
| 113 | try { |
| 114 | const resolved = await plugin.client.request<CodeAction, CodeAction>( |
| 115 | "codeAction/resolve", |
| 116 | action, |
| 117 | ); |
| 118 | return resolved ?? action; |
| 119 | } catch (error) { |
| 120 | addLspLogFor(plugin, "warn", "Code action resolve failed", error); |
| 121 | console.warn("[LSP:CodeAction] Failed to resolve:", error); |
| 122 | return action; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | async function executeCommand( |
| 127 | plugin: LSPPlugin, |
no test coverage detected