From 79a4fb718673e5af74075e0575b74b87ef2c406a Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Fri, 8 Mar 2024 22:56:46 +0900 Subject: [PATCH] fix: wrong scope in top level snippets (#486) --- .changeset/hot-impalas-do.md | 5 + src/context/index.ts | 13 +- src/context/script-let.ts | 58 +- src/parser/analyze-scope.ts | 19 +- src/parser/converts/block.ts | 3 + src/parser/converts/root.ts | 24 +- src/parser/template.ts | 2 - src/parser/typescript/analyze/index.ts | 8 +- src/parser/typescript/index.ts | 2 +- .../ts-snippet-hoist-scope-input.svelte | 9 + .../ts-snippet-hoist-scope-output.json | 1 + .../ts-snippet-hoist-scope-requirements.json | 5 + .../ts-snippet-hoist-scope-setup.ts | 27 + .../docs/snippets/01-scope-output.json | 3362 +++++++++---- .../docs/snippets/02-scope-output.json | 4270 +++++++++++++++-- .../03-snippet-scope-scope-output.json | 540 ++- .../04-snippet-scope-scope-output.json | 295 +- .../05-snippet-scope-scope-output.json | 1112 ++++- ...g-snippets-to-components-scope-output.json | 2066 +++++++- ...g-snippets-to-components-scope-output.json | 2038 +++++++- .../ast/svelte5/snippet01-hoist-input.svelte | 9 + .../ast/svelte5/snippet01-hoist-output.json | 1091 +++++ .../svelte5/snippet01-hoist-scope-output.json | 600 +++ .../svelte5/ts-snippet01-scope-output.json | 428 +- .../svelte5/ts-snippet02-hoist-input.svelte | 9 + .../svelte5/ts-snippet02-hoist-output.json | 1238 +++++ .../ts-snippet02-hoist-scope-output.json | 600 +++ tests/src/parser/typescript/index.ts | 4 +- 28 files changed, 15697 insertions(+), 2141 deletions(-) create mode 100644 .changeset/hot-impalas-do.md create mode 100644 tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-input.svelte create mode 100644 tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-output.json create mode 100644 tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-requirements.json create mode 100644 tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts create mode 100644 tests/fixtures/parser/ast/svelte5/snippet01-hoist-input.svelte create mode 100644 tests/fixtures/parser/ast/svelte5/snippet01-hoist-output.json create mode 100644 tests/fixtures/parser/ast/svelte5/snippet01-hoist-scope-output.json create mode 100644 tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-input.svelte create mode 100644 tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-output.json create mode 100644 tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-scope-output.json diff --git a/.changeset/hot-impalas-do.md b/.changeset/hot-impalas-do.md new file mode 100644 index 00000000..3f2c14eb --- /dev/null +++ b/.changeset/hot-impalas-do.md @@ -0,0 +1,5 @@ +--- +"svelte-eslint-parser": patch +--- + +fix: wrong scope in top level snippets diff --git a/src/context/index.ts b/src/context/index.ts index f613ae68..e91a34d6 100644 --- a/src/context/index.ts +++ b/src/context/index.ts @@ -33,6 +33,7 @@ export class ScriptsSourceCode { separate: string; beforeSpaces: string; render: string; + snippet: string; generics: string; } | null = null; @@ -57,6 +58,7 @@ export class ScriptsSourceCode { this._appendScriptLets.separate + this._appendScriptLets.beforeSpaces + this._appendScriptLets.render + + this._appendScriptLets.snippet + this._appendScriptLets.generics ); } @@ -64,16 +66,17 @@ export class ScriptsSourceCode { public getCurrentVirtualCodeInfo(): { script: string; render: string; - generics: string; + rootScope: string; } { if (this._appendScriptLets == null) { - return { script: this.raw, render: "", generics: "" }; + return { script: this.raw, render: "", rootScope: "" }; } return { script: this.trimmedRaw + this._appendScriptLets.separate, render: this._appendScriptLets.beforeSpaces + this._appendScriptLets.render, - generics: this._appendScriptLets.generics, + rootScope: + this._appendScriptLets.snippet + this._appendScriptLets.generics, }; } @@ -86,13 +89,14 @@ export class ScriptsSourceCode { this._appendScriptLets.separate.length + this._appendScriptLets.beforeSpaces.length + this._appendScriptLets.render.length + + this._appendScriptLets.snippet.length + this._appendScriptLets.generics.length ); } public addLet( letCode: string, - kind: "generics" | "render", + kind: "generics" | "snippet" | "render", ): { start: number; end: number } { if (this._appendScriptLets == null) { const currentLength = this.trimmedRaw.length; @@ -102,6 +106,7 @@ export class ScriptsSourceCode { separate: "\n;", beforeSpaces: after, render: "", + snippet: "", generics: "", }; } diff --git a/src/context/script-let.ts b/src/context/script-let.ts index 80682121..26244285 100644 --- a/src/context/script-let.ts +++ b/src/context/script-let.ts @@ -138,6 +138,8 @@ export class ScriptLetContext { private readonly unique = new UniqueIdGenerator(); + private currentScriptScopeKind: "render" | "snippet" = "render"; + public constructor(ctx: Context) { this.script = ctx.sourceCode.scripts; this.ctx = ctx; @@ -164,7 +166,7 @@ export class ScriptLetContext { this.appendScript( `(${part})${isTS ? `as (${typing})` : ""};`, range[0] - 1, - "render", + this.currentScriptScopeKind, (st, tokens, comments, result) => { const exprSt = st as ESTree.ExpressionStatement; const tsAs: TSAsExpression | null = isTS @@ -220,7 +222,7 @@ export class ScriptLetContext { this.appendScript( `({${part}});`, range[0] - 2, - "render", + this.currentScriptScopeKind, (st, tokens, _comments, result) => { const exprSt = st as ESTree.ExpressionStatement; const objectExpression: ESTree.ObjectExpression = @@ -259,7 +261,7 @@ export class ScriptLetContext { this.appendScript( `const ${part};`, range[0] - 6, - "render", + this.currentScriptScopeKind, (st, tokens, _comments, result) => { const decl = st as ESTree.VariableDeclaration; const node = decl.declarations[0]; @@ -393,7 +395,7 @@ export class ScriptLetContext { const restore = this.appendScript( `if(${part}){`, range[0] - 3, - "render", + this.currentScriptScopeKind, (st, tokens, _comments, result) => { const ifSt = st as ESTree.IfStatement; const node = ifSt.test; @@ -417,7 +419,7 @@ export class ScriptLetContext { ifSt.consequent = null as never; }, ); - this.pushScope(restore, "}"); + this.pushScope(restore, "}", this.currentScriptScopeKind); } public nestEachBlock( @@ -448,7 +450,7 @@ export class ScriptLetContext { const restore = this.appendScript( source, exprRange[0] - exprOffset, - "render", + this.currentScriptScopeKind, (st, tokens, comments, result) => { const expSt = st as ESTree.ExpressionStatement; const call = expSt.expression as ESTree.CallExpression; @@ -525,13 +527,14 @@ export class ScriptLetContext { expSt.expression = null as never; }, ); - this.pushScope(restore, "});"); + this.pushScope(restore, "});", this.currentScriptScopeKind); } public nestSnippetBlock( id: ESTree.Identifier, closeParentIndex: number, snippetBlock: SvelteSnippetBlock, + kind: "snippet" | "render", callback: (id: ESTree.Identifier, params: ESTree.Pattern[]) => void, ): void { const idRange = getNodeRange(id); @@ -539,7 +542,7 @@ export class ScriptLetContext { const restore = this.appendScript( `function ${part}{`, idRange[0] - 9, - "render", + kind, (st, tokens, _comments, result) => { const fnDecl = st as ESTree.FunctionDeclaration; const idNode = fnDecl.id; @@ -565,7 +568,7 @@ export class ScriptLetContext { fnDecl.params = []; }, ); - this.pushScope(restore, "}"); + this.pushScope(restore, "}", kind); } public nestBlock( @@ -588,7 +591,7 @@ export class ScriptLetContext { for (const preparationScript of generatedTypes.preparationScript) { this.appendScriptWithoutOffset( preparationScript, - "render", + this.currentScriptScopeKind, (node, tokens, comments, result) => { tokens.length = 0; comments.length = 0; @@ -608,7 +611,7 @@ export class ScriptLetContext { const restore = this.appendScript( `{`, block.range[0], - "render", + this.currentScriptScopeKind, (st, tokens, _comments, result) => { const blockSt = st as ESTree.BlockStatement; @@ -622,7 +625,7 @@ export class ScriptLetContext { blockSt.body = null as never; }, ); - this.pushScope(restore, "}"); + this.pushScope(restore, "}", this.currentScriptScopeKind); } else { const sortedParams = [...resolvedParams] .map((d) => { @@ -664,7 +667,7 @@ export class ScriptLetContext { const restore = this.appendScript( `(${source})=>{`, maps[0].range[0] - 1, - "render", + this.currentScriptScopeKind, (st, tokens, comments, result) => { const exprSt = st as ESTree.ExpressionStatement; const fn = exprSt.expression as ESTree.ArrowFunctionExpression; @@ -723,7 +726,7 @@ export class ScriptLetContext { exprSt.expression = null as never; }, ); - this.pushScope(restore, "};"); + this.pushScope(restore, "};", this.currentScriptScopeKind); } } @@ -738,7 +741,7 @@ export class ScriptLetContext { private appendScript( text: string, offset: number, - kind: "generics" | "render", + kind: "generics" | "snippet" | "render", callback: ( node: ESTree.Node, tokens: Token[], @@ -766,7 +769,7 @@ export class ScriptLetContext { private appendScriptWithoutOffset( text: string, - kind: "generics" | "render", + kind: "generics" | "snippet" | "render", callback: ( node: ESTree.Node, tokens: Token[], @@ -788,9 +791,16 @@ export class ScriptLetContext { return restoreCallback; } - private pushScope(restoreCallback: RestoreCallback, closeToken: string) { + private pushScope( + restoreCallback: RestoreCallback, + closeToken: string, + kind: "snippet" | "render", + ) { + const upper = this.currentScriptScopeKind; + this.currentScriptScopeKind = kind; this.closeScopeCallbacks.push(() => { - this.script.addLet(closeToken, "render"); + this.script.addLet(closeToken, kind); + this.currentScriptScopeKind = upper; restoreCallback.end = this.script.getCurrentVirtualCodeLength(); }); } @@ -825,7 +835,19 @@ export class ScriptLetContext { // If we replace the `scope.block` at this time, // the scope restore calculation will not work, so we will replace the `scope.block` later. postprocessList.push(() => { + const beforeBlock = scope.block; scope.block = node; + + for (const variable of [ + ...scope.variables, + ...(scope.upper?.variables ?? []), + ]) { + for (const def of variable.defs) { + if (def.node === beforeBlock) { + def.node = node; + } + } + } }); const scopes = nodeToScope.get(node); diff --git a/src/parser/analyze-scope.ts b/src/parser/analyze-scope.ts index 01650c2f..3731cf8d 100644 --- a/src/parser/analyze-scope.ts +++ b/src/parser/analyze-scope.ts @@ -235,16 +235,15 @@ export function analyzeSnippetsScope( (parent.kind === "special" && parent.name.name === "svelte:component")) ) { const scope = getScopeFromNode(scopeManager, snippet.id); - const variable = scope.upper - ? scope.upper.set.get(snippet.id.name) - : null; - if (variable) { - // Add the virtual reference for reading. - const reference = addVirtualReference(snippet.id, variable, scope, { - read: true, - }); - (reference as any).svelteSnippetReference = true; - } + const upperScope = scope.upper; + if (!upperScope) continue; + const variable = upperScope.set.get(snippet.id.name); + if (!variable) continue; + // Add the virtual reference for reading. + const reference = addVirtualReference(snippet.id, variable, upperScope, { + read: true, + }); + (reference as any).svelteSnippetReference = true; } } } diff --git a/src/parser/converts/block.ts b/src/parser/converts/block.ts index cd7e8fd7..699f4a21 100644 --- a/src/parser/converts/block.ts +++ b/src/parser/converts/block.ts @@ -655,10 +655,13 @@ export function convertSnippetBlock( ).end, ); + const scopeKind = parent.type === "Program" ? "snippet" : "render"; + ctx.scriptLet.nestSnippetBlock( node.expression, closeParenIndex, snippetBlock, + scopeKind, (id, params) => { snippetBlock.id = id; snippetBlock.params = params; diff --git a/src/parser/converts/root.ts b/src/parser/converts/root.ts index 6cfb117d..b39be927 100644 --- a/src/parser/converts/root.ts +++ b/src/parser/converts/root.ts @@ -45,6 +45,7 @@ export function convertSvelteRoot( ...ctx.getConvertLocation({ start: 0, end: ctx.code.length }), }; const body = ast.body; + const snippetChildren: Compiler.SnippetBlock[] = []; const fragment = getFragmentFromRoot(svelteAst); if (fragment) { let children = getChildren(fragment); @@ -63,11 +64,21 @@ export function convertSvelteRoot( children.push(options); } } - body.push(...convertChildren({ nodes: children }, ast, ctx)); + const nonSnippetChildren: typeof children = []; + for (const child of children) { + if (child.type === "SnippetBlock") { + snippetChildren.push(child); + } else { + nonSnippetChildren.push(child); + } + } + + body.push(...convertChildren({ nodes: nonSnippetChildren }, ast, ctx)); } + let script: SvelteScriptElement | null = null; const instance = getInstanceFromRoot(svelteAst); if (instance) { - const script: SvelteScriptElement = { + script = { type: "SvelteScriptElement", name: null as any, startTag: null as any, @@ -77,15 +88,13 @@ export function convertSvelteRoot( ...ctx.getConvertLocation(instance), }; extractAttributes(script, ctx); - if (ctx.parserOptions.svelteFeatures?.experimentalGenerics) - convertGenericsAttribute(script, ctx); extractElementTags(script, ctx, { buildNameNode: (openTokenRange) => { ctx.addToken("HTMLIdentifier", openTokenRange); const name: SvelteName = { type: "SvelteName", name: "script", - parent: script, + parent: script!, ...ctx.getConvertLocation(openTokenRange), }; return name; @@ -163,6 +172,9 @@ export function convertSvelteRoot( body.push(style); } + body.push(...convertChildren({ nodes: snippetChildren }, ast, ctx)); + if (script && ctx.parserOptions.svelteFeatures?.experimentalGenerics) + convertGenericsAttribute(script, ctx); // Set the scope of the Program node. ctx.scriptLet.addProgramRestore( @@ -188,6 +200,8 @@ export function convertSvelteRoot( }, ); + sortNodes(body); + return ast; } diff --git a/src/parser/template.ts b/src/parser/template.ts index af8f75cf..9cac7a59 100644 --- a/src/parser/template.ts +++ b/src/parser/template.ts @@ -4,7 +4,6 @@ import type * as Compiler from "svelte/compiler"; import type * as SvAST from "./svelte-ast-types"; import type { Context } from "../context"; import { convertSvelteRoot } from "./converts/index"; -import { sortNodes } from "./sort"; import type { SvelteProgram } from "../ast"; import { ParseError } from ".."; import type { NormalizedParserOptions } from "./parser-options"; @@ -27,7 +26,6 @@ export function parseTemplate( ...(svelteVersion.gte(5) ? { modern: true } : {}), }) as never as Compiler.Root | SvAST.AstLegacy; const ast = convertSvelteRoot(svelteAst, ctx); - sortNodes(ast.body); return { ast, diff --git a/src/parser/typescript/analyze/index.ts b/src/parser/typescript/analyze/index.ts index 8f62923b..51c9f01a 100644 --- a/src/parser/typescript/analyze/index.ts +++ b/src/parser/typescript/analyze/index.ts @@ -35,18 +35,18 @@ type TransformInfo = { * See https://github.com/sveltejs/svelte-eslint-parser/blob/main/docs/internal-mechanism.md#scope-types */ export function analyzeTypeScriptInSvelte( - code: { script: string; generics: string; render: string }, + code: { script: string; rootScope: string; render: string }, attrs: Record, parserOptions: NormalizedParserOptions, context: AnalyzeTypeScriptContext, ): VirtualTypeScriptContext { const ctx = new VirtualTypeScriptContext( - code.script + code.render + code.generics, + code.script + code.render + code.rootScope, ); ctx.appendOriginal(/^\s*/u.exec(code.script)![0].length); const result = parseScriptWithoutAnalyzeScope( - code.script + code.render + code.generics, + code.script + code.render + code.rootScope, attrs, { ...parserOptions, @@ -516,7 +516,7 @@ function* analyzeDollarDerivedScopes( * Transform source code to provide the correct type information in the HTML templates. */ function analyzeRenderScopes( - code: { script: string; render: string; generics: string }, + code: { script: string; render: string; rootScope: string }, ctx: VirtualTypeScriptContext, ) { ctx.appendOriginal(code.script.length); diff --git a/src/parser/typescript/index.ts b/src/parser/typescript/index.ts index b41eb498..4f2f2e3d 100644 --- a/src/parser/typescript/index.ts +++ b/src/parser/typescript/index.ts @@ -10,7 +10,7 @@ import type { TSESParseForESLintResult } from "./types"; * Parse for TypeScript in + +{#snippet foo()} +

Hello World!

+{/snippet} + +{@render bar()} diff --git a/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-output.json b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-output.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-output.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-requirements.json b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-requirements.json new file mode 100644 index 00000000..809a4e1f --- /dev/null +++ b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-requirements.json @@ -0,0 +1,5 @@ +{ + "parse": { + "svelte": ">=5.0.0-0" + } +} \ No newline at end of file diff --git a/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts new file mode 100644 index 00000000..6ea0958b --- /dev/null +++ b/tests/fixtures/integrations/snippet-scope/ts-snippet-hoist-scope-setup.ts @@ -0,0 +1,27 @@ +/* eslint eslint-comments/require-description: 0, @typescript-eslint/explicit-module-boundary-types: 0 */ +import type { Linter } from "eslint"; +import { generateParserOptions } from "../../../src/parser/test-utils"; +import { rules } from "@typescript-eslint/eslint-plugin"; +export function setupLinter(linter: Linter) { + linter.defineRule( + "@typescript-eslint/no-unused-vars", + rules["no-unused-vars"] as never, + ); +} + +export function getConfig() { + return { + parser: "svelte-eslint-parser", + parserOptions: { + ...generateParserOptions(), + svelteFeatures: { runes: true }, + }, + rules: { + "@typescript-eslint/no-unused-vars": "error", + }, + env: { + browser: true, + es2021: true, + }, + }; +} diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/01-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/01-scope-output.json index fb168cad..5b9b60d4 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/01-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/01-scope-output.json @@ -99,283 +99,27 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -303, - -291 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } - } - }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -284, - -268 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } - } - }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -259, - -245 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } - } - }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -235, - -220 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } - } - }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -201, - -185 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } - } - } - ], - "range": [ - 23, - 98 - ], - "loc": { - "start": { - "line": 1, - "column": 23 - }, - "end": { - "line": 6, - "column": 14 - } - } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], - "range": [ - 1, - 98 - ], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 6, - "column": 14 - } - } - } - } - ], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "figure", - "range": [ - 281, - 287 - ], - "loc": { - "start": { - "line": 16, - "column": 12 - }, - "end": { - "line": 16, - "column": 18 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "figure", - "range": [ - 10, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 16 - } - } - } - }, - { - "identifier": { - "type": "Identifier", - "name": "figure", - "range": [ - 323, - 329 - ], - "loc": { - "start": { - "line": 19, - "column": 11 - }, - "end": { - "line": 19, - "column": 17 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "figure", - "range": [ - 10, - 16 - ], - "loc": { - "start": { - "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 16 - } - } - } - } - ] - } - ], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "images", - "range": [ - 210, - 216 - ], - "loc": { - "start": { - "line": 13, - "column": 7 - }, - "end": { - "line": 13, - "column": 13 - } - } - }, - "from": "module", - "init": null, - "resolved": null - } - ], - "childScopes": [ - { - "type": "function", - "variables": [ - { - "name": "arguments", - "identifiers": [], - "defs": [], - "references": [] - }, - { - "name": "image", - "identifiers": [ - { + "type": "SvelteSnippetBlock", + "id": { "type": "Identifier", - "name": "image", + "name": "figure", "range": [ - 17, - 22 + 10, + 16 ], "loc": { "start": { "line": 1, - "column": 17 + "column": 10 }, "end": { "line": 1, - "column": 22 + "column": 16 } } - } - ], - "defs": [ - { - "type": "Parameter", - "name": { + }, + "params": [ + { "type": "Identifier", "name": "image", "range": [ @@ -392,381 +136,841 @@ "column": 22 } } - }, - "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -303, - -291 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } - } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figure", + "range": [ + 27, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 2 }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -284, - -268 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } - } + "end": { + "line": 2, + "column": 8 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 26, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 1 }, - { - "type": "ExpressionStatement", - "expression": null, + "end": { + "line": 2, + "column": 9 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 34, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "img", "range": [ - -259, - -245 + 38, + 41 ], "loc": { "start": { - "line": 0, - "column": null + "line": 3, + "column": 3 }, "end": { - "line": 0, - "column": null + "line": 3, + "column": 6 } } }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -235, - -220 - ], - "loc": { - "start": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "src", + "range": [ + 45, + 48 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 6 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "src", + "range": [ + 56, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "range": [ + 50, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "range": [ + 49, + 60 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 18 + } + } + } + ], + "range": [ + 45, + 60 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 18 + } + } }, - "end": { - "line": 0, - "column": null + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "alt", + "range": [ + 64, + 67 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "caption", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 69, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 68, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 22 + } + } + } + ], + "range": [ + 64, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 22 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "width", + "range": [ + 87, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 8 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 94, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "width", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 21 + } + } + }, + "range": [ + 94, + 105 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 21 + } + } + }, + "range": [ + 93, + 106 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + ], + "range": [ + 87, + 106 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "height", + "range": [ + 110, + 116 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 118, + 123 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 16 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "height", + "range": [ + 124, + 130 + ], + "loc": { + "start": { + "line": 7, + "column": 17 + }, + "end": { + "line": 7, + "column": 23 + } + } + }, + "range": [ + 118, + 130 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 23 + } + } + }, + "range": [ + 117, + 131 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 24 + } + } + } + ], + "range": [ + 110, + 131 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 24 + } + } } - } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "selfClosing": true, "range": [ - -201, - -185 + 37, + 136 ], "loc": { "start": { - "line": 0, - "column": null + "line": 3, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 8, + "column": 4 } } - } - ], + }, + "children": [], + "endTag": null, + "range": [ + 37, + 136 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 8, + "column": 4 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 136, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 9, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figcaption", + "range": [ + 140, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 3 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 139, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 152, + 157 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 20 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "caption", + "range": [ + 158, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 21 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + "range": [ + 152, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + "range": [ + 151, + 166 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 29 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 166, + 179 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 42 + } + } + }, + "range": [ + 139, + 179 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 42 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 179, + 181 + ], + "loc": { + "start": { + "line": 9, + "column": 42 + }, + "end": { + "line": 10, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - 23, - 98 + 181, + 190 ], "loc": { "start": { - "line": 1, - "column": 23 + "line": 10, + "column": 1 }, "end": { - "line": 6, - "column": 14 + "line": 10, + "column": 10 } } }, - "expression": false, - "generator": false, - "id": null, - "params": [], "range": [ - 1, - 98 + 26, + 190 ], "loc": { "start": { - "line": 1, + "line": 2, "column": 1 }, "end": { - "line": 6, - "column": 14 + "line": 10, + "column": 10 } } } - } - ], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 50, - 55 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 13 - } - } + ], + "range": [ + 0, + 201 + ], + "loc": { + "start": { + "line": 1, + "column": 0 }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } + "end": { + "line": 11, + "column": 10 } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 69, - 74 - ], - "loc": { - "start": { - "line": 5, - "column": 8 - }, - "end": { - "line": 5, - "column": 13 - } - } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "figure", + "range": [ + 281, + 287 + ], + "loc": { + "start": { + "line": 16, + "column": 12 }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } + "end": { + "line": 16, + "column": 18 } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 94, - 99 - ], - "loc": { - "start": { - "line": 6, - "column": 10 - }, - "end": { - "line": 6, - "column": 15 - } - } - }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } - } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 118, - 123 - ], - "loc": { - "start": { - "line": 7, - "column": 11 - }, - "end": { - "line": 7, - "column": 16 - } - } - }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } - } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 152, - 157 - ], - "loc": { - "start": { - "line": 9, - "column": 15 - }, - "end": { - "line": 9, - "column": 20 - } - } - }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } - } - } - ] - } - ], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 50, - 55 - ], - "loc": { - "start": { - "line": 4, - "column": 8 - }, - "end": { - "line": 4, - "column": 13 - } - } - }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 }, "end": { "line": 1, - "column": 22 + "column": 16 } } } @@ -774,170 +978,75 @@ { "identifier": { "type": "Identifier", - "name": "image", + "name": "figure", "range": [ - 69, - 74 + 323, + 329 ], "loc": { "start": { - "line": 5, - "column": 8 + "line": 19, + "column": 11 }, "end": { - "line": 5, - "column": 13 + "line": 19, + "column": 17 } } }, - "from": "function", + "from": "block", "init": null, "resolved": { "type": "Identifier", - "name": "image", + "name": "figure", "range": [ - 17, - 22 + 10, + 16 ], "loc": { "start": { "line": 1, - "column": 17 + "column": 10 }, "end": { "line": 1, - "column": 22 + "column": 16 } } } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 94, - 99 - ], - "loc": { - "start": { - "line": 6, - "column": 10 - }, - "end": { - "line": 6, - "column": 15 - } - } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "images", + "range": [ + 210, + 216 + ], + "loc": { + "start": { + "line": 13, + "column": 7 }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } + "end": { + "line": 13, + "column": 13 } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 118, - 123 - ], - "loc": { - "start": { - "line": 7, - "column": 11 - }, - "end": { - "line": 7, - "column": 16 - } - } - }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } - } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 152, - 157 - ], - "loc": { - "start": { - "line": 9, - "column": 15 - }, - "end": { - "line": 9, - "column": 20 - } - } - }, - "from": "function", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 17, - 22 - ], - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 22 - } - } - } - } - ], - "childScopes": [], - "through": [] - }, - { - "type": "function", - "variables": [ + } + }, + "from": "module", + "init": null, + "resolved": null + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ { "name": "image", "identifiers": [ @@ -1752,168 +1861,1392 @@ "line": 13, "column": 22 } - } - } - }, - { - "identifier": { - "type": "Identifier", - "name": "figure", - "range": [ - 281, - 287 + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "figure", + "range": [ + 281, + 287 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 18 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 288, + 293 + ], + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 22 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 256, + 261 + ], + "loc": { + "start": { + "line": 15, + "column": 11 + }, + "end": { + "line": 15, + "column": 16 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 22 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "figure", + "range": [ + 281, + 287 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 18 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 288, + 293 + ], + "loc": { + "start": { + "line": 16, + "column": 19 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 22 + } + } + } + } + ] + }, + { + "type": "block", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "figure", + "range": [ + 323, + 329 + ], + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 17 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 330, + 335 + ], + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 19, + "column": 23 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 22 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "figure", + "range": [ + 323, + 329 + ], + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 17 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 330, + 335 + ], + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 19, + "column": 23 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 22 + } + } + } + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "figure", + "range": [ + 281, + 287 + ], + "loc": { + "start": { + "line": 16, + "column": 12 + }, + "end": { + "line": 16, + "column": 18 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "figure", + "range": [ + 323, + 329 + ], + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 17 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + } + ] + }, + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "image", + "identifiers": [ + { + "type": "Identifier", + "name": "image", + "range": [ + 17, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "image", + "range": [ + 17, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + "node": { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "image", + "range": [ + 17, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figure", + "range": [ + 27, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 26, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 34, + 37 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "img", + "range": [ + 38, + 41 + ], + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 6 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "src", + "range": [ + 45, + 48 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 6 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "src", + "range": [ + 56, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "range": [ + 50, + 59 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "range": [ + 49, + 60 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 18 + } + } + } + ], + "range": [ + 45, + 60 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "alt", + "range": [ + 64, + 67 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "caption", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 69, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 21 + } + } + }, + "range": [ + 68, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 22 + } + } + } + ], + "range": [ + 64, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 22 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "width", + "range": [ + 87, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 8 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 94, + 99 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "width", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 21 + } + } + }, + "range": [ + 94, + 105 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 21 + } + } + }, + "range": [ + 93, + 106 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + ], + "range": [ + 87, + 106 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "height", + "range": [ + 110, + 116 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 118, + 123 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 16 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "height", + "range": [ + 124, + 130 + ], + "loc": { + "start": { + "line": 7, + "column": 17 + }, + "end": { + "line": 7, + "column": 23 + } + } + }, + "range": [ + 118, + 130 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 23 + } + } + }, + "range": [ + 117, + 131 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 24 + } + } + } + ], + "range": [ + 110, + 131 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 24 + } + } + } + ], + "selfClosing": true, + "range": [ + 37, + 136 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 8, + "column": 4 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 37, + 136 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 8, + "column": 4 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 136, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 9, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figcaption", + "range": [ + 140, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 3 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 139, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "image", + "range": [ + 152, + 157 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 20 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "caption", + "range": [ + 158, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 21 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + "range": [ + 152, + 165 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + "range": [ + 151, + 166 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 29 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 166, + 179 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 42 + } + } + }, + "range": [ + 139, + 179 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 42 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 179, + 181 + ], + "loc": { + "start": { + "line": 9, + "column": 42 + }, + "end": { + "line": 10, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 181, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 10 + } + } + }, + "range": [ + 26, + 190 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 10, + "column": 10 + } + } + } ], - "loc": { - "start": { - "line": 16, - "column": 12 - }, - "end": { - "line": 16, - "column": 18 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "figure", "range": [ - 10, - 16 + 0, + 201 ], "loc": { "start": { "line": 1, - "column": 10 - }, - "end": { - "line": 1, - "column": 16 - } - } - } - }, - { - "identifier": { - "type": "Identifier", - "name": "image", - "range": [ - 288, - 293 - ], - "loc": { - "start": { - "line": 16, - "column": 19 - }, - "end": { - "line": 16, - "column": 24 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 220, - 225 - ], - "loc": { - "start": { - "line": 13, - "column": 17 + "column": 0 }, "end": { - "line": 13, - "column": 22 + "line": 11, + "column": 10 } } } } ], - "childScopes": [], - "through": [ + "references": [ { "identifier": { "type": "Identifier", "name": "image", "range": [ - 256, - 261 + 50, + 55 ], "loc": { "start": { - "line": 15, - "column": 11 + "line": 4, + "column": 8 }, "end": { - "line": 15, - "column": 16 + "line": 4, + "column": 13 } } }, - "from": "block", + "from": "function", "init": null, "resolved": { "type": "Identifier", "name": "image", "range": [ - 220, - 225 - ], - "loc": { - "start": { - "line": 13, - "column": 17 - }, - "end": { - "line": 13, - "column": 22 - } - } - } - }, - { - "identifier": { - "type": "Identifier", - "name": "figure", - "range": [ - 281, - 287 - ], - "loc": { - "start": { - "line": 16, - "column": 12 - }, - "end": { - "line": 16, - "column": 18 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "figure", - "range": [ - 10, - 16 + 17, + 22 ], "loc": { "start": { "line": 1, - "column": 10 + "column": 17 }, "end": { "line": 1, - "column": 16 + "column": 22 } } } @@ -1923,83 +3256,37 @@ "type": "Identifier", "name": "image", "range": [ - 288, - 293 - ], - "loc": { - "start": { - "line": 16, - "column": 19 - }, - "end": { - "line": 16, - "column": 24 - } - } - }, - "from": "block", - "init": null, - "resolved": { - "type": "Identifier", - "name": "image", - "range": [ - 220, - 225 - ], - "loc": { - "start": { - "line": 13, - "column": 17 - }, - "end": { - "line": 13, - "column": 22 - } - } - } - } - ] - }, - { - "type": "block", - "variables": [], - "references": [ - { - "identifier": { - "type": "Identifier", - "name": "figure", - "range": [ - 323, - 329 + 69, + 74 ], "loc": { "start": { - "line": 19, - "column": 11 + "line": 5, + "column": 8 }, "end": { - "line": 19, - "column": 17 + "line": 5, + "column": 13 } } }, - "from": "block", + "from": "function", "init": null, "resolved": { "type": "Identifier", - "name": "figure", + "name": "image", "range": [ - 10, - 16 + 17, + 22 ], "loc": { "start": { "line": 1, - "column": 10 + "column": 17 }, "end": { "line": 1, - "column": 16 + "column": 22 } } } @@ -2009,80 +3296,77 @@ "type": "Identifier", "name": "image", "range": [ - 330, - 335 + 94, + 99 ], "loc": { "start": { - "line": 19, - "column": 18 + "line": 6, + "column": 10 }, "end": { - "line": 19, - "column": 23 + "line": 6, + "column": 15 } } }, - "from": "block", + "from": "function", "init": null, "resolved": { "type": "Identifier", "name": "image", "range": [ - 220, - 225 + 17, + 22 ], "loc": { "start": { - "line": 13, + "line": 1, "column": 17 }, "end": { - "line": 13, + "line": 1, "column": 22 } } } - } - ], - "childScopes": [], - "through": [ + }, { "identifier": { "type": "Identifier", - "name": "figure", + "name": "image", "range": [ - 323, - 329 + 118, + 123 ], "loc": { "start": { - "line": 19, + "line": 7, "column": 11 }, "end": { - "line": 19, - "column": 17 + "line": 7, + "column": 16 } } }, - "from": "block", + "from": "function", "init": null, "resolved": { "type": "Identifier", - "name": "figure", + "name": "image", "range": [ - 10, - 16 + 17, + 22 ], "loc": { "start": { "line": 1, - "column": 10 + "column": 17 }, "end": { "line": 1, - "column": 16 + "column": 22 } } } @@ -2092,36 +3376,36 @@ "type": "Identifier", "name": "image", "range": [ - 330, - 335 + 152, + 157 ], "loc": { "start": { - "line": 19, - "column": 18 + "line": 9, + "column": 15 }, "end": { - "line": 19, - "column": 23 + "line": 9, + "column": 20 } } }, - "from": "block", + "from": "function", "init": null, "resolved": { "type": "Identifier", "name": "image", "range": [ - 220, - 225 + 17, + 22 ], "loc": { "start": { - "line": 13, + "line": 1, "column": 17 }, "end": { - "line": 13, + "line": 1, "column": 22 } } @@ -2130,43 +3414,123 @@ ] } ], - "through": [ + "references": [ { "identifier": { "type": "Identifier", - "name": "figure", + "name": "image", "range": [ - 281, - 287 + 50, + 55 ], "loc": { "start": { - "line": 16, - "column": 12 + "line": 4, + "column": 8 }, "end": { - "line": 16, - "column": 18 + "line": 4, + "column": 13 } } }, - "from": "block", + "from": "function", "init": null, "resolved": { "type": "Identifier", - "name": "figure", + "name": "image", "range": [ - 10, - 16 + 17, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 69, + 74 ], "loc": { "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 17, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { "line": 1, + "column": 22 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 94, + 99 + ], + "loc": { + "start": { + "line": 6, "column": 10 }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 17, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, "end": { "line": 1, - "column": 16 + "column": 22 } } } @@ -2174,44 +3538,86 @@ { "identifier": { "type": "Identifier", - "name": "figure", + "name": "image", "range": [ - 323, - 329 + 118, + 123 ], "loc": { "start": { - "line": 19, + "line": 7, "column": 11 }, "end": { - "line": 19, + "line": 7, + "column": 16 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "image", + "range": [ + 17, + 22 + ], + "loc": { + "start": { + "line": 1, "column": 17 + }, + "end": { + "line": 1, + "column": 22 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "image", + "range": [ + 152, + 157 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 20 } } }, - "from": "block", + "from": "function", "init": null, "resolved": { "type": "Identifier", - "name": "figure", + "name": "image", "range": [ - 10, - 16 + 17, + 22 ], "loc": { "start": { "line": 1, - "column": 10 + "column": 17 }, "end": { "line": 1, - "column": 16 + "column": 22 } } } } - ] + ], + "childScopes": [], + "through": [] } ], "through": [ diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/02-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/02-scope-output.json index 46555110..f556b88c 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/02-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/02-scope-output.json @@ -99,133 +99,817 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -94, - -84 - ], - "loc": { - "start": { - "line": 0, - "column": null + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + "params": [ + { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } }, - "end": { - "line": 0, - "column": null + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "range": [ + 17, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 48 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figure", "range": [ - -85, - -77 + 53, + 59 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 8 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - -79, - -69 + 52, + 60 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 9 } } }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -71, - -60 - ], - "loc": { - "start": { - "line": 0, - "column": null + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 60, + 63 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "img", + "range": [ + 64, + 67 + ], + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 6 + } + } }, - "end": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "alt", + "range": [ + 68, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 73, + 80 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 19 + } + } + }, + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + } + } + } + ], + "range": [ + 68, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 20 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 26 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "range": [ + 88, + 95 + ], + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "range": [ + 96, + 104 + ], + "loc": { + "start": { + "line": 3, + "column": 35 + }, + "end": { + "line": 3, + "column": 43 + } + } + } + ], + "selfClosing": true, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 3, + "column": 46 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figcaption", + "range": [ + 111, + 121 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 110, + 122 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 123, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 122, + 131 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 131, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + "range": [ + 110, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 144, + 146 + ], + "loc": { + "start": { + "line": 4, + "column": 36 + }, + "end": { + "line": 5, + "column": 1 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -44, - -34 + 146, + 155 ], "loc": { "start": { - "line": 0, - "column": null + "line": 5, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 5, + "column": 10 } } - } - ], - "range": [ - 49, - 100 - ], - "loc": { - "start": { - "line": 1, - "column": 49 }, - "end": { - "line": 3, - "column": 39 + "range": [ + 52, + 155 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 5, + "column": 10 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 1, - 100 + 0, + 166 ], "loc": { "start": { "line": 1, - "column": 1 + "column": 0 }, "end": { - "line": 3, - "column": 39 + "line": 6, + "column": 10 } } } @@ -289,133 +973,817 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -94, - -84 - ], - "loc": { - "start": { - "line": 0, - "column": null + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + "params": [ + { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } }, - "end": { - "line": 0, - "column": null + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "range": [ + 17, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 48 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figure", "range": [ - -85, - -77 + 53, + 59 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 8 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - -79, - -69 + 52, + 60 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 9 } } }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -71, - -60 - ], - "loc": { - "start": { - "line": 0, - "column": null + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 60, + 63 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "img", + "range": [ + 64, + 67 + ], + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 6 + } + } }, - "end": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "alt", + "range": [ + 68, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 73, + 80 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 19 + } + } + }, + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + } + } + } + ], + "range": [ + 68, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 20 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 26 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "range": [ + 88, + 95 + ], + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "range": [ + 96, + 104 + ], + "loc": { + "start": { + "line": 3, + "column": 35 + }, + "end": { + "line": 3, + "column": 43 + } + } + } + ], + "selfClosing": true, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 3, + "column": 46 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figcaption", + "range": [ + 111, + 121 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 110, + 122 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 123, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 122, + 131 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 131, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + "range": [ + 110, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 144, + 146 + ], + "loc": { + "start": { + "line": 4, + "column": 36 + }, + "end": { + "line": 5, + "column": 1 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -44, - -34 + 146, + 155 ], "loc": { "start": { - "line": 0, - "column": null + "line": 5, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 5, + "column": 10 } } - } - ], - "range": [ - 49, - 100 - ], - "loc": { - "start": { - "line": 1, - "column": 49 }, - "end": { - "line": 3, - "column": 39 + "range": [ + 52, + 155 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 5, + "column": 10 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 1, - 100 + 0, + 166 ], "loc": { "start": { "line": 1, - "column": 1 + "column": 0 }, "end": { - "line": 3, - "column": 39 + "line": 6, + "column": 10 } } } @@ -508,133 +1876,817 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -94, - -84 - ], - "loc": { - "start": { - "line": 0, - "column": null + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + "params": [ + { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } }, - "end": { - "line": 0, - "column": null + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "range": [ + 17, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 48 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figure", "range": [ - -85, - -77 + 53, + 59 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 8 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - -79, - -69 + 52, + 60 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 9 } } }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -71, - -60 - ], - "loc": { - "start": { - "line": 0, - "column": null + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 60, + 63 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "img", + "range": [ + 64, + 67 + ], + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 6 + } + } }, - "end": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "alt", + "range": [ + 68, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 73, + 80 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 19 + } + } + }, + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + } + } + } + ], + "range": [ + 68, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 20 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 26 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "range": [ + 88, + 95 + ], + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "range": [ + 96, + 104 + ], + "loc": { + "start": { + "line": 3, + "column": 35 + }, + "end": { + "line": 3, + "column": 43 + } + } + } + ], + "selfClosing": true, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 3, + "column": 46 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figcaption", + "range": [ + 111, + 121 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 110, + 122 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 123, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 122, + 131 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 131, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + "range": [ + 110, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 144, + 146 + ], + "loc": { + "start": { + "line": 4, + "column": 36 + }, + "end": { + "line": 5, + "column": 1 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -44, - -34 + 146, + 155 ], "loc": { "start": { - "line": 0, - "column": null + "line": 5, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 5, + "column": 10 } } - } - ], - "range": [ - 49, - 100 - ], - "loc": { - "start": { - "line": 1, - "column": 49 }, - "end": { - "line": 3, - "column": 39 + "range": [ + 52, + 155 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 5, + "column": 10 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 1, - 100 + 0, + 166 ], "loc": { "start": { "line": 1, - "column": 1 + "column": 0 }, "end": { - "line": 3, - "column": 39 + "line": 6, + "column": 10 } } } @@ -767,133 +2819,817 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -94, - -84 - ], - "loc": { - "start": { - "line": 0, - "column": null + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + "params": [ + { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } }, - "end": { - "line": 0, - "column": null + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "range": [ + 17, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 48 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figure", "range": [ - -85, - -77 + 53, + 59 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 8 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - -79, - -69 + 52, + 60 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 9 } } }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -71, - -60 - ], - "loc": { - "start": { - "line": 0, - "column": null + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 60, + 63 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "img", + "range": [ + 64, + 67 + ], + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 6 + } + } }, - "end": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "alt", + "range": [ + 68, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 73, + 80 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 19 + } + } + }, + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + } + } + } + ], + "range": [ + 68, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 20 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 26 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "range": [ + 88, + 95 + ], + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "range": [ + 96, + 104 + ], + "loc": { + "start": { + "line": 3, + "column": 35 + }, + "end": { + "line": 3, + "column": 43 + } + } + } + ], + "selfClosing": true, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 3, + "column": 46 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figcaption", + "range": [ + 111, + 121 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 110, + 122 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 123, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 122, + 131 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 131, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + "range": [ + 110, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 144, + 146 + ], + "loc": { + "start": { + "line": 4, + "column": 36 + }, + "end": { + "line": 5, + "column": 1 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -44, - -34 + 146, + 155 ], "loc": { "start": { - "line": 0, - "column": null + "line": 5, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 5, + "column": 10 } } - } - ], - "range": [ - 49, - 100 - ], - "loc": { - "start": { - "line": 1, - "column": 49 }, - "end": { - "line": 3, - "column": 39 + "range": [ + 52, + 155 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 5, + "column": 10 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 1, - 100 + 0, + 166 ], "loc": { "start": { "line": 1, - "column": 1 + "column": 0 }, "end": { - "line": 3, - "column": 39 + "line": 6, + "column": 10 } } } @@ -986,133 +3722,817 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -94, - -84 - ], - "loc": { - "start": { - "line": 0, - "column": null + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "figure", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + "params": [ + { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } }, - "end": { - "line": 0, - "column": null + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "caption", + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + "range": [ + 24, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + "range": [ + 33, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } + } + }, + "range": [ + 40, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 46 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "range": [ + 17, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 48 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figure", "range": [ - -85, - -77 + 53, + 59 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 8 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - -79, - -69 + 52, + 60 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 2, + "column": 9 } } }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - -71, - -60 - ], - "loc": { - "start": { - "line": 0, - "column": null + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 60, + 63 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "img", + "range": [ + 64, + 67 + ], + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 3, + "column": 6 + } + } }, - "end": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "alt", + "range": [ + 68, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 10 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 73, + 80 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 19 + } + } + }, + "range": [ + 72, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 20 + } + } + } + ], + "range": [ + 68, + 81 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 20 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "value": { + "type": "Identifier", + "name": "src", + "range": [ + 83, + 86 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + "range": [ + 82, + 87 + ], + "loc": { + "start": { + "line": 3, + "column": 21 + }, + "end": { + "line": 3, + "column": 26 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "value": { + "type": "Identifier", + "name": "width", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 3, + "column": 33 + } + } + }, + "range": [ + 88, + 95 + ], + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 3, + "column": 34 + } + } + }, + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "value": { + "type": "Identifier", + "name": "height", + "range": [ + 97, + 103 + ], + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 42 + } + } + }, + "range": [ + 96, + 104 + ], + "loc": { + "start": { + "line": 3, + "column": 35 + }, + "end": { + "line": 3, + "column": 43 + } + } + } + ], + "selfClosing": true, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 63, + 107 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 46 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 3, + "column": 46 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "figcaption", + "range": [ + 111, + 121 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 110, + 122 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "caption", + "range": [ + 123, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 15 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 122, + 131 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 131, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + "range": [ + 110, + 144 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 36 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 144, + 146 + ], + "loc": { + "start": { + "line": 4, + "column": 36 + }, + "end": { + "line": 5, + "column": 1 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -44, - -34 + 146, + 155 ], "loc": { "start": { - "line": 0, - "column": null + "line": 5, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 5, + "column": 10 } } - } - ], - "range": [ - 49, - 100 - ], - "loc": { - "start": { - "line": 1, - "column": 49 }, - "end": { - "line": 3, - "column": 39 + "range": [ + 52, + 155 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 5, + "column": 10 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 1, - 100 + 0, + 166 ], "loc": { "start": { "line": 1, - "column": 1 + "column": 0 }, "end": { - "line": 3, - "column": 39 + "line": 6, + "column": 10 } } } diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/03-snippet-scope-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/03-snippet-scope-scope-output.json index a3acfcf0..17957314 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/03-snippet-scope-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/03-snippet-scope-scope-output.json @@ -480,79 +480,259 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "hello", + "range": [ + 86, + 91 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 92, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 20 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", "range": [ - -6, - 1 + 101, + 102 ], "loc": { "start": { - "line": 0, - "column": null + "line": 6, + "column": 2 }, "end": { - "line": 1, + "line": 6, + "column": 3 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 100, + 103 + ], + "loc": { + "start": { + "line": 6, "column": 1 + }, + "end": { + "line": 6, + "column": 4 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "children": [ + { + "type": "SvelteText", + "value": "hello ", + "range": [ + 103, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "name", + "range": [ + 110, + 114 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "range": [ + 109, + 115 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "SvelteText", + "value": "! ", + "range": [ + 115, + 117 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 18 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "message", + "range": [ + 118, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "range": [ + 117, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + { + "type": "SvelteText", + "value": "!", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 28 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - 2, - 12 + 127, + 131 ], "loc": { "start": { - "line": 1, - "column": 2 + "line": 6, + "column": 28 }, "end": { - "line": 2, - "column": 3 + "line": 6, + "column": 32 } } - } - ], - "range": [ - 97, - 116 - ], - "loc": { - "start": { - "line": 5, - "column": 21 }, - "end": { - "line": 6, - "column": 17 + "range": [ + 100, + 131 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 32 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 77, - 116 + 76, + 142 ], "loc": { "start": { "line": 5, - "column": 1 + "column": 0 }, "end": { - "line": 6, - "column": 17 + "line": 7, + "column": 10 } } } @@ -881,79 +1061,259 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "hello", + "range": [ + 86, + 91 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "name", + "range": [ + 92, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 20 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", "range": [ - -6, - 1 + 101, + 102 ], "loc": { "start": { - "line": 0, - "column": null + "line": 6, + "column": 2 }, "end": { - "line": 1, + "line": 6, + "column": 3 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 100, + 103 + ], + "loc": { + "start": { + "line": 6, "column": 1 + }, + "end": { + "line": 6, + "column": 4 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "children": [ + { + "type": "SvelteText", + "value": "hello ", + "range": [ + 103, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "name", + "range": [ + 110, + 114 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "range": [ + 109, + 115 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "SvelteText", + "value": "! ", + "range": [ + 115, + 117 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 18 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "message", + "range": [ + 118, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "range": [ + 117, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + { + "type": "SvelteText", + "value": "!", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 6, + "column": 27 + }, + "end": { + "line": 6, + "column": 28 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - 2, - 12 + 127, + 131 ], "loc": { "start": { - "line": 1, - "column": 2 + "line": 6, + "column": 28 }, "end": { - "line": 2, - "column": 3 + "line": 6, + "column": 32 } } - } - ], - "range": [ - 97, - 116 - ], - "loc": { - "start": { - "line": 5, - "column": 21 }, - "end": { - "line": 6, - "column": 17 + "range": [ + 100, + 131 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 32 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 77, - 116 + 76, + 142 ], "loc": { "start": { "line": 5, - "column": 1 + "column": 0 }, "end": { - "line": 6, - "column": 17 + "line": 7, + "column": 10 } } } diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/04-snippet-scope-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/04-snippet-scope-scope-output.json index 5cdf4262..6673fbaa 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/04-snippet-scope-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/04-snippet-scope-scope-output.json @@ -128,101 +128,204 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [], + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "x", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "params": [], + "children": [ + { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "y", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 13 + } + } + }, + "params": [], + "children": [ + { + "type": "SvelteText", + "value": "...", "range": [ - -450, - -448 + 38, + 41 ], "loc": { "start": { - "line": 0, - "column": null + "line": 3, + "column": 16 }, "end": { - "line": 0, - "column": null + "line": 3, + "column": 19 } } + } + ], + "range": [ + 24, + 51 + ], + "loc": { + "start": { + "line": 3, + "column": 2 }, - "expression": false, - "generator": false, - "id": null, - "params": [], - "range": [ - -462, - -448 - ], - "loc": { - "start": { - "line": 0, - "column": null - }, - "end": { - "line": 0, - "column": null - } + "end": { + "line": 3, + "column": 29 } - }, - { - "type": "ExpressionStatement", - "expression": null, + } + }, + { + "type": "SvelteText", + "value": "\n\n\t\t", + "range": [ + 51, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 29 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + { + "type": "SvelteHTMLComment", + "value": " this is fine ", + "range": [ + 55, + 76 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 23 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 76, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "y", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 12 + } + } + }, + "optional": false, "range": [ - -400, - -394 + 88, + 91 ], "loc": { "start": { - "line": 0, - "column": null + "line": 6, + "column": 11 }, "end": { - "line": 0, - "column": null + "line": 6, + "column": 14 } } - } - ], - "range": [ - -227, - -205 - ], - "loc": { - "start": { - "line": 0, - "column": null }, - "end": { - "line": 0, - "column": null + "range": [ + 79, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 15 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - -239, - -205 + 7, + 104 ], "loc": { "start": { - "line": 0, - "column": null + "line": 2, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 7, + "column": 11 } } } @@ -310,42 +413,58 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [], + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "y", "range": [ - -450, - -448 + 34, + 35 ], "loc": { "start": { - "line": 0, - "column": null + "line": 3, + "column": 12 }, "end": { - "line": 0, - "column": null + "line": 3, + "column": 13 } } }, - "expression": false, - "generator": false, - "id": null, "params": [], + "children": [ + { + "type": "SvelteText", + "value": "...", + "range": [ + 38, + 41 + ], + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 19 + } + } + } + ], "range": [ - -462, - -448 + 24, + 51 ], "loc": { "start": { - "line": 0, - "column": null + "line": 3, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 3, + "column": 29 } } } diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/05-snippet-scope-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/05-snippet-scope-scope-output.json index 5efe5dde..45556974 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/05-snippet-scope-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/05-snippet-scope-scope-output.json @@ -99,42 +99,132 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [], + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "blastoff", "range": [ - 20, - 22 + 10, + 18 ], "loc": { "start": { "line": 1, - "column": 20 + "column": 10 }, "end": { - "line": 2, - "column": 0 + "line": 1, + "column": 18 } } }, - "expression": false, - "generator": false, - "id": null, "params": [], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "span", + "range": [ + 24, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "🚀", + "range": [ + 29, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 9 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 31, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "range": [ + 23, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 16 + } + } + } + ], "range": [ - 1, - 22 + 0, + 49 ], "loc": { "start": { "line": 1, - "column": 1 + "column": 0 }, "end": { - "line": 2, - "column": 0 + "line": 3, + "column": 10 } } } @@ -227,81 +317,464 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "alternate": null, - "consequent": null, - "test": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "countdown", + "range": [ + 61, + 70 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "n", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 21 + } + } + } + ], + "children": [ + { + "type": "SvelteIfBlock", + "elseif": false, + "expression": { + "type": "BinaryExpression", + "left": { + "type": "Identifier", + "name": "n", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 7 + } + } + }, + "operator": ">", + "right": { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, "range": [ - -105, - -71 + 81, + 86 ], "loc": { "start": { - "line": 0, - "column": null + "line": 6, + "column": 6 }, "end": { - "line": 0, - "column": null + "line": 6, + "column": 11 } } }, - { - "type": "BlockStatement", - "body": null, + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "span", + "range": [ + 91, + 95 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 90, + 96 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "n", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + } + }, + "range": [ + 96, + 99 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + { + "type": "SvelteText", + "value": "...", + "range": [ + 99, + 102 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 14 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 102, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 21 + } + } + }, + "range": [ + 90, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 21 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 109, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 21 + }, + "end": { + "line": 8, + "column": 2 + } + } + }, + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "BinaryExpression", + "left": { + "type": "Identifier", + "name": "n", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 8, + "column": 21 + }, + "end": { + "line": 8, + "column": 22 + } + } + }, + "operator": "-", + "right": { + "type": "Literal", + "raw": "1", + "value": 1, + "range": [ + 135, + 136 + ], + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 26 + } + } + }, + "range": [ + 131, + 136 + ], + "loc": { + "start": { + "line": 8, + "column": 21 + }, + "end": { + "line": 8, + "column": 26 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "countdown", + "range": [ + 121, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 20 + } + } + }, + "optional": false, + "range": [ + 121, + 137 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 27 + } + } + }, + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 28 + } + } + } + ], + "else": { + "type": "SvelteElseBlock", + "elseif": false, + "children": [ + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "blastoff", + "range": [ + 159, + 167 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 159, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "range": [ + 150, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 22 + } + } + } + ], "range": [ - -43, - -28 + 140, + 172 ], "loc": { "start": { - "line": 0, - "column": null + "line": 9, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 11, + "column": 1 } } - } - ], - "range": [ - 73, - 124 - ], - "loc": { - "start": { - "line": 5, - "column": 22 }, - "end": { - "line": 8, - "column": 14 + "range": [ + 76, + 177 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 11, + "column": 6 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 52, - 124 + 51, + 188 ], "loc": { "start": { "line": 5, - "column": 1 + "column": 0 }, "end": { - "line": 8, - "column": 14 + "line": 12, + "column": 10 } } } @@ -313,21 +786,21 @@ "type": "Identifier", "name": "countdown", "range": [ - 121, - 130 + 199, + 208 ], "loc": { "start": { - "line": 8, - "column": 11 + "line": 14, + "column": 9 }, "end": { - "line": 8, - "column": 20 + "line": 14, + "column": 18 } } }, - "from": "block", + "from": "module", "init": null, "resolved": { "type": "Identifier", @@ -353,21 +826,21 @@ "type": "Identifier", "name": "countdown", "range": [ - 199, - 208 + 121, + 130 ], "loc": { "start": { - "line": 14, - "column": 9 + "line": 8, + "column": 11 }, "end": { - "line": 14, - "column": 18 + "line": 8, + "column": 20 } } }, - "from": "module", + "from": "block", "init": null, "resolved": { "type": "Identifier", @@ -501,81 +974,464 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "IfStatement", - "alternate": null, - "consequent": null, - "test": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "countdown", + "range": [ + 61, + 70 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "n", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 21 + } + } + } + ], + "children": [ + { + "type": "SvelteIfBlock", + "elseif": false, + "expression": { + "type": "BinaryExpression", + "left": { + "type": "Identifier", + "name": "n", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 7 + } + } + }, + "operator": ">", + "right": { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, "range": [ - -105, - -71 + 81, + 86 ], "loc": { "start": { - "line": 0, - "column": null + "line": 6, + "column": 6 }, "end": { - "line": 0, - "column": null + "line": 6, + "column": 11 } } }, - { - "type": "BlockStatement", - "body": null, + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "span", + "range": [ + 91, + 95 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 90, + 96 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "n", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + } + }, + "range": [ + 96, + 99 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + { + "type": "SvelteText", + "value": "...", + "range": [ + 99, + 102 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 14 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 102, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 14 + }, + "end": { + "line": 7, + "column": 21 + } + } + }, + "range": [ + 90, + 109 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 21 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 109, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 21 + }, + "end": { + "line": 8, + "column": 2 + } + } + }, + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "BinaryExpression", + "left": { + "type": "Identifier", + "name": "n", + "range": [ + 131, + 132 + ], + "loc": { + "start": { + "line": 8, + "column": 21 + }, + "end": { + "line": 8, + "column": 22 + } + } + }, + "operator": "-", + "right": { + "type": "Literal", + "raw": "1", + "value": 1, + "range": [ + 135, + 136 + ], + "loc": { + "start": { + "line": 8, + "column": 25 + }, + "end": { + "line": 8, + "column": 26 + } + } + }, + "range": [ + 131, + 136 + ], + "loc": { + "start": { + "line": 8, + "column": 21 + }, + "end": { + "line": 8, + "column": 26 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "countdown", + "range": [ + 121, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 20 + } + } + }, + "optional": false, + "range": [ + 121, + 137 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 27 + } + } + }, + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 28 + } + } + } + ], + "else": { + "type": "SvelteElseBlock", + "elseif": false, + "children": [ + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "blastoff", + "range": [ + 159, + 167 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 159, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "range": [ + 150, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 22 + } + } + } + ], "range": [ - -43, - -28 + 140, + 172 ], "loc": { "start": { - "line": 0, - "column": null + "line": 9, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 11, + "column": 1 } } - } - ], - "range": [ - 73, - 124 - ], - "loc": { - "start": { - "line": 5, - "column": 22 }, - "end": { - "line": 8, - "column": 14 + "range": [ + 76, + 177 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 11, + "column": 6 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 52, - 124 + 51, + 188 ], "loc": { "start": { "line": 5, - "column": 1 + "column": 0 }, "end": { - "line": 8, - "column": 14 + "line": 12, + "column": 10 } } } diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/06-passing-snippets-to-components-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/06-passing-snippets-to-components-scope-output.json index 830823da..c4944ad1 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/06-passing-snippets-to-components-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/06-passing-snippets-to-components-scope-output.json @@ -983,42 +983,462 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [], + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "header", "range": [ - 224, - 226 + 216, + 222 ], "loc": { "start": { "line": 11, - "column": 18 + "column": 10 }, "end": { - "line": 12, - "column": 0 + "line": 11, + "column": 16 } } }, - "expression": false, - "generator": false, - "id": null, "params": [], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 228, + 230 + ], + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 227, + 231 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "fruit", + "range": [ + 231, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 5 + }, + "end": { + "line": 12, + "column": 10 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 236, + 241 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + "range": [ + 227, + 241 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 241, + 243 + ], + "loc": { + "start": { + "line": 12, + "column": 15 + }, + "end": { + "line": 13, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 244, + 246 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 243, + 247 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "qty", + "range": [ + 247, + 250 + ], + "loc": { + "start": { + "line": 13, + "column": 5 + }, + "end": { + "line": 13, + "column": 8 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 250, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 8 + }, + "end": { + "line": 13, + "column": 13 + } + } + }, + "range": [ + 243, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 13 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 255, + 257 + ], + "loc": { + "start": { + "line": 13, + "column": 13 + }, + "end": { + "line": 14, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 258, + 260 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 257, + 261 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "price", + "range": [ + 261, + 266 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 10 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 266, + 271 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 15 + } + } + }, + "range": [ + 257, + 271 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 15 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 271, + 273 + ], + "loc": { + "start": { + "line": 14, + "column": 15 + }, + "end": { + "line": 15, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 274, + 276 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 273, + 277 + ], + "loc": { + "start": { + "line": 15, + "column": 1 + }, + "end": { + "line": 15, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "total", + "range": [ + 277, + 282 + ], + "loc": { + "start": { + "line": 15, + "column": 5 + }, + "end": { + "line": 15, + "column": 10 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 282, + 287 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 15 + } + } + }, + "range": [ + 273, + 287 + ], + "loc": { + "start": { + "line": 15, + "column": 1 + }, + "end": { + "line": 15, + "column": 15 + } + } + } + ], "range": [ - 207, - 226 + 206, + 298 ], "loc": { "start": { "line": 11, - "column": 1 + "column": 0 }, "end": { - "line": 12, - "column": 0 + "line": 16, + "column": 10 } } } @@ -1111,115 +1531,774 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - 151, - 160 - ], - "loc": { - "start": { - "line": 7, - "column": 4 - }, - "end": { - "line": 7, - "column": 13 - } - } + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "row", + "range": [ + 310, + 313 + ], + "loc": { + "start": { + "line": 18, + "column": 10 }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - 170, - 178 - ], - "loc": { - "start": { - "line": 7, - "column": 23 + "end": { + "line": 18, + "column": 13 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 314, + 315 + ], + "loc": { + "start": { + "line": 18, + "column": 14 + }, + "end": { + "line": 18, + "column": 15 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 320, + 322 + ], + "loc": { + "start": { + "line": 19, + "column": 2 + }, + "end": { + "line": 19, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 319, + 323 + ], + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 19, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 324, + 325 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 326, + 330 + ], + "loc": { + "start": { + "line": 19, + "column": 8 + }, + "end": { + "line": 19, + "column": 12 + } + } + }, + "range": [ + 324, + 330 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 12 + } + } + }, + "range": [ + 323, + 331 + ], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 13 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 331, + 336 + ], + "loc": { + "start": { + "line": 19, + "column": 13 + }, + "end": { + "line": 19, + "column": 18 + } + } + }, + "range": [ + 319, + 336 + ], + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 19, + "column": 18 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 336, + 338 + ], + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 20, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 339, + 341 + ], + "loc": { + "start": { + "line": 20, + "column": 2 + }, + "end": { + "line": 20, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 338, + 342 + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 343, + 344 + ], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 20, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 345, + 348 + ], + "loc": { + "start": { + "line": 20, + "column": 8 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "range": [ + 343, + 348 + ], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "range": [ + 342, + 349 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 12 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 349, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + "range": [ + 338, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 354, + 356 + ], + "loc": { + "start": { + "line": 20, + "column": 17 + }, + "end": { + "line": 21, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 357, + 359 + ], + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 21, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 356, + 360 + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 361, + 362 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 21, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 363, + 368 + ], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "range": [ + 361, + 368 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "range": [ + 360, + 369 + ], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 14 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 369, + 374 + ], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "range": [ + 356, + 374 + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 374, + 376 + ], + "loc": { + "start": { + "line": 21, + "column": 19 + }, + "end": { + "line": 22, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 377, + 379 + ], + "loc": { + "start": { + "line": 22, + "column": 2 + }, + "end": { + "line": 22, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 376, + 380 + ], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 22, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "BinaryExpression", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 381, + 382 + ], + "loc": { + "start": { + "line": 22, + "column": 6 + }, + "end": { + "line": 22, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 383, + 386 + ], + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + "range": [ + 381, + 386 + ], + "loc": { + "start": { + "line": 22, + "column": 6 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + "operator": "*", + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 389, + 390 + ], + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 391, + 396 + ], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "range": [ + 389, + 396 + ], + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "range": [ + 381, + 396 + ], + "loc": { + "start": { + "line": 22, + "column": 6 + }, + "end": { + "line": 22, + "column": 21 + } + } }, - "end": { - "line": 7, - "column": 31 + "range": [ + 380, + 397 + ], + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 22, + "column": 22 + } } } - }, - { - "type": "ExpressionStatement", - "expression": null, + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - 188, - 198 + 397, + 402 ], "loc": { "start": { - "line": 7, - "column": 41 + "line": 22, + "column": 22 }, "end": { - "line": 9, - "column": 3 + "line": 22, + "column": 27 } } }, - { - "type": "ExpressionStatement", - "expression": null, - "range": [ - 208, - 226 - ], - "loc": { - "start": { - "line": 11, - "column": 2 - }, - "end": { - "line": 12, - "column": 0 - } + "range": [ + 376, + 402 + ], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 22, + "column": 27 } } - ], - "range": [ - 316, - 363 - ], - "loc": { - "start": { - "line": 18, - "column": 16 - }, - "end": { - "line": 21, - "column": 8 - } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 301, - 363 + 300, + 413 ], "loc": { "start": { "line": 18, - "column": 1 + "column": 0 }, "end": { - "line": 21, - "column": 8 + "line": 23, + "column": 10 } } } @@ -1539,115 +2618,774 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "row", + "range": [ + 310, + 313 + ], + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 13 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 314, + 315 + ], + "loc": { + "start": { + "line": 18, + "column": 14 + }, + "end": { + "line": 18, + "column": 15 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", "range": [ - 151, - 160 + 320, + 322 ], "loc": { "start": { - "line": 7, + "line": 19, + "column": 2 + }, + "end": { + "line": 19, "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 319, + 323 + ], + "loc": { + "start": { + "line": 19, + "column": 1 }, "end": { - "line": 7, + "line": 19, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 324, + 325 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 326, + 330 + ], + "loc": { + "start": { + "line": 19, + "column": 8 + }, + "end": { + "line": 19, + "column": 12 + } + } + }, + "range": [ + 324, + 330 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 12 + } + } + }, + "range": [ + 323, + 331 + ], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 13 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 331, + 336 + ], + "loc": { + "start": { + "line": 19, "column": 13 + }, + "end": { + "line": 19, + "column": 18 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "range": [ + 319, + 336 + ], + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 19, + "column": 18 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 336, + 338 + ], + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 20, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", "range": [ - 170, - 178 + 339, + 341 ], "loc": { "start": { - "line": 7, - "column": 23 + "line": 20, + "column": 2 }, "end": { - "line": 7, - "column": 31 + "line": 20, + "column": 4 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - 188, - 198 + 338, + 342 ], "loc": { "start": { - "line": 7, - "column": 41 + "line": 20, + "column": 1 }, "end": { - "line": 9, - "column": 3 + "line": 20, + "column": 5 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 343, + 344 + ], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 20, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 345, + 348 + ], + "loc": { + "start": { + "line": 20, + "column": 8 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "range": [ + 343, + 348 + ], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "range": [ + 342, + 349 + ], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 12 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 349, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + "range": [ + 338, + 354 + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 354, + 356 + ], + "loc": { + "start": { + "line": 20, + "column": 17 + }, + "end": { + "line": 21, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", "range": [ - 208, - 226 + 357, + 359 ], "loc": { "start": { - "line": 11, + "line": 21, "column": 2 }, "end": { - "line": 12, - "column": 0 + "line": 21, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 356, + 360 + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 361, + 362 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 21, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 363, + 368 + ], + "loc": { + "start": { + "line": 21, + "column": 8 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "range": [ + 361, + 368 + ], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 21, + "column": 13 + } + } + }, + "range": [ + 360, + 369 + ], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 14 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 369, + 374 + ], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 19 } } + }, + "range": [ + 356, + 374 + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 19 + } } - ], - "range": [ - 316, - 363 - ], - "loc": { - "start": { - "line": 18, - "column": 16 + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 374, + 376 + ], + "loc": { + "start": { + "line": 21, + "column": 19 + }, + "end": { + "line": 22, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 377, + 379 + ], + "loc": { + "start": { + "line": 22, + "column": 2 + }, + "end": { + "line": 22, + "column": 4 + } + } }, - "end": { - "line": 21, - "column": 8 + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 376, + 380 + ], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 22, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "BinaryExpression", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 381, + 382 + ], + "loc": { + "start": { + "line": 22, + "column": 6 + }, + "end": { + "line": 22, + "column": 7 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 383, + 386 + ], + "loc": { + "start": { + "line": 22, + "column": 8 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + "range": [ + 381, + 386 + ], + "loc": { + "start": { + "line": 22, + "column": 6 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + "operator": "*", + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 389, + 390 + ], + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 391, + 396 + ], + "loc": { + "start": { + "line": 22, + "column": 16 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "range": [ + 389, + 396 + ], + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "range": [ + 381, + 396 + ], + "loc": { + "start": { + "line": 22, + "column": 6 + }, + "end": { + "line": 22, + "column": 21 + } + } + }, + "range": [ + 380, + 397 + ], + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 22, + "column": 22 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 397, + 402 + ], + "loc": { + "start": { + "line": 22, + "column": 22 + }, + "end": { + "line": 22, + "column": 27 + } + } + }, + "range": [ + 376, + 402 + ], + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 22, + "column": 27 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 301, - 363 + 300, + 413 ], "loc": { "start": { "line": 18, - "column": 1 + "column": 0 }, "end": { - "line": 21, - "column": 8 + "line": 23, + "column": 10 } } } diff --git a/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json index d6e311a2..6092b117 100644 --- a/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/docs/snippets/07-passing-snippets-to-components-scope-output.json @@ -128,42 +128,462 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [], + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "header", "range": [ - -158, - -156 + 85, + 91 ], "loc": { "start": { - "line": 0, - "column": null + "line": 3, + "column": 11 }, "end": { - "line": 0, - "column": null + "line": 3, + "column": 17 } } }, - "expression": false, - "generator": false, - "id": null, "params": [], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 98, + 100 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 97, + 101 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "fruit", + "range": [ + 101, + 106 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 11 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 106, + 111 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 16 + } + } + }, + "range": [ + 97, + 111 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 16 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 111, + 114 + ], + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 115, + 117 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 114, + 118 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "qty", + "range": [ + 118, + 121 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 9 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 121, + 126 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 14 + } + } + }, + "range": [ + 114, + 126 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 14 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 126, + 129 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 130, + 132 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 129, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "price", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 11 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 138, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + "range": [ + 129, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 143, + 146 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "th", + "range": [ + 147, + 149 + ], + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 146, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "total", + "range": [ + 150, + 155 + ], + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 7, + "column": 11 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 155, + 160 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 16 + } + } + }, + "range": [ + 146, + 160 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 16 + } + } + } + ], "range": [ - -175, - -156 + 75, + 172 ], "loc": { "start": { - "line": 0, - "column": null + "line": 3, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 8, + "column": 11 } } } @@ -189,7 +609,7 @@ } } }, - "from": "function", + "from": "block", "init": null, "resolved": { "type": "Identifier", @@ -256,115 +676,774 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "row", + "range": [ + 185, + 188 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 14 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 189, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 16 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 196, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 195, + 199 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 200, + 201 + ], + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 202, + 206 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 13 + } + } + }, + "range": [ + 200, + 206 + ], + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 13 + } + } + }, + "range": [ + 199, + 207 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 14 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 207, + 212 + ], + "loc": { + "start": { + "line": 11, + "column": 14 + }, + "end": { + "line": 11, + "column": 19 + } + } + }, + "range": [ + 195, + 212 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 19 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 212, + 215 + ], + "loc": { + "start": { + "line": 11, + "column": 19 + }, + "end": { + "line": 12, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 216, + 218 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 215, + 219 + ], + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 220, + 221 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 222, + 225 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 12, + "column": 12 + } + } + }, + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 12 + } + } + }, + "range": [ + 219, + 226 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 13 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -208, - -199 + 226, + 231 ], "loc": { "start": { - "line": 0, - "column": null + "line": 12, + "column": 13 }, "end": { - "line": 0, - "column": null + "line": 12, + "column": 18 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "range": [ + 215, + 231 + ], + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 18 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 231, + 234 + ], + "loc": { + "start": { + "line": 12, + "column": 18 + }, + "end": { + "line": 13, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", "range": [ - -188, - -180 + 235, + 237 ], "loc": { "start": { - "line": 0, - "column": null + "line": 13, + "column": 3 }, "end": { - "line": 0, - "column": null + "line": 13, + "column": 5 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - -169, - -159 + 234, + 238 ], "loc": { "start": { - "line": 0, - "column": null + "line": 13, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 13, + "column": 6 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 239, + 240 + ], + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 13, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 241, + 246 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "range": [ + 239, + 246 + ], + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "range": [ + 238, + 247 + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 15 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -148, - -130 + 247, + 252 ], "loc": { "start": { - "line": 0, - "column": null + "line": 13, + "column": 15 }, "end": { - "line": 0, - "column": null + "line": 13, + "column": 20 } } + }, + "range": [ + 234, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 20 + } } - ], - "range": [ - -60, - -13 - ], - "loc": { - "start": { - "line": 0, - "column": null + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 252, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 20 + }, + "end": { + "line": 14, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 256, + 258 + ], + "loc": { + "start": { + "line": 14, + "column": 3 + }, + "end": { + "line": 14, + "column": 5 + } + } }, - "end": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 255, + 259 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "BinaryExpression", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 262, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 12 + } + } + }, + "range": [ + 260, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 12 + } + } + }, + "operator": "*", + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 268, + 269 + ], + "loc": { + "start": { + "line": 14, + "column": 15 + }, + "end": { + "line": 14, + "column": 16 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 270, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 22 + } + } + }, + "range": [ + 268, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 15 + }, + "end": { + "line": 14, + "column": 22 + } + } + }, + "range": [ + 260, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 22 + } + } + }, + "range": [ + 259, + 276 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 276, + 281 + ], + "loc": { + "start": { + "line": 14, + "column": 23 + }, + "end": { + "line": 14, + "column": 28 + } + } + }, + "range": [ + 255, + 281 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 28 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - -75, - -13 + 175, + 293 ], "loc": { "start": { - "line": 0, - "column": null + "line": 10, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 15, + "column": 11 } } } @@ -390,7 +1469,7 @@ } } }, - "from": "function", + "from": "block", "init": null, "resolved": { "type": "Identifier", @@ -507,115 +1586,774 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "row", + "range": [ + 185, + 188 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 10, + "column": 14 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "d", + "range": [ + 189, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 16 + } + } + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 196, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 195, + 199 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 200, + 201 + ], + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "name", + "range": [ + 202, + 206 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 13 + } + } + }, + "range": [ + 200, + 206 + ], + "loc": { + "start": { + "line": 11, + "column": 7 + }, + "end": { + "line": 11, + "column": 13 + } + } + }, + "range": [ + 199, + 207 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 14 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -208, - -199 + 207, + 212 ], "loc": { "start": { - "line": 0, - "column": null + "line": 11, + "column": 14 }, "end": { - "line": 0, - "column": null + "line": 11, + "column": 19 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "range": [ + 195, + 212 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 19 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 212, + 215 + ], + "loc": { + "start": { + "line": 11, + "column": 19 + }, + "end": { + "line": 12, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", "range": [ - -188, - -180 + 216, + 218 ], "loc": { "start": { - "line": 0, - "column": null + "line": 12, + "column": 3 }, "end": { - "line": 0, - "column": null + "line": 12, + "column": 5 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, "range": [ - -169, - -159 + 215, + 219 ], "loc": { "start": { - "line": 0, - "column": null + "line": 12, + "column": 2 }, "end": { - "line": 0, - "column": null + "line": 12, + "column": 6 } } }, - { - "type": "ExpressionStatement", - "expression": null, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 220, + 221 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 222, + 225 + ], + "loc": { + "start": { + "line": 12, + "column": 9 + }, + "end": { + "line": 12, + "column": 12 + } + } + }, + "range": [ + 220, + 225 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 12 + } + } + }, + "range": [ + 219, + 226 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 13 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", "range": [ - -148, - -130 + 226, + 231 ], "loc": { "start": { - "line": 0, - "column": null + "line": 12, + "column": 13 }, "end": { - "line": 0, - "column": null + "line": 12, + "column": 18 } } + }, + "range": [ + 215, + 231 + ], + "loc": { + "start": { + "line": 12, + "column": 2 + }, + "end": { + "line": 12, + "column": 18 + } } - ], - "range": [ - -60, - -13 - ], - "loc": { - "start": { - "line": 0, - "column": null + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 231, + 234 + ], + "loc": { + "start": { + "line": 12, + "column": 18 + }, + "end": { + "line": 13, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 235, + 237 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 5 + } + } }, - "end": { - "line": 0, - "column": null + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 234, + 238 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 239, + 240 + ], + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 13, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 241, + 246 + ], + "loc": { + "start": { + "line": 13, + "column": 9 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "range": [ + 239, + 246 + ], + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "range": [ + 238, + 247 + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 15 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 247, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 15 + }, + "end": { + "line": 13, + "column": 20 + } + } + }, + "range": [ + 234, + 252 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 20 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t\t", + "range": [ + 252, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 20 + }, + "end": { + "line": 14, + "column": 2 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "td", + "range": [ + 256, + 258 + ], + "loc": { + "start": { + "line": 14, + "column": 3 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 255, + 259 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 6 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "BinaryExpression", + "left": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "qty", + "range": [ + 262, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 12 + } + } + }, + "range": [ + 260, + 265 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 12 + } + } + }, + "operator": "*", + "right": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "d", + "range": [ + 268, + 269 + ], + "loc": { + "start": { + "line": 14, + "column": 15 + }, + "end": { + "line": 14, + "column": 16 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "price", + "range": [ + 270, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 17 + }, + "end": { + "line": 14, + "column": 22 + } + } + }, + "range": [ + 268, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 15 + }, + "end": { + "line": 14, + "column": 22 + } + } + }, + "range": [ + 260, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 22 + } + } + }, + "range": [ + 259, + 276 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 276, + 281 + ], + "loc": { + "start": { + "line": 14, + "column": 23 + }, + "end": { + "line": 14, + "column": 28 + } + } + }, + "range": [ + 255, + 281 + ], + "loc": { + "start": { + "line": 14, + "column": 2 + }, + "end": { + "line": 14, + "column": 28 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - -75, - -13 + 175, + 293 ], "loc": { "start": { - "line": 0, - "column": null + "line": 10, + "column": 1 }, "end": { - "line": 0, - "column": null + "line": 15, + "column": 11 } } } diff --git a/tests/fixtures/parser/ast/svelte5/snippet01-hoist-input.svelte b/tests/fixtures/parser/ast/svelte5/snippet01-hoist-input.svelte new file mode 100644 index 00000000..05a82082 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/snippet01-hoist-input.svelte @@ -0,0 +1,9 @@ + + +{#snippet foo()} +

Hello World!

+{/snippet} + +{@render bar()} diff --git a/tests/fixtures/parser/ast/svelte5/snippet01-hoist-output.json b/tests/fixtures/parser/ast/svelte5/snippet01-hoist-output.json new file mode 100644 index 00000000..9fea670f --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/snippet01-hoist-output.json @@ -0,0 +1,1091 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteScriptElement", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + "body": [ + { + "type": "VariableDeclaration", + "kind": "const", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "Identifier", + "name": "foo", + "range": [ + 22, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "range": [ + 16, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 16 + } + } + } + ], + "range": [ + 10, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 27, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "range": [ + 0, + 36 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 36, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "params": [], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 56, + 59 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "Hello World!", + "range": [ + 59, + 71 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 71, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 20 + } + } + }, + "range": [ + 56, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 20 + } + } + } + ], + "range": [ + 38, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "bar", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "optional": false, + "range": [ + 97, + 102 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + "range": [ + 88, + 103 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 15 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "const", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 22, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 36, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "#snippet", + "range": [ + 39, + 47 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "p", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + { + "type": "HTMLText", + "value": "Hello", + "range": [ + 59, + 64 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + { + "type": "HTMLText", + "value": "World!", + "range": [ + 65, + 71 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 72, + 73 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 18 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "p", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "/snippet", + "range": [ + 77, + 85 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 86, + 88 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "@render", + "range": [ + 89, + 96 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 9, + "column": 13 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + } + } + } + ], + "range": [ + 0, + 104 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/snippet01-hoist-scope-output.json b/tests/fixtures/parser/ast/svelte5/snippet01-hoist-scope-output.json new file mode 100644 index 00000000..b061912d --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/snippet01-hoist-scope-output.json @@ -0,0 +1,600 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$inspect", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "bar", + "identifiers": [ + { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "Identifier", + "name": "foo", + "range": [ + 22, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "range": [ + 16, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 16 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ] + }, + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "node": { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "params": [], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 56, + 59 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "Hello World!", + "range": [ + 59, + 71 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 71, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 20 + } + } + }, + "range": [ + 56, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 20 + } + } + } + ], + "range": [ + 38, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "range": [ + 22, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "range": [ + 22, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "foo", + "range": [ + 48, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 97, + 100 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 16, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/ts-snippet01-scope-output.json b/tests/fixtures/parser/ast/svelte5/ts-snippet01-scope-output.json index f7cacb4d..009c609d 100644 --- a/tests/fixtures/parser/ast/svelte5/ts-snippet01-scope-output.json +++ b/tests/fixtures/parser/ast/svelte5/ts-snippet01-scope-output.json @@ -281,61 +281,203 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 57, + 60 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "msg", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSStringKeyword", + "range": [ + 66, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 25 + } + } + }, "range": [ - 7, - 13 + 64, + 72 ], "loc": { "start": { - "line": 1, - "column": 7 + "line": 5, + "column": 17 }, "end": { - "line": 1, - "column": 13 + "line": 5, + "column": 25 } } + }, + "range": [ + 61, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 25 + } } - ], - "range": [ - 73, - 81 - ], - "loc": { - "start": { - "line": 5, - "column": 26 + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } }, - "end": { - "line": 6, - "column": 6 + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 76, + 79 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "msg", + "range": [ + 80, + 83 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 8 + } + } + }, + "range": [ + 79, + 84 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 84, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "range": [ + 76, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 13 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 48, - 81 + 47, + 99 ], "loc": { "start": { "line": 5, - "column": 1 + "column": 0 }, "end": { - "line": 6, - "column": 6 + "line": 7, + "column": 10 } } } @@ -629,61 +771,203 @@ } }, "node": { - "type": "FunctionDeclaration", - "async": false, - "body": { - "type": "BlockStatement", - "body": [ - { - "type": "ExpressionStatement", - "expression": null, + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 57, + 60 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "msg", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "typeAnnotation": { + "type": "TSStringKeyword", + "range": [ + 66, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 25 + } + } + }, "range": [ - 7, - 13 + 64, + 72 ], "loc": { "start": { - "line": 1, - "column": 7 + "line": 5, + "column": 17 }, "end": { - "line": 1, - "column": 13 + "line": 5, + "column": 25 } } + }, + "range": [ + 61, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 25 + } } - ], - "range": [ - 73, - 81 - ], - "loc": { - "start": { - "line": 5, - "column": 26 + } + ], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } }, - "end": { - "line": 6, - "column": 6 + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 76, + 79 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + "children": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "msg", + "range": [ + 80, + 83 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 8 + } + } + }, + "range": [ + 79, + 84 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 84, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "range": [ + 76, + 88 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 13 + } } } - }, - "expression": false, - "generator": false, - "id": null, - "params": [], + ], "range": [ - 48, - 81 + 47, + 99 ], "loc": { "start": { "line": 5, - "column": 1 + "column": 0 }, "end": { - "line": 6, - "column": 6 + "line": 7, + "column": 10 } } } diff --git a/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-input.svelte b/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-input.svelte new file mode 100644 index 00000000..45672af7 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-input.svelte @@ -0,0 +1,9 @@ + + +{#snippet foo()} +

Hello World!

+{/snippet} + +{@render bar()} diff --git a/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-output.json b/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-output.json new file mode 100644 index 00000000..3501feb7 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-output.json @@ -0,0 +1,1238 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteScriptElement", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "lang", + "range": [ + 8, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "ts", + "range": [ + 14, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + ], + "range": [ + 8, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 17 + } + } + } + ], + "selfClosing": false, + "range": [ + 0, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + "body": [ + { + "type": "VariableDeclaration", + "kind": "const", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "Identifier", + "name": "foo", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "range": [ + 26, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 16 + } + } + } + ], + "range": [ + 20, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 37, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "range": [ + 0, + 46 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 46, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "params": [], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 66, + 69 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "Hello World!", + "range": [ + 69, + 81 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 81, + 85 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 20 + } + } + }, + "range": [ + 66, + 85 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 20 + } + } + } + ], + "range": [ + 48, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 96, + 98 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "SvelteRenderTag", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "bar", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "optional": false, + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + "range": [ + 98, + 113 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 15 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "lang", + "range": [ + 8, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 12, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 13, + 14 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + } + }, + { + "type": "HTMLText", + "value": "ts", + "range": [ + 14, + 16 + ], + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + } + }, + { + "type": "Keyword", + "value": "const", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 39, + 45 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 46, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "#snippet", + "range": [ + 49, + 57 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "foo", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "p", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + { + "type": "HTMLText", + "value": "Hello", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + { + "type": "HTMLText", + "value": "World!", + "range": [ + 75, + 81 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 82, + 83 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 18 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "p", + "range": [ + 83, + 84 + ], + "loc": { + "start": { + "line": 6, + "column": 18 + }, + "end": { + "line": 6, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 84, + 85 + ], + "loc": { + "start": { + "line": 6, + "column": 19 + }, + "end": { + "line": 6, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 86, + 87 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "/snippet", + "range": [ + 87, + 95 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 95, + 96 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 7, + "column": 10 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 96, + 98 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "@render", + "range": [ + 99, + 106 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 8 + } + } + }, + { + "type": "Identifier", + "value": "bar", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 110, + 111 + ], + "loc": { + "start": { + "line": 9, + "column": 12 + }, + "end": { + "line": 9, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 9, + "column": 13 + }, + "end": { + "line": 9, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 9, + "column": 14 + }, + "end": { + "line": 9, + "column": 15 + } + } + } + ], + "range": [ + 0, + 114 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-scope-output.json b/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-scope-output.json new file mode 100644 index 00000000..c65bbf43 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/ts-snippet02-hoist-scope-output.json @@ -0,0 +1,600 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$inspect", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "bar", + "identifiers": [ + { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "Identifier", + "name": "foo", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "range": [ + 26, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 16 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ] + }, + { + "name": "foo", + "identifiers": [ + { + "type": "Identifier", + "name": "foo", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "foo", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "node": { + "type": "SvelteSnippetBlock", + "id": { + "type": "Identifier", + "name": "foo", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "params": [], + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "p", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 66, + 69 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "Hello World!", + "range": [ + 69, + 81 + ], + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 16 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 81, + 85 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 20 + } + } + }, + "range": [ + 66, + 85 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 20 + } + } + } + ], + "range": [ + 48, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 10 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "foo", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "foo", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "foo", + "range": [ + 32, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "foo", + "range": [ + 58, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "bar", + "range": [ + 107, + 110 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 12 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "bar", + "range": [ + 26, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/src/parser/typescript/index.ts b/tests/src/parser/typescript/index.ts index ddaaef64..053c4200 100644 --- a/tests/src/parser/typescript/index.ts +++ b/tests/src/parser/typescript/index.ts @@ -52,12 +52,12 @@ describe("Check for typescript analyze result.", () => { }, ); const result = parseScriptInSvelte( - code.script + code.render + code.generics, + code.script + code.render + code.rootScope, attrs, parserOptions, ); const info = { - code: code.script + code.render + code.generics, + code: code.script + code.render + code.rootScope, virtualScriptCode: analyzedResult._virtualScriptCode, };