Skip to content

Commit 5ecb611

Browse files
hyperpolymathclaude
andcommitted
feat(affine-vscode): languageClientSendRequest host binding (Refs #103)
#103 slice-2 (sendRequest half — owner-scoped; the callback half is tracked separately in #199). Adds languageClientSendRequest to the VscodeLanguageClient binding map in packages/affine-vscode/mod.js (the JS-side impl the #103 acceptance criteria names). It reads the method + JSON params string, parses the params (empty/malformed -> no params), invokes c.sendRequest, and registers the returned Thenable in the handle table — matching the existing newLanguageClient/start/stop pattern. No host->guest callback involved, so it is unaffected by the Deno callback-ABI gap. node --check clean. mod.js is a JS package (not dune-built); no 253 impact. Pilot scope note: the rsr-certifier vscode extension calls sendRequest *inside* a vscode.window.withProgress wrapper. withProgress needs the host->guest callback ABI, which the source-to-source backend lacks (#199). The full pilot restore is therefore blocked on #199; forcing a withProgress-less partial rewrite of a cross-repo production extension would be a damaging partial change and is deliberately not done here. This PR delivers the enabling binding; the pilot follows #199. Refs #103 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e1c1591 commit 5ecb611

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

packages/affine-vscode/mod.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,27 @@ module.exports = function makeVscodeBindings(vscode, lcModule, hostShim) {
345345
if (c) c.stop();
346346
return 0;
347347
},
348+
// `LanguageClient.sendRequest(method, params)` (issue #103). `params`
349+
// arrives as a JSON string (the binding's synchronous extern shape);
350+
// we parse it, invoke the LSP request, and register the returned
351+
// Thenable in the handle table. The consumer awaits it on the
352+
// source-to-source path (the wasm path additionally needs the
353+
// thenable-resolution primitives — tracked in #199). An empty or
354+
// malformed params string is treated as no params.
355+
languageClientSendRequest: (cHandle, methodPtr, paramsJsonPtr) => {
356+
const c = get(cHandle);
357+
if (!c) return 0;
358+
const method = readString(methodPtr);
359+
const raw = readString(paramsJsonPtr);
360+
let params;
361+
if (raw && raw.length > 0) {
362+
try { params = JSON.parse(raw); } catch (_e) { params = undefined; }
363+
}
364+
const thenable = params === undefined
365+
? c.sendRequest(method)
366+
: c.sendRequest(method, params);
367+
return reg(thenable);
368+
},
348369
};
349370

350371
return { Vscode, VscodeLanguageClient };

0 commit comments

Comments
 (0)