Run fixupParentReferences when parsing isolated jsDocComment

This commit is contained in:
zhengbli
2016-06-01 22:57:25 -07:00
parent 166f399d17
commit 0e96c5eaf1
2 changed files with 42 additions and 1 deletions

View File

@@ -440,7 +440,26 @@ namespace ts {
/* @internal */
export function parseIsolatedJSDocComment(content: string, start?: number, length?: number) {
return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
const result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
if (result.jsDocComment) {
// because the jsDocComment was parsed out of the source file, it might
// not be covered by the fixupParentReferences.
let parentNode: Node = result.jsDocComment;
forEachChild(result.jsDocComment, visitNode);
function visitNode(n: Node): void {
if (n.parent !== parentNode) {
n.parent = parentNode;
const saveParent = parentNode;
parentNode = n;
forEachChild(n, visitNode);
parentNode = saveParent;
}
}
}
return result;
}
/* @internal */

View File

@@ -0,0 +1,22 @@
/// <reference path="fourslash.ts"/>
/////** @template T */
////function ident<T>: T {
////}
var c = classification;
verify.syntacticClassificationsAre(
c.comment("/** "),
c.punctuation("@"),
c.docCommentTagName("template"),
c.typeParameterName("T"),
c.comment(" */"),
c.keyword("function"),
c.identifier("ident"),
c.punctuation("<"),
c.typeParameterName("T"),
c.punctuation(">"),
c.punctuation(":"),
c.identifier("T"),
c.punctuation("{"),
c.punctuation("}"));