Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple template parameters #163191

Merged
merged 4 commits into from Oct 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion extensions/typescript-language-features/src/utils/previewer.ts
Expand Up @@ -84,7 +84,7 @@ function getTagDocumentation(
case 'extends':
case 'param':
case 'template': {
const body = (convertLinkTags(tag.text, filePathConverter)).split(/^(\S+)\s*-?\s*/);
const body = getTagBody(tag, filePathConverter);
if (body?.length === 3) {
const param = body[1];
const doc = body[2];
Expand All @@ -106,6 +106,18 @@ function getTagDocumentation(
return label + (text.match(/\r\n|\n/g) ? ' \n' + text : ` \u2014 ${text}`);
}

function getTagBody(tag: Proto.JSDocTagInfo, filePathConverter: IFilePathToResourceConverter): Array<string> | undefined {
if (tag.name === 'template') {
const parts = tag.text;
if (parts && typeof (parts) !== 'string') {
const params = parts.filter(p => p.kind === 'typeParameterName').map(p => p.text).join(', ');
const docs = parts.filter(p => p.kind === 'text').map(p => convertLinkTags(p.text.replace(/^\s*-?\s*/, ''), filePathConverter)).join(' ');
return params ? ['', params, docs] : undefined;
}
}
return (convertLinkTags(tag.text, filePathConverter)).split(/^(\S+)\s*-?\s*/);
}

export function plainWithLinks(
parts: readonly Proto.SymbolDisplayPart[] | string,
filePathConverter: IFilePathToResourceConverter,
Expand Down