diff --git a/src/context/index.ts b/src/context/index.ts index cb48f1c9..6f740654 100644 --- a/src/context/index.ts +++ b/src/context/index.ts @@ -7,11 +7,13 @@ import { LetDirectiveCollections } from "./let-directive-collection" import { getParserName } from "../parser/resolve-parser" export class ScriptsSourceCode { - private readonly raw + private raw: string + + private trimmedRaw: string public readonly attrs: Record - private _vcode: string | null = null + private _appendScriptLets: string | null = null public separateSemiIndex: number @@ -20,32 +22,44 @@ export class ScriptsSourceCode { attrs: Record, ) { this.raw = script + this.trimmedRaw = script.trimEnd() this.attrs = attrs this.separateSemiIndex = script.length } public get vcode(): string { - if (this._vcode == null) { + if (this._appendScriptLets == null) { return this.raw } - return this._vcode + return this.trimmedRaw + this._appendScriptLets } public addLet(letCode: string): { start: number; end: number } { - if (this._vcode == null) { - this._vcode = this.raw.trimEnd() - this.separateSemiIndex = this._vcode.length - this._vcode += ";" - const after = this.raw.slice(this._vcode.length) - this._vcode += after + if (this._appendScriptLets == null) { + this._appendScriptLets = "" + this.separateSemiIndex = this.vcode.length + this._appendScriptLets += ";" + const after = this.raw.slice(this.vcode.length) + this._appendScriptLets += after } - const start = this._vcode.length - this._vcode += letCode + const start = this.vcode.length + this._appendScriptLets += letCode return { start, - end: this._vcode.length, + end: this.vcode.length, } } + + public stripCode(start: number, end: number): void { + this.raw = + this.raw.slice(0, start) + + this.raw.slice(start, end).replace(/[^\n\r ]/g, " ") + + this.raw.slice(end) + this.trimmedRaw = + this.trimmedRaw.slice(0, start) + + this.trimmedRaw.slice(start, end).replace(/[^\n\r ]/g, " ") + + this.trimmedRaw.slice(end) + } } export type ContextSourceCode = { template: string @@ -202,6 +216,10 @@ export class Context { return (this.state.isTypeScript = false) } + + public stripScriptCode(start: number, end: number): void { + this.sourceCode.scripts.stripCode(start, end) + } } /** Extract + diff --git a/tests/fixtures/parser/ast/nesting-script-tag01-output.json b/tests/fixtures/parser/ast/nesting-script-tag01-output.json new file mode 100644 index 00000000..e3c070a1 --- /dev/null +++ b/tests/fixtures/parser/ast/nesting-script-tag01-output.json @@ -0,0 +1,603 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "div", + "range": [ + 1, + 4 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 0, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 5, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 2, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 8, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 7, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\tlet a;\n\t", + "range": [ + 15, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 4, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 26, + 35 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + "range": [ + 7, + 35 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 36, + 42 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + "range": [ + 0, + 42 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 6 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "div", + "range": [ + 1, + 4 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 4, + 5 + ], + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 5, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 2, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 8, + 14 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t\t", + "range": [ + 15, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "HTMLText", + "value": "let", + "range": [ + 18, + 21 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 21, + 22 + ], + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + } + } + }, + { + "type": "HTMLText", + "value": "a;", + "range": [ + 22, + 24 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 27, + 28 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 3 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 28, + 34 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 36, + 37 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "div", + "range": [ + 38, + 41 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + } + } + ], + "range": [ + 0, + 43 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/nesting-script-tag01-scope-output.json b/tests/fixtures/parser/ast/nesting-script-tag01-scope-output.json new file mode 100644 index 00000000..d392ca4b --- /dev/null +++ b/tests/fixtures/parser/ast/nesting-script-tag01-scope-output.json @@ -0,0 +1,34 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/style01-input.svelte b/tests/fixtures/parser/ast/style01-input.svelte new file mode 100644 index 00000000..c8c806f7 --- /dev/null +++ b/tests/fixtures/parser/ast/style01-input.svelte @@ -0,0 +1,6 @@ + +
diff --git a/tests/fixtures/parser/ast/style01-output.json b/tests/fixtures/parser/ast/style01-output.json new file mode 100644 index 00000000..df50350d --- /dev/null +++ b/tests/fixtures/parser/ast/style01-output.json @@ -0,0 +1,423 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteStyleElement", + "name": { + "type": "SvelteName", + "name": "style", + "range": [ + 1, + 6 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 0, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\ndiv {\n color: red;\n}\n", + "range": [ + 7, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 5, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 30, + 38 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 8 + } + } + }, + "range": [ + 0, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 8 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 6, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "div", + "range": [ + 40, + 43 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": true, + "range": [ + 39, + 46 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 7 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 39, + 46 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 7 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "style", + "range": [ + 1, + 6 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 6, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "HTMLText", + "value": "\ndiv {\n color: red;\n}\n", + "range": [ + 7, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "style", + "range": [ + 32, + 37 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 37, + 38 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 6, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 39, + 40 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "div", + "range": [ + 40, + 43 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 6, + "column": 5 + }, + "end": { + "line": 6, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 7 + } + } + } + ], + "range": [ + 0, + 47 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/style01-scope-output.json b/tests/fixtures/parser/ast/style01-scope-output.json new file mode 100644 index 00000000..d392ca4b --- /dev/null +++ b/tests/fixtures/parser/ast/style01-scope-output.json @@ -0,0 +1,34 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/style02-input.svelte b/tests/fixtures/parser/ast/style02-input.svelte new file mode 100644 index 00000000..38e1ef58 --- /dev/null +++ b/tests/fixtures/parser/ast/style02-input.svelte @@ -0,0 +1,5 @@ + +
diff --git a/tests/fixtures/parser/ast/style02-output.json b/tests/fixtures/parser/ast/style02-output.json new file mode 100644 index 00000000..4aa25712 --- /dev/null +++ b/tests/fixtures/parser/ast/style02-output.json @@ -0,0 +1,570 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteStyleElement", + "name": { + "type": "SvelteName", + "name": "style", + "range": [ + 1, + 6 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "lang", + "range": [ + 7, + 11 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "stylus", + "range": [ + 13, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 19 + } + } + } + ], + "range": [ + 7, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + ], + "selfClosing": false, + "range": [ + 0, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\ndiv\n color: red;\n", + "range": [ + 21, + 40 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 4, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 40, + 48 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + "range": [ + 0, + 48 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "div", + "range": [ + 50, + 53 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 4 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": true, + "range": [ + 49, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 49, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 7 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "style", + "range": [ + 1, + 6 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "lang", + "range": [ + 7, + 11 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 11, + 12 + ], + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 12, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + } + }, + { + "type": "HTMLText", + "value": "stylus", + "range": [ + 13, + 19 + ], + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + } + } + }, + { + "type": "HTMLText", + "value": "\ndiv\n color: red;\n", + "range": [ + 21, + 40 + ], + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 4, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 40, + 41 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "style", + "range": [ + 42, + 47 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 49, + 50 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "div", + "range": [ + 50, + 53 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + } + ], + "range": [ + 0, + 57 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/style02-scope-output.json b/tests/fixtures/parser/ast/style02-scope-output.json new file mode 100644 index 00000000..d392ca4b --- /dev/null +++ b/tests/fixtures/parser/ast/style02-scope-output.json @@ -0,0 +1,34 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] +} \ No newline at end of file