Repository navigation
#236, again - #238
Closed
Rich-Harris wants to merge 10 commits into
Closed
#236, again#238Rich-Harris wants to merge 10 commits into
Rich-Harris wants to merge 10 commits into
Conversation
The root visitor maps every node's start and end, which covers tokens that open a node. Tokens inside a node have no node boundary to anchor them: the brackets of a computed key, the parentheses of parameter lists, calls and control-flow heads, the braces of import and export lists, static blocks, switch and enum bodies, template interpolations, and every keyword written after a node's first token (`function` after `async`, `else`, `finally`, `while` in `do … while`, `default` after `export`, `type` after `import`, class and member modifiers, `extends`, `implements`, `in`, `of`, `as`, `satisfies`). A new `tokens` option takes the parser's token list (Acorn's `onToken`, Babel's `tokens`, ESLint-style `ast.tokens`). The tokens of interest are indexed once, sorted if the parser emitted them out of order, and each one is found by a bounded binary search from a position the AST does know. Without tokens they stay unmapped. Closing delimiters that end a node (`)` of a call, `]` of an array or computed member, `}` of an object, switch, enum or interface body) are mapped from the node's end without tokens, as BlockStatement already does. Printed output is unchanged; 61 sample maps gain segments. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A decorated class's decorators are printed before `export`, so the root visitor cannot map the export node's start where it is written. Emit that start once the decorators are out: the export node begins at `export` with both Acorn and typescript-estree, whichever side of it the decorators were written on. Instead of clearing the declaration's decorators and location while it is printed, remember that its decorators were printed. The root visitor then maps its start when that start is the `class` keyword (typescript-estree, decorators written before `export`) and skips it when it is a decorator (Acorn, see sveltejs/acorn-typescript#117), and the keyword lookup can locate `class`, `abstract` and the rest from the tokens because the node keeps its location. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Deferred from the first version of this branch until sveltejs#212 gave the catch clause its own visitor. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nst token matching
`import type {} from` was written as one string since sveltejs#219, so with tokens
neither the keyword nor the braces could match; write them one token at a time.
Add tests for the comment handling the token matcher relies on: a comment whose
text is a bracket (`/* ( */`, `// )`, a commented-out block, a comment line
that is a lone `}`) must not be consumed as the next source token, and the
real brackets after it must still map exactly.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Install the latest version of pnpm add https://pkg.svelte.dev/esrap/c/2729d072b2afcc75ce648da0af983338e91254feOpen in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: 2729d07 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Member
Author
|
ugh it won't let me push changes after merging |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
the previous PR was auto-deleted