mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
show jsdoc tags in sig help and for completion items
Fixes #26290 Exposes jsdoc tags such as `@priver` in the signature help and in completion items
This commit is contained in:
parent
173fc44723
commit
f7306841f6
|
@ -242,9 +242,11 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
|
|||
return item;
|
||||
}
|
||||
const detail = details[0];
|
||||
item.documentation = Previewer.plain(detail.documentation);
|
||||
item.detail = Previewer.plain(detail.displayParts);
|
||||
|
||||
const tags = Previewer.tagsPlainPreview(detail.tags);
|
||||
item.documentation = Previewer.plain(detail.documentation) + (tags ? '\n\n' + tags : '');
|
||||
|
||||
if (detail && this.config.useCodeSnippetsOnMethodSuggest && (item.kind === CompletionItemKind.Function || item.kind === CompletionItemKind.Method)) {
|
||||
return this.isValidFunctionCompletionContext(filepath, item.position).then(shouldCompleteFunction => {
|
||||
if (shouldCompleteFunction) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import { HoverProvider, Hover, TextDocument, Position, Range, CancellationToken
|
|||
|
||||
import * as Proto from '../protocol';
|
||||
import { ITypescriptServiceClient } from '../typescriptService';
|
||||
import { tagsMarkdownPreview } from "./previewer";
|
||||
|
||||
export default class TypeScriptHoverProvider implements HoverProvider {
|
||||
|
||||
|
@ -40,13 +41,10 @@ export default class TypeScriptHoverProvider implements HoverProvider {
|
|||
}
|
||||
|
||||
private static getContents(data: Proto.QuickInfoResponseBody) {
|
||||
const tags: string[] = [];
|
||||
for (const tag of data.tags || []) {
|
||||
tags.push(`*@${tag.name}*` + (tag.text ? ` — ${tag.text}` : ''));
|
||||
}
|
||||
const tags = tagsMarkdownPreview(data.tags);
|
||||
return [
|
||||
{ language: 'typescript', value: data.displayString },
|
||||
data.documentation + (tags.length ? '\n\n' + tags.join(' \n') : '')
|
||||
data.documentation + (tags ? '\n\n' + tags : '')
|
||||
];
|
||||
}
|
||||
}
|
|
@ -12,4 +12,16 @@ export function plain(parts: Proto.SymbolDisplayPart[]): string {
|
|||
return '';
|
||||
}
|
||||
return parts.map(part => part.text).join('');
|
||||
}
|
||||
|
||||
export function tagsMarkdownPreview(tags: Proto.JSDocTagInfo[]): string {
|
||||
return (tags || [])
|
||||
.map(tag => `*@${tag.name}*` + (tag.text ? ` — ${tag.text}` : ''))
|
||||
.join(' \n');
|
||||
}
|
||||
|
||||
export function tagsPlainPreview(tags: Proto.JSDocTagInfo[]): string {
|
||||
return (tags || [])
|
||||
.map(tag => `@${tag.name}` + (tag.text ? ` — ${tag.text}` : ''))
|
||||
.join('\n');
|
||||
}
|
|
@ -61,7 +61,10 @@ export default class TypeScriptSignatureHelpProvider implements SignatureHelpPro
|
|||
}
|
||||
});
|
||||
signature.label += Previewer.plain(item.suffixDisplayParts);
|
||||
signature.documentation = Previewer.plain(item.documentation);
|
||||
|
||||
const tags = Previewer.tagsPlainPreview(item.tags);
|
||||
signature.documentation = Previewer.plain(item.documentation) + (tags ? '\n\n' + tags : '');
|
||||
|
||||
result.signatures.push(signature);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue