// Convert protocol hover contents to VS Code MarkdownString objects. // MarkupContent, legacy MarkedString, and arrays are all valid LSP responses. function hoverContents(vscode, contents) { const entries = Array.isArray(contents) ? contents : [contents]; const result = []; for (const entry of entries) { if (!entry) continue; const value = typeof entry === 'string' ? entry : entry.value; if (typeof value !== 'string' || !value) continue; const md = new vscode.MarkdownString(); if (typeof entry === 'object' && entry.kind === 'plaintext') md.appendText(value); else if (typeof entry === 'object' && typeof entry.language === 'string') md.appendCodeblock(value, entry.language); else md.appendMarkdown(value); md.supportHtml = false; md.isTrusted = false; result.push(md); } return result; } module.exports = { hoverContents };