-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Run fixupParentReferences when parsing isolated jsDocComment #8930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect the check here to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might happen during incremental parsing; however as the jsDocComment is parsed in isolation, it is always parsed from scratch, so you are right that it should never happen. Will update. |
||
n.parent = parentNode; | ||
|
||
const saveParent = parentNode; | ||
parentNode = n; | ||
forEachChild(n, visitNode); | ||
parentNode = saveParent; | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
/* @internal */ | ||
|
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("}")); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 passresult.jsDocComment
as a parameter instead of copying the code?There was a problem hiding this comment.
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 forsourceFile
nodes. Changing that.