Skip triple-slash references

This commit is contained in:
Nathan Shively-Sanders
2020-08-06 09:11:46 -07:00
parent cf63bce7af
commit ae4b29c559
2 changed files with 18 additions and 7 deletions

View File

@@ -7215,6 +7215,7 @@ namespace ts {
}
function parseJSDocCommentWorker(startOrRanges: number | CommentRange[] = 0, length: number | undefined): JSDoc | undefined {
// TODO: Probably should save a boolean isTripleSlash at the beginning and make all the nested functions change their behaviour.
const content = sourceText; // TODO: Why alias this?
const comments: string[] = [];
let tags: JSDocTag[];
@@ -7223,16 +7224,25 @@ namespace ts {
if (Array.isArray(startOrRanges)) {
if (!startOrRanges.length) return undefined;
const ranges = startOrRanges;
for (const comment of ranges) {
const { pos: start, end } = comment;
let currentTag: JSDocTag | undefined; // TODO: Probably can use tags
for (const { pos: start, end } of ranges) {
if (isRecognizedTripleSlashComment(content, start, end)) continue;
const length = end - start;
scanner.scanRange(start + 3, length - 3, () => {
while (nextTokenJSDoc() !== SyntaxKind.EndOfFileToken) {
if (token() === SyntaxKind.AtToken) {
addTag(parseTag(0));
addTag(currentTag);
currentTag = parseTag(0);
}
else {
comments.push(scanner.getTokenText());
if (currentTag) {
// this doesn't update currentTag.end, which will cause problems later
// I think that parseXTag will have to return unfinished tags or something.
(currentTag as any).comment = (currentTag.comment || "") + scanner.getTokenText()
}
else {
comments.push(scanner.getTokenText());
}
}
}
});

View File

@@ -9,9 +9,10 @@
//// /// multiline comment
//// ///
//// /// @return {number}
//// function add1(n) {
//// function add1(/*2*/n) {
//// return n + 1
//// }
//// add1/*1*/
//// add1/*1*/(12)
verify.quickInfoAt('1', 'function add1(n: number): number', ' Adds one')
verify.quickInfoAt('1', 'function add1(n: number): number', ' Adds one ')
verify.quickInfoAt('2', '(parameter) n: number', '- this is a long, multiline comment ')