Skip to content

Commit 0e96c5e

Browse files
committed
Run fixupParentReferences when parsing isolated jsDocComment
1 parent 166f399 commit 0e96c5e

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/compiler/parser.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,26 @@ namespace ts {
440440

441441
/* @internal */
442442
export function parseIsolatedJSDocComment(content: string, start?: number, length?: number) {
443-
return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
443+
const result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
444+
if (result.jsDocComment) {
445+
// because the jsDocComment was parsed out of the source file, it might
446+
// not be covered by the fixupParentReferences.
447+
let parentNode: Node = result.jsDocComment;
448+
forEachChild(result.jsDocComment, visitNode);
449+
450+
function visitNode(n: Node): void {
451+
if (n.parent !== parentNode) {
452+
n.parent = parentNode;
453+
454+
const saveParent = parentNode;
455+
parentNode = n;
456+
forEachChild(n, visitNode);
457+
parentNode = saveParent;
458+
}
459+
}
460+
}
461+
462+
return result;
444463
}
445464

446465
/* @internal */
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
/////** @template T */
4+
////function ident<T>: T {
5+
////}
6+
7+
var c = classification;
8+
verify.syntacticClassificationsAre(
9+
c.comment("/** "),
10+
c.punctuation("@"),
11+
c.docCommentTagName("template"),
12+
c.typeParameterName("T"),
13+
c.comment(" */"),
14+
c.keyword("function"),
15+
c.identifier("ident"),
16+
c.punctuation("<"),
17+
c.typeParameterName("T"),
18+
c.punctuation(">"),
19+
c.punctuation(":"),
20+
c.identifier("T"),
21+
c.punctuation("{"),
22+
c.punctuation("}"));

0 commit comments

Comments
 (0)