-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Fix node.getStart()
for nodes spanning multiline JSDoc comments
#43854
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
Conversation
|
||
case CharacterCodes.asterisk: | ||
if (canConsumeStar) { | ||
pos++; |
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.
Dont you need to set canConsumeStar to false in the default case as well?
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.
I don’t think so—the default case is either whitespace (which doesn’t change whether we can consume a leading *
) or it breaks and returns.
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.
One question about whether skipTrivia is suitable in the first place.
@@ -478,7 +478,12 @@ namespace ts { | |||
return getTokenPosOfNode((<SyntaxList>node)._children[0], sourceFile, includeJsDoc); | |||
} | |||
|
|||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); |
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.
this looks like an OK fix, but I don't think skipTrivia is called on the inside of jsdoc anywhere else. Maybe there should be a completely separate code path?
I haven't thought about it deeply, so it's likely that skipTrivia is 98% right and just needed this tweak to work.
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.
Well, it’s definitely true that I didn’t pass the parameter anywhere else. It occurred to me that I could accomplish the same thing by wrapping skipTrivia
and calling it in a loop with stopAfterLineBreak
, but I felt like it was a little less clear what was happening. But I can go back to that—I’m pretty ambivalent about it.
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.
Ummm, me too. Neither one of these functions are specific to jsdoc, so jsdoc-specific code is surprise in both.
Probably means that this is good enough.
Fixes #43442
skipTrivia
needs to skip a leading*
inside JSDoc.