Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
21 changes: 20 additions & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 && 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;
Copy link
Contributor

@vladima vladima Jun 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just call fixupParentReferences here and pass result.jsDocComment as a parameter instead of copying the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be better, as I was thinking the fixupParentReferences was supposed to be called only for sourceFile nodes. Changing that.

forEachChild(result.jsDocComment, visitNode);

function visitNode(n: Node): void {
if (n.parent === undefined) {
n.parent = parentNode;

const saveParent = parentNode;
parentNode = n;
forEachChild(n, visitNode);
parentNode = saveParent;
}
}
}

return result;
}

/* @internal */
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("}"));