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

Method process

src/cm/lsp/inlayHints.ts:214–266  ·  view source on GitHub ↗
(
				lsp: LSPPluginAPI,
				hints: InlayHint[],
				docLen: number,
			)

Source from the content-addressed store, hash-verified

212 }
213
214 process(
215 lsp: LSPPluginAPI,
216 hints: InlayHint[],
217 docLen: number,
218 ): ProcessedHint[] {
219 const result: ProcessedHint[] = [];
220
221 for (const h of hints) {
222 if (h.kind === TYPE_HINT && !showTypes) continue;
223 if (h.kind === PARAM_HINT && !showParams) continue;
224
225 let pos: number;
226 try {
227 pos = lsp.fromPosition(h.position, lsp.syncedDoc);
228 const mapped = lsp.unsyncedChanges.mapPos(pos);
229 if (mapped === null) continue;
230 pos = mapped;
231 } catch {
232 continue;
233 }
234
235 if (pos < 0 || pos > docLen) continue;
236
237 const label =
238 typeof h.label === "string"
239 ? h.label
240 : Array.isArray(h.label)
241 ? h.label.map((p: InlayHintLabelPart) => p.value).join("")
242 : "";
243 if (!label) continue;
244
245 const tooltip =
246 typeof h.tooltip === "string"
247 ? h.tooltip
248 : h.tooltip &&
249 typeof h.tooltip === "object" &&
250 "value" in h.tooltip
251 ? (h.tooltip as { value: string }).value
252 : undefined;
253
254 result.push({
255 pos,
256 label,
257 paddingLeft: h.paddingLeft,
258 paddingRight: h.paddingRight,
259 tooltip,
260 });
261
262 if (result.length >= max) break;
263 }
264
265 return result.sort((a, b) => a.pos - b.pos);
266 }
267
268 destroy(): void {
269 if (this.timer) clearTimeout(this.timer);

Callers 1

fetchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected