Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,14 @@ 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 && result.jsDocComment) {
// because the jsDocComment was parsed out of the source file, it might
// not be covered by the fixupParentReferences.
Parser.fixupParentReferences(result.jsDocComment);
}

return result;
}

/* @internal */
Expand Down Expand Up @@ -652,14 +659,14 @@ namespace ts {
return node;
}

export function fixupParentReferences(sourceFile: Node) {
export function fixupParentReferences(rootNode: Node) {
// normally parent references are set during binding. However, for clients that only need
// a syntax tree, and no semantic features, then the binding process is an unnecessary
// overhead. This functions allows us to set all the parents, without all the expense of
// binding.

let parent: Node = sourceFile;
forEachChild(sourceFile, visitNode);
let parent: Node = rootNode;
forEachChild(rootNode, visitNode);
return;

function visitNode(n: Node): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -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("}"));