vscode-typescript-languageservice
Advanced tools
Comparing version 0.26.8 to 0.26.9
@@ -50,3 +50,3 @@ "use strict"; | ||
if (details.displayParts) { | ||
detailTexts.push(previewer.plainWithLinks(details.displayParts, { toResource: shared.fsPathToUri })); | ||
detailTexts.push(previewer.plainWithLinks(details.displayParts, { toResource: shared.fsPathToUri }, getTextDocument2)); | ||
} | ||
@@ -53,0 +53,0 @@ if (detailTexts.length) { |
@@ -9,5 +9,5 @@ import type * as Proto from '../protocol'; | ||
} | ||
export declare function plainWithLinks(parts: readonly Proto.SymbolDisplayPart[] | string, filePathConverter: IFilePathToResourceConverter): string; | ||
export declare function plainWithLinks(parts: readonly Proto.SymbolDisplayPart[] | string, filePathConverter: IFilePathToResourceConverter, getTextDocument: (uri: string) => TextDocument | undefined): string; | ||
export declare function tagsMarkdownPreview(tags: readonly ts.JSDocTagInfo[], filePathConverter: IFilePathToResourceConverter, getTextDocument: (uri: string) => TextDocument | undefined): string; | ||
export declare function markdownDocumentation(documentation: Proto.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, filePathConverter: IFilePathToResourceConverter, getTextDocument: (uri: string) => TextDocument | undefined): string; | ||
export declare function addMarkdownDocumentation(out: string, documentation: Proto.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, converter: IFilePathToResourceConverter, getTextDocument: (uri: string) => TextDocument | undefined): string; |
@@ -24,3 +24,3 @@ "use strict"; | ||
} | ||
function getTagBodyText(tag, filePathConverter) { | ||
function getTagBodyText(tag, filePathConverter, getTextDocument) { | ||
if (!tag.text) { | ||
@@ -36,3 +36,3 @@ return undefined; | ||
} | ||
const text = convertLinkTags(tag.text, filePathConverter); | ||
const text = convertLinkTags(tag.text, filePathConverter, getTextDocument); | ||
switch (tag.name) { | ||
@@ -62,3 +62,3 @@ case 'example': | ||
} | ||
function getTagDocumentation(tag, filePathConverter) { | ||
function getTagDocumentation(tag, filePathConverter, getTextDocument) { | ||
switch (tag.name) { | ||
@@ -69,3 +69,3 @@ case 'augments': | ||
case 'template': | ||
const body = (convertLinkTags(tag.text, filePathConverter)).split(/^(\S+)\s*-?\s*/); | ||
const body = (convertLinkTags(tag.text, filePathConverter, getTextDocument)).split(/^(\S+)\s*-?\s*/); | ||
if ((body === null || body === void 0 ? void 0 : body.length) === 3) { | ||
@@ -83,3 +83,3 @@ const param = body[1]; | ||
const label = `*@${tag.name}*`; | ||
const text = getTagBodyText(tag, filePathConverter); | ||
const text = getTagBodyText(tag, filePathConverter, getTextDocument); | ||
if (!text) { | ||
@@ -90,4 +90,4 @@ return label; | ||
} | ||
function plainWithLinks(parts, filePathConverter) { | ||
return processInlineTags(convertLinkTags(parts, filePathConverter)); | ||
function plainWithLinks(parts, filePathConverter, getTextDocument) { | ||
return processInlineTags(convertLinkTags(parts, filePathConverter, getTextDocument)); | ||
} | ||
@@ -98,3 +98,3 @@ exports.plainWithLinks = plainWithLinks; | ||
*/ | ||
function convertLinkTags(parts, filePathConverter) { | ||
function convertLinkTags(parts, filePathConverter, getTextDocument) { | ||
var _a; | ||
@@ -114,4 +114,27 @@ if (!parts) { | ||
const text = (_a = currentLink.text) !== null && _a !== void 0 ? _a : currentLink.name; | ||
if (currentLink.target) { | ||
const link = filePathConverter.toResource(currentLink.target.file) + '#' + `L${currentLink.target.start.line},${currentLink.target.start.offset}`; | ||
let target = currentLink.target; | ||
if (typeof currentLink.target === 'object' && 'fileName' in currentLink.target) { | ||
const _target = currentLink.target; | ||
const fileDoc = getTextDocument(shared.uriToFsPath(_target.fileName)); | ||
if (fileDoc) { | ||
const start = fileDoc.positionAt(_target.textSpan.start); | ||
const end = fileDoc.positionAt(_target.textSpan.start + _target.textSpan.length); | ||
target = { | ||
file: _target.fileName, | ||
start: { | ||
line: start.line + 1, | ||
offset: start.character + 1, | ||
}, | ||
end: { | ||
line: end.line + 1, | ||
offset: end.character + 1, | ||
}, | ||
}; | ||
} | ||
else { | ||
target = undefined; | ||
} | ||
} | ||
if (target) { | ||
const link = filePathConverter.toResource(target.file) + '#' + `L${target.start.line},${target.start.offset}`; | ||
out.push(`[${text}](${link})`); | ||
@@ -150,42 +173,3 @@ } | ||
function tagsMarkdownPreview(tags, filePathConverter, getTextDocument) { | ||
// fix https://github.com/johnsoncodehk/volar/issues/289 | ||
tags = tags.map(tag => { | ||
if (tag.text) { | ||
return { | ||
...tag, | ||
text: tag.text.map(part => { | ||
const target = part.target; | ||
if (target && 'fileName' in target) { | ||
const fileDoc = getTextDocument(shared.uriToFsPath(target.fileName)); | ||
if (fileDoc) { | ||
const start = fileDoc.positionAt(target.textSpan.start); | ||
const end = fileDoc.positionAt(target.textSpan.start + target.textSpan.length); | ||
const newTarget = { | ||
file: target.fileName, | ||
start: { | ||
line: start.line + 1, | ||
offset: start.character + 1, | ||
}, | ||
end: { | ||
line: end.line + 1, | ||
offset: end.character + 1, | ||
}, | ||
}; | ||
return { | ||
...part, | ||
target: newTarget, | ||
}; | ||
} | ||
return { | ||
...part, | ||
target: undefined, | ||
}; | ||
} | ||
return part; | ||
}), | ||
}; | ||
} | ||
return tag; | ||
}); | ||
return tags.map(tag => getTagDocumentation(tag, filePathConverter)).join(' \n\n'); | ||
return tags.map(tag => getTagDocumentation(tag, filePathConverter, getTextDocument)).join(' \n\n'); | ||
} | ||
@@ -199,3 +183,3 @@ exports.tagsMarkdownPreview = tagsMarkdownPreview; | ||
if (documentation) { | ||
out += plainWithLinks(documentation, converter); | ||
out += plainWithLinks(documentation, converter, getTextDocument); | ||
} | ||
@@ -202,0 +186,0 @@ if (tags) { |
{ | ||
"name": "vscode-typescript-languageservice", | ||
"version": "0.26.8", | ||
"version": "0.26.9", | ||
"main": "out/index.js", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@volar/shared": "^0.26.8", | ||
"@volar/shared": "^0.26.9", | ||
"upath": "^2.0.1", | ||
@@ -25,3 +25,3 @@ "vscode-languageserver": "^8.0.0-next.1", | ||
}, | ||
"gitHead": "d777e06bd68dc56d87644e16cfe53e8e866378eb" | ||
"gitHead": "a108863c0a9d53619207bffc252f9a92384d714b" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112412
2196
Updated@volar/shared@^0.26.9