Handle JSDoc backticks in the parser, not scanner #30939
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, the jsdoc scanner had ad-hoc handling of backticks that was similar in structure to the normal scanner's handling of template literals, but much simpler. But the only use of these simplified template literals was to allow non-standard markdown-quoting of names in
@param
tags.This PR changes the jsdoc scanner to produce backticks instead of template literal tokens. This is a bigger change, but it (1) reflects that backticks aren't special except for markdown-quoted param names (2) avoids treating large swatches of jsdoc text as template literals, which causes code fences to break jsdoc asterisk handling in #23517.
Since this is a code improvement, I also improved a couple of other JSDoc parsing things:
Note that there are dependencies between subsequent calls to parseExpected/parseOptional/et al. Each of these functions, when they succeed, ask the scanner for the next token, but
parseExpectedTokenJSDoc
gets a jsdoc token, whereasparseExpectedToken
gets a normal token. Then the next function that inspects the current token will see that jsdoc/normal token.These dependencies are non-local and non-obvious. But I'm not sure sure of the best way to get rid of them, so I'm leaving them for now.
Fixes #23517