fix: append start/end info to more tags (#11930)

* fix: append start/end info to more tags

We should add them everywhere we can
Related https://github.com/sveltejs/language-tools/pull/2385

* changeset

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/11926/head
Simon H 6 months ago committed by GitHub
parent 6cf2ec5f83
commit 08b5851a66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: append start/end info to `AssignmentPattern` and `VariableDeclarator`

@ -281,10 +281,13 @@ function open(parser) {
parser.allow_whitespace(); parser.allow_whitespace();
if (parser.eat('=')) { if (parser.eat('=')) {
parser.allow_whitespace(); parser.allow_whitespace();
const right = read_expression(parser);
pattern = { pattern = {
type: 'AssignmentPattern', type: 'AssignmentPattern',
left: pattern, left: pattern,
right: read_expression(parser) right: right,
start: pattern.start,
end: right.end
}; };
} }
@ -572,7 +575,7 @@ function special(parser) {
declaration: { declaration: {
type: 'VariableDeclaration', type: 'VariableDeclaration',
kind: 'const', kind: 'const',
declarations: [{ type: 'VariableDeclarator', id, init }], declarations: [{ type: 'VariableDeclarator', id, init, start: id.start, end: init.end }],
start: start + 2, // start at const, not at @const start: start + 2, // start at const, not at @const
end: parser.index - 1 end: parser.index - 1
} }

Loading…
Cancel
Save