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

Method fetch

src/cm/lsp/inlayHints.ts:173–212  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171 }
172
173 async fetch(): Promise<void> {
174 const lsp = LSPPlugin.get(this.view) as LSPPluginAPI | null;
175 if (!lsp?.client.connected) return;
176
177 const caps = lsp.client.serverCapabilities;
178 if (!caps?.inlayHintProvider) return;
179
180 lsp.client.sync();
181 const id = ++this.reqId;
182 const doc = this.view.state.doc;
183
184 // Visible range with buffer
185 const { from, to } = this.view.viewport;
186 const buf = 20;
187 const startLn = Math.max(1, doc.lineAt(Math.max(0, from)).number - buf);
188 const endLn = Math.min(
189 doc.lines,
190 doc.lineAt(Math.min(doc.length, to)).number + buf,
191 );
192
193 try {
194 const hints = await lsp.client.request<
195 InlayHintParams,
196 InlayHint[] | null
197 >("textDocument/inlayHint", {
198 textDocument: { uri: lsp.uri },
199 range: {
200 start: lsp.toPosition(doc.line(startLn).from),
201 end: lsp.toPosition(doc.line(endLn).to),
202 },
203 });
204
205 if (id !== this.reqId) return;
206
207 const processed = this.process(lsp, hints ?? [], doc.length);
208 this.view.dispatch({ effects: setHints.of(processed) });
209 } catch {
210 // Non-critical - silently ignore
211 }
212 }
213
214 process(
215 lsp: LSPPluginAPI,

Callers 2

constructorMethod · 0.80
scheduleMethod · 0.80

Calls 2

processMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected