From 6304d0bc4dd8b1cfe6351092dc10448c5d2438e0 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Sun, 21 Sep 2025 15:51:13 -0400 Subject: [PATCH 01/49] wip --- .changeset/floppy-coins-cry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/floppy-coins-cry.md diff --git a/.changeset/floppy-coins-cry.md b/.changeset/floppy-coins-cry.md new file mode 100644 index 00000000..763a763d --- /dev/null +++ b/.changeset/floppy-coins-cry.md @@ -0,0 +1,5 @@ +--- +'@ryanatkn/fuz_code': minor +--- + +improve token styles From cb597fe56cbaeca5ffdc812fb7a22ae5437bc269 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 22 Sep 2025 04:40:20 -0400 Subject: [PATCH 02/49] wip --- src/lib/highlight_manager.ts | 146 ++++++++++++++++------------------- 1 file changed, 68 insertions(+), 78 deletions(-) diff --git a/src/lib/highlight_manager.ts b/src/lib/highlight_manager.ts index 17fb1bb8..6cc092f2 100644 --- a/src/lib/highlight_manager.ts +++ b/src/lib/highlight_manager.ts @@ -23,74 +23,7 @@ export class Highlight_Manager { } /** - * Create ranges for all tokens in the tree - */ - #create_all_ranges( - tokens: Syntax_Token_Stream, - text_node: Node, - ranges_by_type: Map>, - offset: number, - ): number { - let pos = offset; - - for (const token of tokens) { - if (typeof token === 'string') { - // Plain text, just advance position - pos += token.length; - continue; - } - - const start = pos; - const length = this.#get_token_length(token); - const end = start + length; - - // Create range for EVERY token - no complex logic - try { - const range = new Range(); - range.setStart(text_node, start); - range.setEnd(text_node, end); - - const type = token.type; - if (!ranges_by_type.has(type)) { - ranges_by_type.set(type, []); - } - ranges_by_type.get(type)!.push(range); - } catch (e) { - throw new Error(`Failed to create range for ${token.type}: ${e}`); - } - - // Process nested tokens - if (Array.isArray(token.content)) { - this.#create_all_ranges(token.content, text_node, ranges_by_type, start); - } - - pos = end; - } - - return pos; - } - - /** - * Calculate the total text length of a token - */ - #get_token_length(token: Syntax_Token): number { - if (typeof token.content === 'string') { - return token.content.length; - } - - let length = 0; - for (const item of token.content) { - if (typeof item === 'string') { - length += item.length; - } else { - length += this.#get_token_length(item); - } - } - return length; - } - - /** - * Highlight from syntax styler token stream + * Highlight from syntax styler token stream. */ highlight_from_syntax_tokens(element: Element, tokens: Syntax_Token_Stream): void { // Find the text node (it might not be firstChild due to Svelte comment nodes) @@ -106,10 +39,8 @@ export class Highlight_Manager { throw new Error('no text node to highlight'); } - // Clear existing highlights this.clear_element_ranges(); - // Create ranges for all tokens - simple direct traversal const ranges_by_type: Map> = new Map(); this.#create_all_ranges(tokens, text_node, ranges_by_type, 0); @@ -121,7 +52,7 @@ export class Highlight_Manager { // Get or create the shared highlight let highlight = CSS.highlights.get(type); if (!highlight) { - highlight = new globalThis.Highlight(); + highlight = new Highlight(); CSS.highlights.set(type, highlight); } @@ -133,7 +64,7 @@ export class Highlight_Manager { } /** - * Clear only this element's ranges from highlights + * Clear only this element's ranges from highlights. */ clear_element_ranges(): void { for (const [name, ranges] of this.element_ranges) { @@ -141,25 +72,84 @@ export class Highlight_Manager { if (!highlight) { throw new Error('Expected to find CSS highlight: ' + name); } - // Remove only this element's ranges + for (const range of ranges) { highlight.delete(range); } - // If highlight is now empty, remove it from registry if (highlight.size === 0) { CSS.highlights.delete(name); } } - // Clear our tracking this.element_ranges.clear(); } - /** - * Destroy this manager and clean up - */ destroy(): void { this.clear_element_ranges(); } + + /** + * Create ranges for all tokens in the tree. + */ + #create_all_ranges( + tokens: Syntax_Token_Stream, + text_node: Node, + ranges_by_type: Map>, + offset: number, + ): number { + let pos = offset; + + for (const token of tokens) { + if (typeof token === 'string') { + pos += token.length; + continue; + } + + const length = this.#get_token_length(token); + const end_pos = pos + length; + + try { + const range = new Range(); + range.setStart(text_node, pos); + range.setEnd(text_node, end_pos); + + const type = token.type; + if (!ranges_by_type.has(type)) { + ranges_by_type.set(type, []); + } + ranges_by_type.get(type)!.push(range); + } catch (e) { + throw new Error(`Failed to create range for ${token.type}: ${e}`); + } + + // Process nested tokens + if (Array.isArray(token.content)) { + this.#create_all_ranges(token.content, text_node, ranges_by_type, pos); + } + + pos = end_pos; + } + + return pos; + } + + /** + * Calculate the total text length of a token + */ + #get_token_length(token: Syntax_Token): number { + if (typeof token.content === 'string') { + return token.content.length; + } + + let length = 0; + for (const item of token.content) { + if (typeof item === 'string') { + length += item.length; + } else { + length += this.#get_token_length(item); + } + } + return length; + } } From 1a06cd0551132bf28af7bbfda7ee9735c1ea5f4d Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 22 Sep 2025 05:35:13 -0400 Subject: [PATCH 03/49] wip --- package-lock.json | 8 ++-- package.json | 2 +- src/lib/samples/all.ts | 10 ++-- src/lib/samples/sample_complex.ts | 10 ++-- src/lib/theme.css | 77 +++++++++++++++---------------- src/routes/package.ts | 2 +- 6 files changed, 54 insertions(+), 55 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0ff14cc8..07981225 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@ryanatkn/eslint-config": "^0.8.0", "@ryanatkn/fuz": "^0.146.0", "@ryanatkn/gro": "^0.165.1", - "@ryanatkn/moss": "^0.34.0", + "@ryanatkn/moss": "^0.34.1", "@sveltejs/adapter-static": "^3.0.9", "@sveltejs/kit": "^2.37.1", "@sveltejs/package": "^2.5.0", @@ -1529,9 +1529,9 @@ } }, "node_modules/@ryanatkn/moss": { - "version": "0.34.0", - "resolved": "https://registry.npmjs.org/@ryanatkn/moss/-/moss-0.34.0.tgz", - "integrity": "sha512-PtC+D8Hy8Oxwuovwfb33l1jGFfgj/MYP9pvRSr1hC4aPhdlFvB6GS97O0o8dEZx0EkQG5zk7oxshmpKn6l/w7Q==", + "version": "0.34.1", + "resolved": "https://registry.npmjs.org/@ryanatkn/moss/-/moss-0.34.1.tgz", + "integrity": "sha512-Jtx2m9YG2BOwBFvNxSWFdsCcebDXMHmSk/hJHFlIVrhQW1IQ2VO9qktLJMPdhFSJwLXfUkyaFoTxwtLeZo7oqQ==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 3210da02..49fa4127 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "@ryanatkn/eslint-config": "^0.8.0", "@ryanatkn/fuz": "^0.146.0", "@ryanatkn/gro": "^0.165.1", - "@ryanatkn/moss": "^0.34.0", + "@ryanatkn/moss": "^0.34.1", "@sveltejs/adapter-static": "^3.0.9", "@sveltejs/kit": "^2.37.1", "@sveltejs/package": "^2.5.0", diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index cf83fd57..f55c0d74 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -97,7 +97,7 @@ export type Some_Type = 1 | 'b' | true; class D { d1: string = 'd'; d2: number; - d3 = $state(false); + d3 = $state(null); constructor(d2: number) { this.d2 = d2; @@ -109,14 +109,16 @@ class D { instance_method = (): void => { /* ... */ - this.#private_method(); + for (const c2 of this.d1) { + this.#private_method(a, c2); + } // foo }; - #private_method() { + #private_method(a2: number, c2: any) { throw new Error(\`\${this.d1} multiline - etc + etc \${a2 + c2} \`); } diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index a8175af3..e5f85053 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -9,7 +9,7 @@ export type Some_Type = 1 | 'b' | true; class D { d1: string = 'd'; d2: number; - d3 = $state(false); + d3 = $state(null); constructor(d2: number) { this.d2 = d2; @@ -21,14 +21,16 @@ class D { instance_method = (): void => { /* ... */ - this.#private_method(); + for (const c2 of this.d1) { + this.#private_method(a, c2); + } // foo }; - #private_method() { + #private_method(a2: number, c2: any) { throw new Error(`${this.d1} multiline - etc + etc ${a2 + c2} `); } diff --git a/src/lib/theme.css b/src/lib/theme.css index d39ee2e1..44e75325 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -1,4 +1,3 @@ -/* Comments, punctuation, and processing */ .token.comment, ::highlight(comment), .token.attr_equals, @@ -34,23 +33,23 @@ color: var(--color_a_5); } -/* Numbers */ -.token.number, -::highlight(number) { - color: var(--color_e_5); -} - -/* Booleans */ +/* TODO keywords like `throw`/`return`/`export` are color_g */ +.token.keyword, +::highlight(keyword), +.token.null, +::highlight(null), .token.boolean, -::highlight(boolean) { - color: var(--color_i_5); +::highlight(boolean), +.token.interpolation_punctuation, +::highlight(interpolation_punctuation) { + color: var(--color_a_5); } -/* Strings, selectors, and values */ +/* selectors, and values */ +.token.comment, +::highlight(comment), .token.selector, ::highlight(selector), -.token.string, -::highlight(string), .token.attr_value, ::highlight(attr_value), .token.char, @@ -62,26 +61,34 @@ color: var(--color_b_5); } -/* Keywords and at-rules */ +.token.builtin, +::highlight(builtin), +.token.class_name, +::highlight(class_name), +.token.number, +::highlight(number) { + color: var(--color_j_5); +} + +.token.string, +::highlight(string), +.token.template_punctuation, +::highlight(template_punctuation) { + color: var(--color_h_5); +} + +.token.function, +::highlight(function) { + color: var(--color_e_5); +} + .token.atrule, ::highlight(atrule), .token.attr_name, -::highlight(attr_name), -.token.keyword, -::highlight(keyword), -.token.null, -::highlight(null) { +::highlight(attr_name) { color: var(--color_f_5); } -/* Functions and classes */ -.token.function, -::highlight(function), -.token.class_name, -::highlight(class_name) { - color: var(--color_d_5); -} - /* Regular expressions and variables */ .token.regex, ::highlight(regex), @@ -109,16 +116,7 @@ /* TODO some of these should probably be used, others are unnecessary */ /* TypeScript/JS specific */ -/* .token.template_string, -::highlight(template_string) { - color: var(--color_b_5); -} - -.token.template_punctuation, -::highlight(template_punctuation) { - color: var(--color_a_5); -} - +/* .token.parameter, ::highlight(parameter) { color: var(--color_a_5); @@ -186,10 +184,7 @@ } */ /* Additional tokens */ -/* .token.interpolation_punctuation, -::highlight(interpolation_punctuation) { - color: var(--color_a_5); -} +/* .token.at, ::highlight(at) { diff --git a/src/routes/package.ts b/src/routes/package.ts index 879eb263..96c95c26 100644 --- a/src/routes/package.ts +++ b/src/routes/package.ts @@ -39,7 +39,7 @@ export const package_json: Package_Json = { '@ryanatkn/eslint-config': '^0.8.0', '@ryanatkn/fuz': '^0.146.0', '@ryanatkn/gro': '^0.165.1', - '@ryanatkn/moss': '^0.34.0', + '@ryanatkn/moss': '^0.34.1', '@sveltejs/adapter-static': '^3.0.9', '@sveltejs/kit': '^2.37.1', '@sveltejs/package': '^2.5.0', From 86a6817ec98dd96ba80fd957aba5f4052c31d476 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 22 Sep 2025 05:38:13 -0400 Subject: [PATCH 04/49] wip --- src/lib/samples/sample_complex.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index e5f85053..05fc93c1 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -39,8 +39,6 @@ class D { } } -export {a, b, c, D}; - // comment /* @@ -53,6 +51,13 @@ const comment = false; * JSDoc comment */ +// @ts-expect-error +import {B, C, d} from 'foo'; +// @ts-expect-error +import * as A from 'foo2'; + +export {a, A, b, B, c, C, D}; + export interface Some_E { name: string; age: number; From 3d5f80b96493fd089be28a8f46b21131ecd12f4a Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 22 Sep 2025 05:38:25 -0400 Subject: [PATCH 05/49] wip --- src/lib/samples/all.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index f55c0d74..614d0029 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -127,8 +127,6 @@ class D { } } -export {a, b, c, D}; - // comment /* @@ -141,6 +139,13 @@ const comment = false; * JSDoc comment */ +// @ts-expect-error +import {B, C, d} from 'foo'; +// @ts-expect-error +import * as A from 'foo2'; + +export {a, A, b, B, c, C, D}; + export interface Some_E { name: string; age: number; From 9d49b1320a37c31af536b663b1d5d2ae46292237 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Mon, 22 Sep 2025 05:47:30 -0400 Subject: [PATCH 06/49] wip --- fixtures/generated/ts/ts_complex.json | 432 +++++++++++++----------- fixtures/generated/ts/ts_complex.txt | 466 ++++++++++++++------------ src/lib/samples/all.ts | 10 +- src/lib/samples/sample_complex.ts | 10 +- 4 files changed, 507 insertions(+), 411 deletions(-) diff --git a/fixtures/generated/ts/ts_complex.json b/fixtures/generated/ts/ts_complex.json index e3b567ab..854b6cc3 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/fixtures/generated/ts/ts_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "ts", "variant": "complex", - "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(false);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tthis.#private_method();\n\t\t// foo\n\t};\n\n\t#private_method() {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc\n\t\t`);\n\t}\n\n\tprotected protected_method(): void {\n\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t}\n}\n\nexport {a, b, c, D};\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", + "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tfor (const c2 of this.d1) {\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected protected_method(): void {\n\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", "filepath": "src/lib/samples/sample_complex.ts" }, "tokens": [ @@ -43,206 +43,254 @@ {"type": "operator", "start": 134, "end": 135}, {"type": "function", "start": 136, "end": 142}, {"type": "punctuation", "start": 142, "end": 143}, - {"type": "boolean", "start": 143, "end": 148}, + {"type": "keyword", "start": 143, "end": 147}, + {"type": "punctuation", "start": 147, "end": 148}, {"type": "punctuation", "start": 148, "end": 149}, - {"type": "punctuation", "start": 149, "end": 150}, - {"type": "function", "start": 153, "end": 164}, - {"type": "punctuation", "start": 164, "end": 165}, - {"type": "operator", "start": 167, "end": 168}, - {"type": "builtin", "start": 169, "end": 175}, - {"type": "punctuation", "start": 175, "end": 176}, - {"type": "punctuation", "start": 177, "end": 178}, - {"type": "keyword", "start": 181, "end": 185}, - {"type": "punctuation", "start": 185, "end": 186}, - {"type": "operator", "start": 189, "end": 190}, - {"type": "punctuation", "start": 193, "end": 194}, - {"type": "punctuation", "start": 196, "end": 197}, - {"type": "function", "start": 200, "end": 212}, + {"type": "function", "start": 152, "end": 163}, + {"type": "punctuation", "start": 163, "end": 164}, + {"type": "operator", "start": 166, "end": 167}, + {"type": "builtin", "start": 168, "end": 174}, + {"type": "punctuation", "start": 174, "end": 175}, + {"type": "punctuation", "start": 176, "end": 177}, + {"type": "keyword", "start": 180, "end": 184}, + {"type": "punctuation", "start": 184, "end": 185}, + {"type": "operator", "start": 188, "end": 189}, + {"type": "punctuation", "start": 192, "end": 193}, + {"type": "punctuation", "start": 195, "end": 196}, + {"type": "function", "start": 199, "end": 211}, + {"type": "punctuation", "start": 211, "end": 212}, {"type": "punctuation", "start": 212, "end": 213}, - {"type": "punctuation", "start": 213, "end": 214}, - {"type": "operator", "start": 214, "end": 215}, - {"type": "builtin", "start": 216, "end": 222}, - {"type": "punctuation", "start": 223, "end": 224}, - {"type": "keyword", "start": 227, "end": 233}, - {"type": "template_string", "start": 234, "end": 253}, - {"type": "template_punctuation", "start": 234, "end": 235}, - {"type": "string", "start": 235, "end": 242}, - {"type": "interpolation", "start": 242, "end": 252}, - {"type": "interpolation_punctuation", "start": 242, "end": 244}, - {"type": "keyword", "start": 244, "end": 248}, - {"type": "punctuation", "start": 248, "end": 249}, - {"type": "interpolation_punctuation", "start": 251, "end": 252}, - {"type": "template_punctuation", "start": 252, "end": 253}, - {"type": "punctuation", "start": 253, "end": 254}, - {"type": "punctuation", "start": 256, "end": 257}, - {"type": "operator", "start": 276, "end": 277}, + {"type": "operator", "start": 213, "end": 214}, + {"type": "builtin", "start": 215, "end": 221}, + {"type": "punctuation", "start": 222, "end": 223}, + {"type": "keyword", "start": 226, "end": 232}, + {"type": "template_string", "start": 233, "end": 252}, + {"type": "template_punctuation", "start": 233, "end": 234}, + {"type": "string", "start": 234, "end": 241}, + {"type": "interpolation", "start": 241, "end": 251}, + {"type": "interpolation_punctuation", "start": 241, "end": 243}, + {"type": "keyword", "start": 243, "end": 247}, + {"type": "punctuation", "start": 247, "end": 248}, + {"type": "interpolation_punctuation", "start": 250, "end": 251}, + {"type": "template_punctuation", "start": 251, "end": 252}, + {"type": "punctuation", "start": 252, "end": 253}, + {"type": "punctuation", "start": 255, "end": 256}, + {"type": "operator", "start": 275, "end": 276}, + {"type": "punctuation", "start": 277, "end": 278}, {"type": "punctuation", "start": 278, "end": 279}, - {"type": "punctuation", "start": 279, "end": 280}, - {"type": "operator", "start": 280, "end": 281}, - {"type": "keyword", "start": 282, "end": 286}, - {"type": "operator", "start": 287, "end": 289}, - {"type": "punctuation", "start": 290, "end": 291}, - {"type": "comment", "start": 294, "end": 303}, - {"type": "keyword", "start": 306, "end": 310}, - {"type": "punctuation", "start": 310, "end": 311}, - {"type": "function", "start": 311, "end": 326}, + {"type": "operator", "start": 279, "end": 280}, + {"type": "keyword", "start": 281, "end": 285}, + {"type": "operator", "start": 286, "end": 288}, + {"type": "punctuation", "start": 289, "end": 290}, + {"type": "comment", "start": 293, "end": 302}, + {"type": "keyword", "start": 305, "end": 308}, + {"type": "punctuation", "start": 309, "end": 310}, + {"type": "keyword", "start": 310, "end": 315}, + {"type": "keyword", "start": 319, "end": 321}, + {"type": "keyword", "start": 322, "end": 326}, {"type": "punctuation", "start": 326, "end": 327}, - {"type": "punctuation", "start": 327, "end": 328}, - {"type": "punctuation", "start": 328, "end": 329}, - {"type": "comment", "start": 332, "end": 338}, + {"type": "punctuation", "start": 329, "end": 330}, + {"type": "punctuation", "start": 331, "end": 332}, + {"type": "keyword", "start": 336, "end": 340}, {"type": "punctuation", "start": 340, "end": 341}, - {"type": "punctuation", "start": 341, "end": 342}, - {"type": "function", "start": 345, "end": 360}, - {"type": "punctuation", "start": 360, "end": 361}, - {"type": "punctuation", "start": 361, "end": 362}, + {"type": "function", "start": 341, "end": 356}, + {"type": "punctuation", "start": 356, "end": 357}, + {"type": "punctuation", "start": 358, "end": 359}, + {"type": "punctuation", "start": 362, "end": 363}, {"type": "punctuation", "start": 363, "end": 364}, - {"type": "keyword", "start": 367, "end": 372}, - {"type": "keyword", "start": 373, "end": 376}, - {"type": "class_name", "start": 377, "end": 382}, - {"type": "punctuation", "start": 382, "end": 383}, - {"type": "template_string", "start": 383, "end": 419}, - {"type": "template_punctuation", "start": 383, "end": 384}, - {"type": "interpolation", "start": 384, "end": 394}, - {"type": "interpolation_punctuation", "start": 384, "end": 386}, - {"type": "keyword", "start": 386, "end": 390}, - {"type": "punctuation", "start": 390, "end": 391}, - {"type": "interpolation_punctuation", "start": 393, "end": 394}, - {"type": "string", "start": 394, "end": 418}, - {"type": "template_punctuation", "start": 418, "end": 419}, + {"type": "punctuation", "start": 367, "end": 368}, + {"type": "comment", "start": 371, "end": 377}, + {"type": "punctuation", "start": 379, "end": 380}, + {"type": "punctuation", "start": 380, "end": 381}, + {"type": "function", "start": 384, "end": 399}, + {"type": "punctuation", "start": 399, "end": 400}, + {"type": "operator", "start": 402, "end": 403}, + {"type": "builtin", "start": 404, "end": 410}, + {"type": "punctuation", "start": 410, "end": 411}, + {"type": "operator", "start": 414, "end": 415}, + {"type": "builtin", "start": 416, "end": 419}, {"type": "punctuation", "start": 419, "end": 420}, - {"type": "punctuation", "start": 420, "end": 421}, - {"type": "punctuation", "start": 423, "end": 424}, - {"type": "keyword", "start": 427, "end": 436}, - {"type": "function", "start": 437, "end": 453}, - {"type": "punctuation", "start": 453, "end": 454}, - {"type": "punctuation", "start": 454, "end": 455}, - {"type": "operator", "start": 455, "end": 456}, - {"type": "keyword", "start": 457, "end": 461}, - {"type": "punctuation", "start": 462, "end": 463}, - {"type": "builtin", "start": 466, "end": 473}, - {"type": "punctuation", "start": 473, "end": 474}, - {"type": "function", "start": 474, "end": 477}, - {"type": "punctuation", "start": 477, "end": 478}, - {"type": "keyword", "start": 478, "end": 481}, - {"type": "class_name", "start": 482, "end": 486}, - {"type": "punctuation", "start": 486, "end": 487}, - {"type": "punctuation", "start": 487, "end": 488}, + {"type": "punctuation", "start": 421, "end": 422}, + {"type": "keyword", "start": 425, "end": 430}, + {"type": "keyword", "start": 431, "end": 434}, + {"type": "class_name", "start": 435, "end": 440}, + {"type": "punctuation", "start": 440, "end": 441}, + {"type": "template_string", "start": 441, "end": 488}, + {"type": "template_punctuation", "start": 441, "end": 442}, + {"type": "interpolation", "start": 442, "end": 452}, + {"type": "interpolation_punctuation", "start": 442, "end": 444}, + {"type": "keyword", "start": 444, "end": 448}, + {"type": "punctuation", "start": 448, "end": 449}, + {"type": "interpolation_punctuation", "start": 451, "end": 452}, + {"type": "string", "start": 452, "end": 474}, + {"type": "interpolation", "start": 474, "end": 484}, + {"type": "interpolation_punctuation", "start": 474, "end": 476}, + {"type": "operator", "start": 479, "end": 480}, + {"type": "interpolation_punctuation", "start": 483, "end": 484}, + {"type": "string", "start": 484, "end": 487}, + {"type": "template_punctuation", "start": 487, "end": 488}, {"type": "punctuation", "start": 488, "end": 489}, {"type": "punctuation", "start": 489, "end": 490}, - {"type": "comment", "start": 491, "end": 524}, - {"type": "punctuation", "start": 526, "end": 527}, - {"type": "punctuation", "start": 528, "end": 529}, - {"type": "keyword", "start": 531, "end": 537}, - {"type": "punctuation", "start": 538, "end": 539}, - {"type": "punctuation", "start": 540, "end": 541}, - {"type": "punctuation", "start": 543, "end": 544}, + {"type": "punctuation", "start": 492, "end": 493}, + {"type": "keyword", "start": 496, "end": 505}, + {"type": "function", "start": 506, "end": 522}, + {"type": "punctuation", "start": 522, "end": 523}, + {"type": "punctuation", "start": 523, "end": 524}, + {"type": "operator", "start": 524, "end": 525}, + {"type": "keyword", "start": 526, "end": 530}, + {"type": "punctuation", "start": 531, "end": 532}, + {"type": "builtin", "start": 535, "end": 542}, + {"type": "punctuation", "start": 542, "end": 543}, + {"type": "function", "start": 543, "end": 546}, {"type": "punctuation", "start": 546, "end": 547}, - {"type": "constant", "start": 548, "end": 549}, - {"type": "punctuation", "start": 549, "end": 550}, - {"type": "punctuation", "start": 550, "end": 551}, - {"type": "comment", "start": 553, "end": 563}, - {"type": "comment", "start": 565, "end": 608}, - {"type": "comment", "start": 610, "end": 634}, - {"type": "keyword", "start": 636, "end": 642}, - {"type": "keyword", "start": 643, "end": 652}, - {"type": "class_name", "start": 653, "end": 659}, - {"type": "punctuation", "start": 660, "end": 661}, - {"type": "operator", "start": 667, "end": 668}, - {"type": "builtin", "start": 669, "end": 675}, - {"type": "punctuation", "start": 675, "end": 676}, - {"type": "operator", "start": 681, "end": 682}, - {"type": "builtin", "start": 683, "end": 689}, - {"type": "punctuation", "start": 689, "end": 690}, - {"type": "punctuation", "start": 691, "end": 692}, - {"type": "keyword", "start": 694, "end": 700}, - {"type": "keyword", "start": 701, "end": 706}, - {"type": "operator", "start": 713, "end": 714}, - {"type": "operator", "start": 722, "end": 723}, - {"type": "punctuation", "start": 724, "end": 725}, - {"type": "operator", "start": 729, "end": 730}, - {"type": "string", "start": 731, "end": 738}, - {"type": "punctuation", "start": 738, "end": 739}, - {"type": "operator", "start": 743, "end": 744}, - {"type": "number", "start": 745, "end": 748}, - {"type": "punctuation", "start": 748, "end": 749}, - {"type": "punctuation", "start": 749, "end": 750}, - {"type": "keyword", "start": 752, "end": 758}, - {"type": "keyword", "start": 759, "end": 767}, - {"type": "function", "start": 768, "end": 771}, - {"type": "punctuation", "start": 771, "end": 772}, - {"type": "operator", "start": 773, "end": 774}, - {"type": "builtin", "start": 775, "end": 781}, - {"type": "punctuation", "start": 781, "end": 782}, - {"type": "operator", "start": 784, "end": 785}, - {"type": "builtin", "start": 786, "end": 792}, - {"type": "punctuation", "start": 792, "end": 793}, - {"type": "operator", "start": 793, "end": 794}, - {"type": "builtin", "start": 795, "end": 801}, - {"type": "punctuation", "start": 802, "end": 803}, - {"type": "keyword", "start": 805, "end": 811}, - {"type": "operator", "start": 814, "end": 815}, - {"type": "punctuation", "start": 817, "end": 818}, - {"type": "punctuation", "start": 819, "end": 820}, - {"type": "keyword", "start": 822, "end": 828}, - {"type": "keyword", "start": 829, "end": 834}, - {"type": "operator", "start": 840, "end": 841}, - {"type": "punctuation", "start": 842, "end": 843}, - {"type": "operator", "start": 844, "end": 845}, - {"type": "builtin", "start": 846, "end": 849}, - {"type": "punctuation", "start": 849, "end": 850}, - {"type": "operator", "start": 852, "end": 853}, - {"type": "builtin", "start": 854, "end": 857}, - {"type": "punctuation", "start": 857, "end": 858}, - {"type": "operator", "start": 858, "end": 859}, - {"type": "builtin", "start": 860, "end": 863}, - {"type": "operator", "start": 864, "end": 866}, - {"type": "operator", "start": 869, "end": 870}, - {"type": "punctuation", "start": 872, "end": 873}, - {"type": "comment", "start": 875, "end": 897}, - {"type": "keyword", "start": 898, "end": 904}, - {"type": "keyword", "start": 905, "end": 910}, - {"type": "operator", "start": 929, "end": 930}, - {"type": "string", "start": 931, "end": 960}, - {"type": "punctuation", "start": 960, "end": 961}, - {"type": "keyword", "start": 962, "end": 968}, - {"type": "keyword", "start": 969, "end": 974}, - {"type": "operator", "start": 992, "end": 993}, - {"type": "string", "start": 994, "end": 1020}, - {"type": "punctuation", "start": 1020, "end": 1021}, - {"type": "keyword", "start": 1022, "end": 1028}, - {"type": "keyword", "start": 1029, "end": 1034}, - {"type": "operator", "start": 1054, "end": 1055}, - {"type": "template_string", "start": 1056, "end": 1073}, - {"type": "template_punctuation", "start": 1056, "end": 1057}, - {"type": "string", "start": 1057, "end": 1064}, - {"type": "interpolation", "start": 1064, "end": 1072}, - {"type": "interpolation_punctuation", "start": 1064, "end": 1066}, - {"type": "number", "start": 1066, "end": 1067}, - {"type": "operator", "start": 1068, "end": 1069}, - {"type": "number", "start": 1070, "end": 1071}, - {"type": "interpolation_punctuation", "start": 1071, "end": 1072}, - {"type": "template_punctuation", "start": 1072, "end": 1073}, - {"type": "punctuation", "start": 1073, "end": 1074}, - {"type": "comment", "start": 1076, "end": 1108}, - {"type": "keyword", "start": 1109, "end": 1115}, - {"type": "keyword", "start": 1116, "end": 1121}, - {"type": "operator", "start": 1128, "end": 1129}, - {"type": "regex", "start": 1130, "end": 1139}, - {"type": "regex_delimiter", "start": 1130, "end": 1131}, - {"type": "regex_source", "start": 1131, "end": 1137}, - {"type": "regex_delimiter", "start": 1137, "end": 1138}, - {"type": "regex_flags", "start": 1138, "end": 1139}, - {"type": "punctuation", "start": 1139, "end": 1140}, - {"type": "keyword", "start": 1141, "end": 1147}, - {"type": "keyword", "start": 1148, "end": 1153}, - {"type": "operator", "start": 1168, "end": 1169}, - {"type": "regex", "start": 1170, "end": 1202}, - {"type": "regex_delimiter", "start": 1170, "end": 1171}, - {"type": "regex_source", "start": 1171, "end": 1201}, - {"type": "regex_delimiter", "start": 1201, "end": 1202}, - {"type": "punctuation", "start": 1202, "end": 1203}, - {"type": "comment", "start": 1205, "end": 1261}, - {"type": "comment", "start": 1262, "end": 1313} + {"type": "keyword", "start": 547, "end": 550}, + {"type": "class_name", "start": 551, "end": 555}, + {"type": "punctuation", "start": 555, "end": 556}, + {"type": "punctuation", "start": 556, "end": 557}, + {"type": "punctuation", "start": 557, "end": 558}, + {"type": "punctuation", "start": 558, "end": 559}, + {"type": "comment", "start": 560, "end": 593}, + {"type": "punctuation", "start": 595, "end": 596}, + {"type": "punctuation", "start": 597, "end": 598}, + {"type": "comment", "start": 600, "end": 610}, + {"type": "comment", "start": 612, "end": 655}, + {"type": "comment", "start": 657, "end": 681}, + {"type": "keyword", "start": 683, "end": 689}, + {"type": "punctuation", "start": 690, "end": 691}, + {"type": "punctuation", "start": 703, "end": 704}, + {"type": "keyword", "start": 705, "end": 709}, + {"type": "class_name", "start": 710, "end": 721}, + {"type": "punctuation", "start": 721, "end": 722}, + {"type": "keyword", "start": 723, "end": 727}, + {"type": "class_name", "start": 728, "end": 739}, + {"type": "punctuation", "start": 739, "end": 740}, + {"type": "keyword", "start": 741, "end": 745}, + {"type": "string", "start": 746, "end": 765}, + {"type": "punctuation", "start": 765, "end": 766}, + {"type": "keyword", "start": 767, "end": 773}, + {"type": "operator", "start": 774, "end": 775}, + {"type": "keyword", "start": 776, "end": 778}, + {"type": "constant", "start": 779, "end": 780}, + {"type": "keyword", "start": 781, "end": 785}, + {"type": "string", "start": 786, "end": 805}, + {"type": "punctuation", "start": 805, "end": 806}, + {"type": "keyword", "start": 821, "end": 823}, + {"type": "builtin", "start": 824, "end": 831}, + {"type": "keyword", "start": 832, "end": 834}, + {"type": "keyword", "start": 847, "end": 849}, + {"type": "builtin", "start": 850, "end": 853}, + {"type": "keyword", "start": 854, "end": 856}, + {"type": "punctuation", "start": 868, "end": 869}, + {"type": "keyword", "start": 871, "end": 877}, + {"type": "punctuation", "start": 878, "end": 879}, + {"type": "punctuation", "start": 880, "end": 881}, + {"type": "constant", "start": 882, "end": 883}, + {"type": "punctuation", "start": 883, "end": 884}, + {"type": "punctuation", "start": 886, "end": 887}, + {"type": "punctuation", "start": 889, "end": 890}, + {"type": "constant", "start": 891, "end": 892}, + {"type": "punctuation", "start": 892, "end": 893}, + {"type": "punctuation", "start": 893, "end": 894}, + {"type": "keyword", "start": 896, "end": 902}, + {"type": "keyword", "start": 903, "end": 912}, + {"type": "class_name", "start": 913, "end": 919}, + {"type": "punctuation", "start": 920, "end": 921}, + {"type": "operator", "start": 927, "end": 928}, + {"type": "builtin", "start": 929, "end": 935}, + {"type": "punctuation", "start": 935, "end": 936}, + {"type": "operator", "start": 941, "end": 942}, + {"type": "builtin", "start": 943, "end": 949}, + {"type": "punctuation", "start": 949, "end": 950}, + {"type": "punctuation", "start": 951, "end": 952}, + {"type": "keyword", "start": 954, "end": 960}, + {"type": "keyword", "start": 961, "end": 966}, + {"type": "operator", "start": 973, "end": 974}, + {"type": "operator", "start": 982, "end": 983}, + {"type": "punctuation", "start": 984, "end": 985}, + {"type": "operator", "start": 989, "end": 990}, + {"type": "string", "start": 991, "end": 998}, + {"type": "punctuation", "start": 998, "end": 999}, + {"type": "operator", "start": 1003, "end": 1004}, + {"type": "number", "start": 1005, "end": 1008}, + {"type": "punctuation", "start": 1008, "end": 1009}, + {"type": "punctuation", "start": 1009, "end": 1010}, + {"type": "keyword", "start": 1012, "end": 1018}, + {"type": "keyword", "start": 1019, "end": 1027}, + {"type": "function", "start": 1028, "end": 1031}, + {"type": "punctuation", "start": 1031, "end": 1032}, + {"type": "operator", "start": 1033, "end": 1034}, + {"type": "builtin", "start": 1035, "end": 1041}, + {"type": "punctuation", "start": 1041, "end": 1042}, + {"type": "operator", "start": 1044, "end": 1045}, + {"type": "builtin", "start": 1046, "end": 1052}, + {"type": "punctuation", "start": 1052, "end": 1053}, + {"type": "operator", "start": 1053, "end": 1054}, + {"type": "builtin", "start": 1055, "end": 1061}, + {"type": "punctuation", "start": 1062, "end": 1063}, + {"type": "keyword", "start": 1065, "end": 1071}, + {"type": "operator", "start": 1074, "end": 1075}, + {"type": "punctuation", "start": 1077, "end": 1078}, + {"type": "punctuation", "start": 1079, "end": 1080}, + {"type": "keyword", "start": 1082, "end": 1088}, + {"type": "keyword", "start": 1089, "end": 1094}, + {"type": "operator", "start": 1100, "end": 1101}, + {"type": "punctuation", "start": 1102, "end": 1103}, + {"type": "operator", "start": 1104, "end": 1105}, + {"type": "builtin", "start": 1106, "end": 1109}, + {"type": "punctuation", "start": 1109, "end": 1110}, + {"type": "operator", "start": 1112, "end": 1113}, + {"type": "builtin", "start": 1114, "end": 1117}, + {"type": "punctuation", "start": 1117, "end": 1118}, + {"type": "operator", "start": 1118, "end": 1119}, + {"type": "builtin", "start": 1120, "end": 1123}, + {"type": "operator", "start": 1124, "end": 1126}, + {"type": "operator", "start": 1129, "end": 1130}, + {"type": "punctuation", "start": 1132, "end": 1133}, + {"type": "comment", "start": 1135, "end": 1157}, + {"type": "keyword", "start": 1158, "end": 1164}, + {"type": "keyword", "start": 1165, "end": 1170}, + {"type": "operator", "start": 1189, "end": 1190}, + {"type": "string", "start": 1191, "end": 1220}, + {"type": "punctuation", "start": 1220, "end": 1221}, + {"type": "keyword", "start": 1222, "end": 1228}, + {"type": "keyword", "start": 1229, "end": 1234}, + {"type": "operator", "start": 1252, "end": 1253}, + {"type": "string", "start": 1254, "end": 1280}, + {"type": "punctuation", "start": 1280, "end": 1281}, + {"type": "keyword", "start": 1282, "end": 1288}, + {"type": "keyword", "start": 1289, "end": 1294}, + {"type": "operator", "start": 1314, "end": 1315}, + {"type": "template_string", "start": 1316, "end": 1333}, + {"type": "template_punctuation", "start": 1316, "end": 1317}, + {"type": "string", "start": 1317, "end": 1324}, + {"type": "interpolation", "start": 1324, "end": 1332}, + {"type": "interpolation_punctuation", "start": 1324, "end": 1326}, + {"type": "number", "start": 1326, "end": 1327}, + {"type": "operator", "start": 1328, "end": 1329}, + {"type": "number", "start": 1330, "end": 1331}, + {"type": "interpolation_punctuation", "start": 1331, "end": 1332}, + {"type": "template_punctuation", "start": 1332, "end": 1333}, + {"type": "punctuation", "start": 1333, "end": 1334}, + {"type": "comment", "start": 1336, "end": 1368}, + {"type": "keyword", "start": 1369, "end": 1375}, + {"type": "keyword", "start": 1376, "end": 1381}, + {"type": "operator", "start": 1388, "end": 1389}, + {"type": "regex", "start": 1390, "end": 1399}, + {"type": "regex_delimiter", "start": 1390, "end": 1391}, + {"type": "regex_source", "start": 1391, "end": 1397}, + {"type": "regex_delimiter", "start": 1397, "end": 1398}, + {"type": "regex_flags", "start": 1398, "end": 1399}, + {"type": "punctuation", "start": 1399, "end": 1400}, + {"type": "keyword", "start": 1401, "end": 1407}, + {"type": "keyword", "start": 1408, "end": 1413}, + {"type": "operator", "start": 1428, "end": 1429}, + {"type": "regex", "start": 1430, "end": 1462}, + {"type": "regex_delimiter", "start": 1430, "end": 1431}, + {"type": "regex_source", "start": 1431, "end": 1461}, + {"type": "regex_delimiter", "start": 1461, "end": 1462}, + {"type": "punctuation", "start": 1462, "end": 1463}, + {"type": "comment", "start": 1465, "end": 1521}, + {"type": "comment", "start": 1522, "end": 1573} ], - "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(false);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tthis.#private_method();\n\t\t// foo\n\t};\n\n\t#private_method() {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc\n\t\t`);\n\t}\n\n\tprotected protected_method(): void {\n\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t}\n}\n\nexport {a, b, c, D};\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tfor (const c2 of this.d1) {\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected protected_method(): void {\n\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/fixtures/generated/ts/ts_complex.txt index 9188a0e4..730c4b06 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/fixtures/generated/ts/ts_complex.txt @@ -36,228 +36,276 @@ 134-135 operator = 136-142 function $state 142-143 punctuation ( - 143-148 boolean false - 148-149 punctuation ) - 149-150 punctuation ; - 153-164 function constructor - 164-165 punctuation ( - 167-168 operator : - 169-175 builtin number - 175-176 punctuation ) - 177-178 punctuation { - 181-185 keyword this - 185-186 punctuation . - 189-190 operator = - 193-194 punctuation ; - 196-197 punctuation } - 200-212 function class_method - 212-213 punctuation ( - 213-214 punctuation ) - 214-215 operator : - 216-222 builtin string - 223-224 punctuation { - 227-233 keyword return - 234-253 template_string `Hello, ${this.d1}` - 234-235 template_punctuation ` - 235-242 string Hello, - 242-252 interpolation ${this.d1} - 242-244 interpolation_punctuation ${ - 244-248 keyword this - 248-249 punctuation . - 251-252 interpolation_punctuation } - 252-253 template_punctuation ` - 253-254 punctuation ; - 256-257 punctuation } - 276-277 operator = - 278-279 punctuation ( - 279-280 punctuation ) - 280-281 operator : - 282-286 keyword void - 287-289 operator => - 290-291 punctuation { - 294-303 comment /* ... */ - 306-310 keyword this - 310-311 punctuation . - 311-326 function #private_method - 326-327 punctuation ( - 327-328 punctuation ) - 328-329 punctuation ; - 332-338 comment // foo - 340-341 punctuation } - 341-342 punctuation ; - 345-360 function #private_method - 360-361 punctuation ( - 361-362 punctuation ) - 363-364 punctuation { - 367-372 keyword throw - 373-376 keyword new - 377-382 class_name Error - 382-383 punctuation ( - 383-419 template_string `${this.d1} \n\t\t\tmultiline\n\t\t\tetc\n\t\t` - 383-384 template_punctuation ` - 384-394 interpolation ${this.d1} - 384-386 interpolation_punctuation ${ - 386-390 keyword this - 390-391 punctuation . - 393-394 interpolation_punctuation } - 394-418 string \n\t\t\tmultiline\n\t\t\tetc\n\t\t - 418-419 template_punctuation ` + 143-147 keyword null + 147-148 punctuation ) + 148-149 punctuation ; + 152-163 function constructor + 163-164 punctuation ( + 166-167 operator : + 168-174 builtin number + 174-175 punctuation ) + 176-177 punctuation { + 180-184 keyword this + 184-185 punctuation . + 188-189 operator = + 192-193 punctuation ; + 195-196 punctuation } + 199-211 function class_method + 211-212 punctuation ( + 212-213 punctuation ) + 213-214 operator : + 215-221 builtin string + 222-223 punctuation { + 226-232 keyword return + 233-252 template_string `Hello, ${this.d1}` + 233-234 template_punctuation ` + 234-241 string Hello, + 241-251 interpolation ${this.d1} + 241-243 interpolation_punctuation ${ + 243-247 keyword this + 247-248 punctuation . + 250-251 interpolation_punctuation } + 251-252 template_punctuation ` + 252-253 punctuation ; + 255-256 punctuation } + 275-276 operator = + 277-278 punctuation ( + 278-279 punctuation ) + 279-280 operator : + 281-285 keyword void + 286-288 operator => + 289-290 punctuation { + 293-302 comment /* ... */ + 305-308 keyword for + 309-310 punctuation ( + 310-315 keyword const + 319-321 keyword of + 322-326 keyword this + 326-327 punctuation . + 329-330 punctuation ) + 331-332 punctuation { + 336-340 keyword this + 340-341 punctuation . + 341-356 function #private_method + 356-357 punctuation ( + 358-359 punctuation , + 362-363 punctuation ) + 363-364 punctuation ; + 367-368 punctuation } + 371-377 comment // foo + 379-380 punctuation } + 380-381 punctuation ; + 384-399 function #private_method + 399-400 punctuation ( + 402-403 operator : + 404-410 builtin number + 410-411 punctuation , + 414-415 operator : + 416-419 builtin any 419-420 punctuation ) - 420-421 punctuation ; - 423-424 punctuation } - 427-436 keyword protected - 437-453 function protected_method - 453-454 punctuation ( - 454-455 punctuation ) - 455-456 operator : - 457-461 keyword void - 462-463 punctuation { - 466-473 builtin console - 473-474 punctuation . - 474-477 function log - 477-478 punctuation ( - 478-481 keyword new - 482-486 class_name Date - 486-487 punctuation ( - 487-488 punctuation ) + 421-422 punctuation { + 425-430 keyword throw + 431-434 keyword new + 435-440 class_name Error + 440-441 punctuation ( + 441-488 template_string `${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` + 441-442 template_punctuation ` + 442-452 interpolation ${this.d1} + 442-444 interpolation_punctuation ${ + 444-448 keyword this + 448-449 punctuation . + 451-452 interpolation_punctuation } + 452-474 string \n\t\t\tmultiline\n\t\t\tetc + 474-484 interpolation ${a2 + c2} + 474-476 interpolation_punctuation ${ + 479-480 operator + + 483-484 interpolation_punctuation } + 484-487 string \n\t\t + 487-488 template_punctuation ` 488-489 punctuation ) 489-490 punctuation ; - 491-524 comment // eslint-disable-line no-console - 526-527 punctuation } - 528-529 punctuation } - 531-537 keyword export - 538-539 punctuation { - 540-541 punctuation , - 543-544 punctuation , - 546-547 punctuation , - 548-549 constant D - 549-550 punctuation } - 550-551 punctuation ; - 553-563 comment // comment - 565-608 comment /*\nother comment\n\nconst comment = false;\n*/ - 610-634 comment /**\n * JSDoc comment\n */ - 636-642 keyword export - 643-652 keyword interface - 653-659 class_name Some_E - 660-661 punctuation { - 667-668 operator : - 669-675 builtin string - 675-676 punctuation ; - 681-682 operator : - 683-689 builtin number - 689-690 punctuation ; - 691-692 punctuation } - 694-700 keyword export - 701-706 keyword const - 713-714 operator : - 722-723 operator = - 724-725 punctuation { - 729-730 operator : - 731-738 string 'A. H.' - 738-739 punctuation , - 743-744 operator : - 745-748 number 100 - 748-749 punctuation } - 749-750 punctuation ; - 752-758 keyword export - 759-767 keyword function - 768-771 function add - 771-772 punctuation ( - 773-774 operator : - 775-781 builtin number - 781-782 punctuation , - 784-785 operator : - 786-792 builtin number - 792-793 punctuation ) - 793-794 operator : - 795-801 builtin number - 802-803 punctuation { - 805-811 keyword return - 814-815 operator + - 817-818 punctuation ; - 819-820 punctuation } - 822-828 keyword export - 829-834 keyword const - 840-841 operator = - 842-843 punctuation ( - 844-845 operator : - 846-849 builtin any - 849-850 punctuation , - 852-853 operator : - 854-857 builtin any - 857-858 punctuation ) - 858-859 operator : - 860-863 builtin any - 864-866 operator => - 869-870 operator + - 872-873 punctuation ; - 875-897 comment // boundary test cases - 898-904 keyword export - 905-910 keyword const - 929-930 operator = - 931-960 string 'const class function string' - 960-961 punctuation ; - 962-968 keyword export - 969-974 keyword const - 992-993 operator = - 994-1020 string '// this is not a comment' -1020-1021 punctuation ; -1022-1028 keyword export -1029-1034 keyword const -1054-1055 operator = -1056-1073 template_string `Value: ${1 + 2}` -1056-1057 template_punctuation ` -1057-1064 string Value: -1064-1072 interpolation ${1 + 2} -1064-1066 interpolation_punctuation ${ -1066-1067 number 1 -1068-1069 operator + -1070-1071 number 2 -1071-1072 interpolation_punctuation } -1072-1073 template_punctuation ` -1073-1074 punctuation ; -1076-1108 comment // regex that looks like comment -1109-1115 keyword export -1116-1121 keyword const -1128-1129 operator = -1130-1139 regex /\/\/.*/g -1130-1131 regex_delimiter / -1131-1137 regex_source \/\/.* -1137-1138 regex_delimiter / -1138-1139 regex_flags g -1139-1140 punctuation ; -1141-1147 keyword export -1148-1153 keyword const -1168-1169 operator = -1170-1202 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ -1170-1171 regex_delimiter / -1171-1201 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ -1201-1202 regex_delimiter / -1202-1203 punctuation ; -1205-1261 comment // string in comment should not be highlighted as string -1262-1313 comment // const commented = "this string is in a comment"; + 492-493 punctuation } + 496-505 keyword protected + 506-522 function protected_method + 522-523 punctuation ( + 523-524 punctuation ) + 524-525 operator : + 526-530 keyword void + 531-532 punctuation { + 535-542 builtin console + 542-543 punctuation . + 543-546 function log + 546-547 punctuation ( + 547-550 keyword new + 551-555 class_name Date + 555-556 punctuation ( + 556-557 punctuation ) + 557-558 punctuation ) + 558-559 punctuation ; + 560-593 comment // eslint-disable-line no-console + 595-596 punctuation } + 597-598 punctuation } + 600-610 comment // comment + 612-655 comment /*\nother comment\n\nconst comment = false;\n*/ + 657-681 comment /**\n * JSDoc comment\n */ + 683-689 keyword import + 690-691 punctuation { + 703-704 punctuation , + 705-709 keyword type + 710-721 class_name Code_Sample + 721-722 punctuation , + 723-727 keyword type + 728-739 class_name Sample_Lang + 739-740 punctuation } + 741-745 keyword from + 746-765 string '../code_sample.js' + 765-766 punctuation ; + 767-773 keyword import + 774-775 operator * + 776-778 keyword as + 779-780 constant A + 781-785 keyword from + 786-805 string '../code_sample.js' + 805-806 punctuation ; + 821-823 keyword as + 824-831 builtin unknown + 832-834 keyword as + 847-849 keyword as + 850-853 builtin any + 854-856 keyword as + 868-869 punctuation ; + 871-877 keyword export + 878-879 punctuation { + 880-881 punctuation , + 882-883 constant A + 883-884 punctuation , + 886-887 punctuation , + 889-890 punctuation , + 891-892 constant D + 892-893 punctuation } + 893-894 punctuation ; + 896-902 keyword export + 903-912 keyword interface + 913-919 class_name Some_E + 920-921 punctuation { + 927-928 operator : + 929-935 builtin string + 935-936 punctuation ; + 941-942 operator : + 943-949 builtin number + 949-950 punctuation ; + 951-952 punctuation } + 954-960 keyword export + 961-966 keyword const + 973-974 operator : + 982-983 operator = + 984-985 punctuation { + 989-990 operator : + 991-998 string 'A. H.' + 998-999 punctuation , +1003-1004 operator : +1005-1008 number 100 +1008-1009 punctuation } +1009-1010 punctuation ; +1012-1018 keyword export +1019-1027 keyword function +1028-1031 function add +1031-1032 punctuation ( +1033-1034 operator : +1035-1041 builtin number +1041-1042 punctuation , +1044-1045 operator : +1046-1052 builtin number +1052-1053 punctuation ) +1053-1054 operator : +1055-1061 builtin number +1062-1063 punctuation { +1065-1071 keyword return +1074-1075 operator + +1077-1078 punctuation ; +1079-1080 punctuation } +1082-1088 keyword export +1089-1094 keyword const +1100-1101 operator = +1102-1103 punctuation ( +1104-1105 operator : +1106-1109 builtin any +1109-1110 punctuation , +1112-1113 operator : +1114-1117 builtin any +1117-1118 punctuation ) +1118-1119 operator : +1120-1123 builtin any +1124-1126 operator => +1129-1130 operator + +1132-1133 punctuation ; +1135-1157 comment // boundary test cases +1158-1164 keyword export +1165-1170 keyword const +1189-1190 operator = +1191-1220 string 'const class function string' +1220-1221 punctuation ; +1222-1228 keyword export +1229-1234 keyword const +1252-1253 operator = +1254-1280 string '// this is not a comment' +1280-1281 punctuation ; +1282-1288 keyword export +1289-1294 keyword const +1314-1315 operator = +1316-1333 template_string `Value: ${1 + 2}` +1316-1317 template_punctuation ` +1317-1324 string Value: +1324-1332 interpolation ${1 + 2} +1324-1326 interpolation_punctuation ${ +1326-1327 number 1 +1328-1329 operator + +1330-1331 number 2 +1331-1332 interpolation_punctuation } +1332-1333 template_punctuation ` +1333-1334 punctuation ; +1336-1368 comment // regex that looks like comment +1369-1375 keyword export +1376-1381 keyword const +1388-1389 operator = +1390-1399 regex /\/\/.*/g +1390-1391 regex_delimiter / +1391-1397 regex_source \/\/.* +1397-1398 regex_delimiter / +1398-1399 regex_flags g +1399-1400 punctuation ; +1401-1407 keyword export +1408-1413 keyword const +1428-1429 operator = +1430-1462 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ +1430-1431 regex_delimiter / +1431-1461 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +1461-1462 regex_delimiter / +1462-1463 punctuation ; +1465-1521 comment // string in comment should not be highlighted as string +1522-1573 comment // const commented = "this string is in a comment"; === STATS === -Total tokens: 237 -Sample length: 1314 characters +Total tokens: 285 +Sample length: 1574 characters Token types: - punctuation: 79 - operator: 39 - keyword: 37 - builtin: 13 + punctuation: 94 + keyword: 53 + operator: 43 + builtin: 17 + string: 12 comment: 10 - string: 9 function: 8 + interpolation_punctuation: 8 + class_name: 7 template_punctuation: 6 - interpolation_punctuation: 6 number: 5 - class_name: 5 + constant: 4 + interpolation: 4 regex_delimiter: 4 - boolean: 3 template_string: 3 - interpolation: 3 - constant: 2 + boolean: 2 regex: 2 regex_source: 2 regex_flags: 1 diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 614d0029..ecd81466 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -139,12 +139,12 @@ const comment = false; * JSDoc comment */ -// @ts-expect-error -import {B, C, d} from 'foo'; -// @ts-expect-error -import * as A from 'foo2'; +import {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js'; +import * as A from '../code_sample.js'; -export {a, A, b, B, c, C, D}; +sample_langs as unknown as Code_Sample as any as Sample_Lang; + +export {a, A, b, c, D}; export interface Some_E { name: string; diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index 05fc93c1..00123664 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -51,12 +51,12 @@ const comment = false; * JSDoc comment */ -// @ts-expect-error -import {B, C, d} from 'foo'; -// @ts-expect-error -import * as A from 'foo2'; +import {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js'; +import * as A from '../code_sample.js'; -export {a, A, b, B, c, C, D}; +sample_langs as unknown as Code_Sample as any as Sample_Lang; + +export {a, A, b, c, D}; export interface Some_E { name: string; From 951027f9f843b173f4a90a403aba28c4a1a95829 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 07:08:47 -0400 Subject: [PATCH 07/49] wip --- src/lib/theme.css | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/lib/theme.css b/src/lib/theme.css index 44e75325..dfe233d7 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -13,15 +13,16 @@ color: var(--text_color_5); } -/* Namespaces */ .token.namespace, ::highlight(namespace) { color: var(--color_d_5); } -/* Properties, tags, and constants */ .token.property, -::highlight(property), +::highlight(property) { + color: var(--color_i_5); +} + .token.tag, ::highlight(tag), .token.constant, @@ -45,7 +46,6 @@ color: var(--color_a_5); } -/* selectors, and values */ .token.comment, ::highlight(comment), .token.selector, @@ -89,7 +89,6 @@ color: var(--color_f_5); } -/* Regular expressions and variables */ .token.regex, ::highlight(regex), .token.important, @@ -99,7 +98,6 @@ color: var(--color_e_5); } -/* Font weight modifiers */ .token.important, ::highlight(important), .token.bold, @@ -107,7 +105,6 @@ font-weight: bold; } -/* Font style modifiers */ .token.italic, ::highlight(italic) { font-style: italic; From a2d0514031b3782cfe56ac2d8c386565383c5233 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 07:10:45 -0400 Subject: [PATCH 08/49] wip --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 64510254..3d3d8b6f 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ but there are two optional dependencies: based on [`prism-svelte`](https://github.com/pngwn/prism-svelte) and a [Svelte component](src/lib/Code.svelte) for convenient usage. - The [default theme](src/lib/theme.css) integrates - with my CSS library [Moss](https://github.com/ryanatkn/moss) for colors that adapt to the user's runtime `color-scheme` preference, - and [theme_variables.css](src/lib/theme_variables.css) - is also included that uses the less-customizable `light-dark()`. + with my CSS library [Moss](https://github.com/ryanatkn/moss) for colors that adapt to the user's runtime `color-scheme` preference. + Non-Moss users should import [theme_variables.css](src/lib/theme_variables.css) + or otherwise define the variables. Compared to [Shiki](https://github.com/shikijs/shiki), this library is much lighter From 24d87194c289c727f9eb4d750d893adb0687f44b Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 07:11:34 -0400 Subject: [PATCH 09/49] wip --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3d3d8b6f..8b53a565 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ but there are two optional dependencies: - The [default theme](src/lib/theme.css) integrates with my CSS library [Moss](https://github.com/ryanatkn/moss) for colors that adapt to the user's runtime `color-scheme` preference. Non-Moss users should import [theme_variables.css](src/lib/theme_variables.css) - or otherwise define the variables. + or otherwise define those variables. Compared to [Shiki](https://github.com/shikijs/shiki), this library is much lighter From 65e84cfd9aecac549e7b22cf4f8024a02d6387d0 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 07:20:42 -0400 Subject: [PATCH 10/49] wip --- src/lib/theme.css | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lib/theme.css b/src/lib/theme.css index dfe233d7..f4a1d212 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -48,8 +48,6 @@ .token.comment, ::highlight(comment), -.token.selector, -::highlight(selector), .token.attr_value, ::highlight(attr_value), .token.char, @@ -77,8 +75,16 @@ color: var(--color_h_5); } +.token.selector, +::highlight(selector), .token.function, -::highlight(function) { +::highlight(function), +.token.regex, +::highlight(regex), +.token.important, +::highlight(important), +.token.variable, +::highlight(variable) { color: var(--color_e_5); } @@ -89,13 +95,9 @@ color: var(--color_f_5); } -.token.regex, -::highlight(regex), -.token.important, -::highlight(important), -.token.variable, -::highlight(variable) { - color: var(--color_e_5); +.token.rule, +::highlight(rule) { + color: var(--color_g_5); } .token.important, From 296417b4b7932d6f3a6545cc8521c5895f0d47e3 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 07:49:15 -0400 Subject: [PATCH 11/49] wip --- fixtures/generated/svelte/svelte_complex.json | 34 +- fixtures/generated/svelte/svelte_complex.txt | 35 +- fixtures/generated/ts/ts_complex.json | 503 +++++++++------- fixtures/generated/ts/ts_complex.txt | 542 +++++++++++------- src/lib/grammar_js.ts | 10 +- src/lib/samples/all.ts | 21 +- src/lib/samples/sample_complex.ts | 21 +- src/lib/theme.css | 6 +- 8 files changed, 713 insertions(+), 459 deletions(-) diff --git a/fixtures/generated/svelte/svelte_complex.json b/fixtures/generated/svelte/svelte_complex.json index 16d8e811..82f49967 100644 --- a/fixtures/generated/svelte/svelte_complex.json +++ b/fixtures/generated/svelte/svelte_complex.json @@ -18,7 +18,7 @@ {"type": "punctuation", "start": 24, "end": 25}, {"type": "script", "start": 25, "end": 57}, {"type": "lang_ts", "start": 25, "end": 57}, - {"type": "keyword", "start": 27, "end": 33}, + {"type": "special_keyword", "start": 27, "end": 33}, {"type": "keyword", "start": 34, "end": 39}, {"type": "constant", "start": 40, "end": 45}, {"type": "operator", "start": 46, "end": 47}, @@ -40,15 +40,15 @@ {"type": "script", "start": 86, "end": 1268}, {"type": "lang_ts", "start": 86, "end": 1268}, {"type": "comment", "start": 88, "end": 107}, - {"type": "keyword", "start": 109, "end": 115}, - {"type": "keyword", "start": 122, "end": 126}, + {"type": "special_keyword", "start": 109, "end": 115}, + {"type": "special_keyword", "start": 122, "end": 126}, {"type": "string", "start": 127, "end": 146}, {"type": "punctuation", "start": 146, "end": 147}, - {"type": "keyword", "start": 149, "end": 155}, + {"type": "special_keyword", "start": 149, "end": 155}, {"type": "keyword", "start": 156, "end": 160}, {"type": "punctuation", "start": 161, "end": 162}, {"type": "punctuation", "start": 169, "end": 170}, - {"type": "keyword", "start": 171, "end": 175}, + {"type": "special_keyword", "start": 171, "end": 175}, {"type": "string", "start": 176, "end": 184}, {"type": "punctuation", "start": 184, "end": 185}, {"type": "keyword", "start": 188, "end": 193}, @@ -110,7 +110,7 @@ {"type": "boolean", "start": 444, "end": 448}, {"type": "punctuation", "start": 448, "end": 449}, {"type": "punctuation", "start": 449, "end": 450}, - {"type": "keyword", "start": 453, "end": 459}, + {"type": "special_keyword", "start": 453, "end": 459}, {"type": "keyword", "start": 460, "end": 464}, {"type": "class_name", "start": 465, "end": 474}, {"type": "operator", "start": 475, "end": 476}, @@ -155,7 +155,7 @@ {"type": "operator", "start": 628, "end": 629}, {"type": "builtin", "start": 630, "end": 636}, {"type": "punctuation", "start": 637, "end": 638}, - {"type": "keyword", "start": 642, "end": 648}, + {"type": "special_keyword", "start": 642, "end": 648}, {"type": "template_string", "start": 649, "end": 668}, {"type": "template_punctuation", "start": 649, "end": 650}, {"type": "string", "start": 650, "end": 657}, @@ -187,7 +187,7 @@ {"type": "punctuation", "start": 776, "end": 777}, {"type": "punctuation", "start": 777, "end": 778}, {"type": "punctuation", "start": 779, "end": 780}, - {"type": "keyword", "start": 784, "end": 789}, + {"type": "special_keyword", "start": 784, "end": 789}, {"type": "keyword", "start": 790, "end": 793}, {"type": "class_name", "start": 794, "end": 799}, {"type": "punctuation", "start": 799, "end": 800}, @@ -225,7 +225,7 @@ {"type": "comment", "start": 931, "end": 941}, {"type": "comment", "start": 944, "end": 990}, {"type": "comment", "start": 993, "end": 1019}, - {"type": "keyword", "start": 1022, "end": 1028}, + {"type": "special_keyword", "start": 1022, "end": 1028}, {"type": "keyword", "start": 1029, "end": 1038}, {"type": "class_name", "start": 1039, "end": 1045}, {"type": "punctuation", "start": 1046, "end": 1047}, @@ -236,7 +236,7 @@ {"type": "builtin", "start": 1071, "end": 1077}, {"type": "punctuation", "start": 1077, "end": 1078}, {"type": "punctuation", "start": 1080, "end": 1081}, - {"type": "keyword", "start": 1084, "end": 1090}, + {"type": "special_keyword", "start": 1084, "end": 1090}, {"type": "keyword", "start": 1091, "end": 1096}, {"type": "operator", "start": 1103, "end": 1104}, {"type": "operator", "start": 1112, "end": 1113}, @@ -248,7 +248,7 @@ {"type": "number", "start": 1135, "end": 1138}, {"type": "punctuation", "start": 1138, "end": 1139}, {"type": "punctuation", "start": 1139, "end": 1140}, - {"type": "keyword", "start": 1143, "end": 1149}, + {"type": "special_keyword", "start": 1143, "end": 1149}, {"type": "keyword", "start": 1150, "end": 1158}, {"type": "function", "start": 1159, "end": 1162}, {"type": "punctuation", "start": 1162, "end": 1163}, @@ -261,11 +261,11 @@ {"type": "operator", "start": 1184, "end": 1185}, {"type": "builtin", "start": 1186, "end": 1192}, {"type": "punctuation", "start": 1193, "end": 1194}, - {"type": "keyword", "start": 1197, "end": 1203}, + {"type": "special_keyword", "start": 1197, "end": 1203}, {"type": "operator", "start": 1206, "end": 1207}, {"type": "punctuation", "start": 1209, "end": 1210}, {"type": "punctuation", "start": 1212, "end": 1213}, - {"type": "keyword", "start": 1216, "end": 1222}, + {"type": "special_keyword", "start": 1216, "end": 1222}, {"type": "keyword", "start": 1223, "end": 1228}, {"type": "operator", "start": 1234, "end": 1235}, {"type": "punctuation", "start": 1236, "end": 1237}, @@ -322,7 +322,7 @@ {"type": "punctuation", "start": 1380, "end": 1381}, {"type": "lang_ts", "start": 1383, "end": 1390}, {"type": "punctuation", "start": 1383, "end": 1384}, - {"type": "keyword", "start": 1385, "end": 1387}, + {"type": "special_keyword", "start": 1385, "end": 1387}, {"type": "punctuation", "start": 1389, "end": 1390}, {"type": "tag", "start": 1392, "end": 1433}, {"type": "tag", "start": 1392, "end": 1398}, @@ -341,7 +341,7 @@ {"type": "lang_ts", "start": 1434, "end": 1441}, {"type": "punctuation", "start": 1434, "end": 1435}, {"type": "operator", "start": 1435, "end": 1436}, - {"type": "keyword", "start": 1436, "end": 1440}, + {"type": "special_keyword", "start": 1436, "end": 1440}, {"type": "punctuation", "start": 1440, "end": 1441}, {"type": "tag", "start": 1443, "end": 1507}, {"type": "tag", "start": 1443, "end": 1449}, @@ -384,7 +384,7 @@ {"type": "lang_ts", "start": 1541, "end": 1546}, {"type": "punctuation", "start": 1541, "end": 1542}, {"type": "operator", "start": 1542, "end": 1543}, - {"type": "keyword", "start": 1543, "end": 1545}, + {"type": "special_keyword", "start": 1543, "end": 1545}, {"type": "punctuation", "start": 1545, "end": 1546}, {"type": "doctype", "start": 1548, "end": 1563}, {"type": "tag", "start": 1565, "end": 1606}, @@ -583,5 +583,5 @@ {"type": "punctuation", "start": 2324, "end": 2326}, {"type": "punctuation", "start": 2331, "end": 2332} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/fixtures/generated/svelte/svelte_complex.txt b/fixtures/generated/svelte/svelte_complex.txt index 354d0065..324acaa9 100644 --- a/fixtures/generated/svelte/svelte_complex.txt +++ b/fixtures/generated/svelte/svelte_complex.txt @@ -11,7 +11,7 @@ 24-25 punctuation > 25-57 script \n\texport const HELLO = 'world';\n 25-57 lang_ts \n\texport const HELLO = 'world';\n - 27-33 keyword export + 27-33 special_keyword export 34-39 keyword const 40-45 constant HELLO 46-47 operator = @@ -33,15 +33,15 @@ 86-1268 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n 86-1268 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n 88-107 comment // @ts-expect-error - 109-115 keyword import - 122-126 keyword from + 109-115 special_keyword import + 122-126 special_keyword from 127-146 string '$lib/Thing.svelte' 146-147 punctuation ; - 149-155 keyword import + 149-155 special_keyword import 156-160 keyword type 161-162 punctuation { 169-170 punctuation } - 171-175 keyword from + 171-175 special_keyword from 176-184 string 'svelte' 184-185 punctuation ; 188-193 keyword const @@ -103,7 +103,7 @@ 444-448 boolean true 448-449 punctuation ) 449-450 punctuation ; - 453-459 keyword export + 453-459 special_keyword export 460-464 keyword type 465-474 class_name Some_Type 475-476 operator = @@ -148,7 +148,7 @@ 628-629 operator : 630-636 builtin string 637-638 punctuation { - 642-648 keyword return + 642-648 special_keyword return 649-668 template_string `Hello, ${this.d1}` 649-650 template_punctuation ` 650-657 string Hello, @@ -180,7 +180,7 @@ 776-777 punctuation ( 777-778 punctuation ) 779-780 punctuation { - 784-789 keyword throw + 784-789 special_keyword throw 790-793 keyword new 794-799 class_name Error 799-800 punctuation ( @@ -218,7 +218,7 @@ 931-941 comment // comment 944-990 comment /*\n\tother comment\n\n\tconst comment = false;\n\t*/ 993-1019 comment /**\n\t * JSDoc comment\n\t */ -1022-1028 keyword export +1022-1028 special_keyword export 1029-1038 keyword interface 1039-1045 class_name Some_E 1046-1047 punctuation { @@ -229,7 +229,7 @@ 1071-1077 builtin number 1077-1078 punctuation ; 1080-1081 punctuation } -1084-1090 keyword export +1084-1090 special_keyword export 1091-1096 keyword const 1103-1104 operator : 1112-1113 operator = @@ -241,7 +241,7 @@ 1135-1138 number 100 1138-1139 punctuation } 1139-1140 punctuation ; -1143-1149 keyword export +1143-1149 special_keyword export 1150-1158 keyword function 1159-1162 function add 1162-1163 punctuation ( @@ -254,11 +254,11 @@ 1184-1185 operator : 1186-1192 builtin number 1193-1194 punctuation { -1197-1203 keyword return +1197-1203 special_keyword return 1206-1207 operator + 1209-1210 punctuation ; 1212-1213 punctuation } -1216-1222 keyword export +1216-1222 special_keyword export 1223-1228 keyword const 1234-1235 operator = 1236-1237 punctuation ( @@ -315,7 +315,7 @@ 1380-1381 punctuation } 1383-1390 lang_ts {#if c} 1383-1384 punctuation { -1385-1387 keyword if +1385-1387 special_keyword if 1389-1390 punctuation } 1392-1433 tag 1392-1398 tag (c = !c)}> 1443-1449 tag 1565-1606 tag
@@ -584,10 +584,11 @@ Token types: punctuation: 270 tag: 60 operator: 49 - keyword: 40 + keyword: 24 lang_ts: 19 builtin: 17 attr_name: 16 + special_keyword: 16 function: 16 attr_value: 11 string: 10 diff --git a/fixtures/generated/ts/ts_complex.json b/fixtures/generated/ts/ts_complex.json index 854b6cc3..d34cc0ac 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/fixtures/generated/ts/ts_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "ts", "variant": "complex", - "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tfor (const c2 of this.d1) {\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected protected_method(): void {\n\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", + "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\twhile (i < 3) i++;\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", "filepath": "src/lib/samples/sample_complex.ts" }, "tokens": [ @@ -18,7 +18,7 @@ {"type": "operator", "start": 38, "end": 39}, {"type": "boolean", "start": 40, "end": 44}, {"type": "punctuation", "start": 44, "end": 45}, - {"type": "keyword", "start": 47, "end": 53}, + {"type": "special_keyword", "start": 47, "end": 53}, {"type": "keyword", "start": 54, "end": 58}, {"type": "class_name", "start": 59, "end": 68}, {"type": "operator", "start": 69, "end": 70}, @@ -63,7 +63,7 @@ {"type": "operator", "start": 213, "end": 214}, {"type": "builtin", "start": 215, "end": 221}, {"type": "punctuation", "start": 222, "end": 223}, - {"type": "keyword", "start": 226, "end": 232}, + {"type": "special_keyword", "start": 226, "end": 232}, {"type": "template_string", "start": 233, "end": 252}, {"type": "template_punctuation", "start": 233, "end": 234}, {"type": "string", "start": 234, "end": 241}, @@ -84,213 +84,320 @@ {"type": "punctuation", "start": 289, "end": 290}, {"type": "comment", "start": 293, "end": 302}, {"type": "keyword", "start": 305, "end": 308}, - {"type": "punctuation", "start": 309, "end": 310}, - {"type": "keyword", "start": 310, "end": 315}, - {"type": "keyword", "start": 319, "end": 321}, - {"type": "keyword", "start": 322, "end": 326}, - {"type": "punctuation", "start": 326, "end": 327}, - {"type": "punctuation", "start": 329, "end": 330}, - {"type": "punctuation", "start": 331, "end": 332}, - {"type": "keyword", "start": 336, "end": 340}, - {"type": "punctuation", "start": 340, "end": 341}, - {"type": "function", "start": 341, "end": 356}, - {"type": "punctuation", "start": 356, "end": 357}, - {"type": "punctuation", "start": 358, "end": 359}, - {"type": "punctuation", "start": 362, "end": 363}, + {"type": "operator", "start": 311, "end": 312}, + {"type": "number", "start": 313, "end": 314}, + {"type": "punctuation", "start": 314, "end": 315}, + {"type": "special_keyword", "start": 318, "end": 323}, + {"type": "punctuation", "start": 324, "end": 325}, + {"type": "operator", "start": 327, "end": 328}, + {"type": "number", "start": 329, "end": 330}, + {"type": "punctuation", "start": 330, "end": 331}, + {"type": "operator", "start": 333, "end": 335}, + {"type": "punctuation", "start": 335, "end": 336}, + {"type": "special_keyword", "start": 339, "end": 342}, + {"type": "punctuation", "start": 343, "end": 344}, + {"type": "keyword", "start": 344, "end": 349}, + {"type": "keyword", "start": 353, "end": 355}, + {"type": "keyword", "start": 356, "end": 360}, + {"type": "punctuation", "start": 360, "end": 361}, {"type": "punctuation", "start": 363, "end": 364}, - {"type": "punctuation", "start": 367, "end": 368}, - {"type": "comment", "start": 371, "end": 377}, - {"type": "punctuation", "start": 379, "end": 380}, - {"type": "punctuation", "start": 380, "end": 381}, - {"type": "function", "start": 384, "end": 399}, - {"type": "punctuation", "start": 399, "end": 400}, - {"type": "operator", "start": 402, "end": 403}, - {"type": "builtin", "start": 404, "end": 410}, - {"type": "punctuation", "start": 410, "end": 411}, - {"type": "operator", "start": 414, "end": 415}, - {"type": "builtin", "start": 416, "end": 419}, - {"type": "punctuation", "start": 419, "end": 420}, - {"type": "punctuation", "start": 421, "end": 422}, - {"type": "keyword", "start": 425, "end": 430}, - {"type": "keyword", "start": 431, "end": 434}, - {"type": "class_name", "start": 435, "end": 440}, + {"type": "punctuation", "start": 365, "end": 366}, + {"type": "special_keyword", "start": 370, "end": 372}, + {"type": "punctuation", "start": 373, "end": 374}, + {"type": "operator", "start": 377, "end": 380}, + {"type": "string", "start": 381, "end": 384}, + {"type": "punctuation", "start": 384, "end": 385}, + {"type": "special_keyword", "start": 386, "end": 394}, + {"type": "punctuation", "start": 394, "end": 395}, + {"type": "special_keyword", "start": 399, "end": 401}, + {"type": "punctuation", "start": 402, "end": 403}, + {"type": "operator", "start": 403, "end": 404}, + {"type": "punctuation", "start": 406, "end": 407}, + {"type": "special_keyword", "start": 408, "end": 413}, + {"type": "punctuation", "start": 413, "end": 414}, + {"type": "keyword", "start": 418, "end": 422}, + {"type": "punctuation", "start": 422, "end": 423}, + {"type": "function", "start": 423, "end": 438}, + {"type": "punctuation", "start": 438, "end": 439}, {"type": "punctuation", "start": 440, "end": 441}, - {"type": "template_string", "start": 441, "end": 488}, - {"type": "template_punctuation", "start": 441, "end": 442}, - {"type": "interpolation", "start": 442, "end": 452}, - {"type": "interpolation_punctuation", "start": 442, "end": 444}, - {"type": "keyword", "start": 444, "end": 448}, - {"type": "punctuation", "start": 448, "end": 449}, - {"type": "interpolation_punctuation", "start": 451, "end": 452}, - {"type": "string", "start": 452, "end": 474}, - {"type": "interpolation", "start": 474, "end": 484}, - {"type": "interpolation_punctuation", "start": 474, "end": 476}, - {"type": "operator", "start": 479, "end": 480}, - {"type": "interpolation_punctuation", "start": 483, "end": 484}, - {"type": "string", "start": 484, "end": 487}, - {"type": "template_punctuation", "start": 487, "end": 488}, - {"type": "punctuation", "start": 488, "end": 489}, - {"type": "punctuation", "start": 489, "end": 490}, + {"type": "punctuation", "start": 444, "end": 445}, + {"type": "punctuation", "start": 445, "end": 446}, + {"type": "punctuation", "start": 449, "end": 450}, + {"type": "comment", "start": 453, "end": 459}, + {"type": "punctuation", "start": 461, "end": 462}, + {"type": "punctuation", "start": 462, "end": 463}, + {"type": "function", "start": 466, "end": 481}, + {"type": "punctuation", "start": 481, "end": 482}, + {"type": "operator", "start": 484, "end": 485}, + {"type": "builtin", "start": 486, "end": 492}, {"type": "punctuation", "start": 492, "end": 493}, - {"type": "keyword", "start": 496, "end": 505}, - {"type": "function", "start": 506, "end": 522}, + {"type": "operator", "start": 496, "end": 497}, + {"type": "builtin", "start": 498, "end": 501}, + {"type": "punctuation", "start": 501, "end": 502}, + {"type": "punctuation", "start": 503, "end": 504}, + {"type": "special_keyword", "start": 507, "end": 512}, + {"type": "keyword", "start": 513, "end": 516}, + {"type": "class_name", "start": 517, "end": 522}, {"type": "punctuation", "start": 522, "end": 523}, - {"type": "punctuation", "start": 523, "end": 524}, - {"type": "operator", "start": 524, "end": 525}, + {"type": "template_string", "start": 523, "end": 570}, + {"type": "template_punctuation", "start": 523, "end": 524}, + {"type": "interpolation", "start": 524, "end": 534}, + {"type": "interpolation_punctuation", "start": 524, "end": 526}, {"type": "keyword", "start": 526, "end": 530}, - {"type": "punctuation", "start": 531, "end": 532}, - {"type": "builtin", "start": 535, "end": 542}, - {"type": "punctuation", "start": 542, "end": 543}, - {"type": "function", "start": 543, "end": 546}, - {"type": "punctuation", "start": 546, "end": 547}, - {"type": "keyword", "start": 547, "end": 550}, - {"type": "class_name", "start": 551, "end": 555}, - {"type": "punctuation", "start": 555, "end": 556}, - {"type": "punctuation", "start": 556, "end": 557}, - {"type": "punctuation", "start": 557, "end": 558}, - {"type": "punctuation", "start": 558, "end": 559}, - {"type": "comment", "start": 560, "end": 593}, - {"type": "punctuation", "start": 595, "end": 596}, - {"type": "punctuation", "start": 597, "end": 598}, - {"type": "comment", "start": 600, "end": 610}, - {"type": "comment", "start": 612, "end": 655}, - {"type": "comment", "start": 657, "end": 681}, - {"type": "keyword", "start": 683, "end": 689}, + {"type": "punctuation", "start": 530, "end": 531}, + {"type": "interpolation_punctuation", "start": 533, "end": 534}, + {"type": "string", "start": 534, "end": 556}, + {"type": "interpolation", "start": 556, "end": 566}, + {"type": "interpolation_punctuation", "start": 556, "end": 558}, + {"type": "operator", "start": 561, "end": 562}, + {"type": "interpolation_punctuation", "start": 565, "end": 566}, + {"type": "string", "start": 566, "end": 569}, + {"type": "template_punctuation", "start": 569, "end": 570}, + {"type": "punctuation", "start": 570, "end": 571}, + {"type": "punctuation", "start": 571, "end": 572}, + {"type": "punctuation", "start": 574, "end": 575}, + {"type": "keyword", "start": 578, "end": 587}, + {"type": "keyword", "start": 588, "end": 593}, + {"type": "function", "start": 594, "end": 610}, + {"type": "punctuation", "start": 610, "end": 611}, + {"type": "punctuation", "start": 611, "end": 612}, + {"type": "operator", "start": 612, "end": 613}, + {"type": "builtin", "start": 614, "end": 621}, + {"type": "operator", "start": 621, "end": 622}, + {"type": "keyword", "start": 622, "end": 626}, + {"type": "operator", "start": 626, "end": 627}, + {"type": "punctuation", "start": 628, "end": 629}, + {"type": "special_keyword", "start": 632, "end": 635}, + {"type": "punctuation", "start": 636, "end": 637}, + {"type": "special_keyword", "start": 641, "end": 646}, + {"type": "keyword", "start": 647, "end": 650}, + {"type": "class_name", "start": 651, "end": 658}, + {"type": "builtin", "start": 651, "end": 658}, + {"type": "punctuation", "start": 658, "end": 659}, + {"type": "punctuation", "start": 659, "end": 660}, + {"type": "punctuation", "start": 667, "end": 668}, + {"type": "operator", "start": 669, "end": 671}, + {"type": "function", "start": 672, "end": 682}, + {"type": "punctuation", "start": 682, "end": 683}, {"type": "punctuation", "start": 690, "end": 691}, - {"type": "punctuation", "start": 703, "end": 704}, - {"type": "keyword", "start": 705, "end": 709}, - {"type": "class_name", "start": 710, "end": 721}, - {"type": "punctuation", "start": 721, "end": 722}, - {"type": "keyword", "start": 723, "end": 727}, - {"type": "class_name", "start": 728, "end": 739}, - {"type": "punctuation", "start": 739, "end": 740}, - {"type": "keyword", "start": 741, "end": 745}, - {"type": "string", "start": 746, "end": 765}, - {"type": "punctuation", "start": 765, "end": 766}, - {"type": "keyword", "start": 767, "end": 773}, - {"type": "operator", "start": 774, "end": 775}, - {"type": "keyword", "start": 776, "end": 778}, - {"type": "constant", "start": 779, "end": 780}, - {"type": "keyword", "start": 781, "end": 785}, - {"type": "string", "start": 786, "end": 805}, + {"type": "number", "start": 692, "end": 695}, + {"type": "punctuation", "start": 695, "end": 696}, + {"type": "punctuation", "start": 696, "end": 697}, + {"type": "punctuation", "start": 697, "end": 698}, + {"type": "special_keyword", "start": 702, "end": 704}, + {"type": "punctuation", "start": 705, "end": 706}, + {"type": "punctuation", "start": 710, "end": 711}, + {"type": "function", "start": 711, "end": 717}, + {"type": "punctuation", "start": 717, "end": 718}, + {"type": "punctuation", "start": 718, "end": 719}, + {"type": "operator", "start": 720, "end": 721}, + {"type": "number", "start": 722, "end": 725}, + {"type": "punctuation", "start": 725, "end": 726}, + {"type": "punctuation", "start": 727, "end": 728}, + {"type": "builtin", "start": 733, "end": 740}, + {"type": "punctuation", "start": 740, "end": 741}, + {"type": "function", "start": 741, "end": 744}, + {"type": "punctuation", "start": 744, "end": 745}, + {"type": "keyword", "start": 745, "end": 748}, + {"type": "class_name", "start": 749, "end": 753}, + {"type": "punctuation", "start": 753, "end": 754}, + {"type": "punctuation", "start": 754, "end": 755}, + {"type": "punctuation", "start": 755, "end": 756}, + {"type": "punctuation", "start": 756, "end": 757}, + {"type": "comment", "start": 758, "end": 791}, + {"type": "punctuation", "start": 795, "end": 796}, + {"type": "special_keyword", "start": 797, "end": 801}, + {"type": "special_keyword", "start": 802, "end": 804}, {"type": "punctuation", "start": 805, "end": 806}, - {"type": "keyword", "start": 821, "end": 823}, - {"type": "builtin", "start": 824, "end": 831}, - {"type": "keyword", "start": 832, "end": 834}, - {"type": "keyword", "start": 847, "end": 849}, - {"type": "builtin", "start": 850, "end": 853}, - {"type": "keyword", "start": 854, "end": 856}, - {"type": "punctuation", "start": 868, "end": 869}, - {"type": "keyword", "start": 871, "end": 877}, - {"type": "punctuation", "start": 878, "end": 879}, - {"type": "punctuation", "start": 880, "end": 881}, - {"type": "constant", "start": 882, "end": 883}, - {"type": "punctuation", "start": 883, "end": 884}, - {"type": "punctuation", "start": 886, "end": 887}, - {"type": "punctuation", "start": 889, "end": 890}, - {"type": "constant", "start": 891, "end": 892}, - {"type": "punctuation", "start": 892, "end": 893}, - {"type": "punctuation", "start": 893, "end": 894}, - {"type": "keyword", "start": 896, "end": 902}, - {"type": "keyword", "start": 903, "end": 912}, - {"type": "class_name", "start": 913, "end": 919}, - {"type": "punctuation", "start": 920, "end": 921}, - {"type": "operator", "start": 927, "end": 928}, - {"type": "builtin", "start": 929, "end": 935}, - {"type": "punctuation", "start": 935, "end": 936}, - {"type": "operator", "start": 941, "end": 942}, - {"type": "builtin", "start": 943, "end": 949}, + {"type": "punctuation", "start": 810, "end": 811}, + {"type": "function", "start": 811, "end": 817}, + {"type": "punctuation", "start": 817, "end": 818}, + {"type": "punctuation", "start": 818, "end": 819}, + {"type": "operator", "start": 820, "end": 821}, + {"type": "number", "start": 822, "end": 825}, + {"type": "punctuation", "start": 825, "end": 826}, + {"type": "punctuation", "start": 827, "end": 828}, + {"type": "builtin", "start": 833, "end": 840}, + {"type": "punctuation", "start": 840, "end": 841}, + {"type": "function", "start": 841, "end": 844}, + {"type": "punctuation", "start": 844, "end": 845}, + {"type": "string", "start": 845, "end": 861}, + {"type": "punctuation", "start": 861, "end": 862}, + {"type": "punctuation", "start": 862, "end": 863}, + {"type": "punctuation", "start": 867, "end": 868}, + {"type": "special_keyword", "start": 869, "end": 873}, + {"type": "punctuation", "start": 874, "end": 875}, + {"type": "builtin", "start": 880, "end": 887}, + {"type": "punctuation", "start": 887, "end": 888}, + {"type": "function", "start": 888, "end": 891}, + {"type": "punctuation", "start": 891, "end": 892}, + {"type": "string", "start": 892, "end": 905}, + {"type": "punctuation", "start": 905, "end": 906}, + {"type": "punctuation", "start": 906, "end": 907}, + {"type": "punctuation", "start": 911, "end": 912}, + {"type": "punctuation", "start": 915, "end": 916}, + {"type": "special_keyword", "start": 917, "end": 922}, + {"type": "punctuation", "start": 923, "end": 924}, + {"type": "punctuation", "start": 929, "end": 930}, + {"type": "punctuation", "start": 931, "end": 932}, + {"type": "builtin", "start": 936, "end": 943}, + {"type": "punctuation", "start": 943, "end": 944}, + {"type": "function", "start": 944, "end": 949}, {"type": "punctuation", "start": 949, "end": 950}, - {"type": "punctuation", "start": 951, "end": 952}, - {"type": "keyword", "start": 954, "end": 960}, - {"type": "keyword", "start": 961, "end": 966}, - {"type": "operator", "start": 973, "end": 974}, - {"type": "operator", "start": 982, "end": 983}, - {"type": "punctuation", "start": 984, "end": 985}, - {"type": "operator", "start": 989, "end": 990}, - {"type": "string", "start": 991, "end": 998}, - {"type": "punctuation", "start": 998, "end": 999}, - {"type": "operator", "start": 1003, "end": 1004}, - {"type": "number", "start": 1005, "end": 1008}, - {"type": "punctuation", "start": 1008, "end": 1009}, - {"type": "punctuation", "start": 1009, "end": 1010}, - {"type": "keyword", "start": 1012, "end": 1018}, - {"type": "keyword", "start": 1019, "end": 1027}, - {"type": "function", "start": 1028, "end": 1031}, - {"type": "punctuation", "start": 1031, "end": 1032}, - {"type": "operator", "start": 1033, "end": 1034}, - {"type": "builtin", "start": 1035, "end": 1041}, - {"type": "punctuation", "start": 1041, "end": 1042}, - {"type": "operator", "start": 1044, "end": 1045}, - {"type": "builtin", "start": 1046, "end": 1052}, - {"type": "punctuation", "start": 1052, "end": 1053}, - {"type": "operator", "start": 1053, "end": 1054}, - {"type": "builtin", "start": 1055, "end": 1061}, - {"type": "punctuation", "start": 1062, "end": 1063}, - {"type": "keyword", "start": 1065, "end": 1071}, - {"type": "operator", "start": 1074, "end": 1075}, - {"type": "punctuation", "start": 1077, "end": 1078}, - {"type": "punctuation", "start": 1079, "end": 1080}, - {"type": "keyword", "start": 1082, "end": 1088}, - {"type": "keyword", "start": 1089, "end": 1094}, - {"type": "operator", "start": 1100, "end": 1101}, - {"type": "punctuation", "start": 1102, "end": 1103}, - {"type": "operator", "start": 1104, "end": 1105}, - {"type": "builtin", "start": 1106, "end": 1109}, - {"type": "punctuation", "start": 1109, "end": 1110}, - {"type": "operator", "start": 1112, "end": 1113}, - {"type": "builtin", "start": 1114, "end": 1117}, - {"type": "punctuation", "start": 1117, "end": 1118}, - {"type": "operator", "start": 1118, "end": 1119}, - {"type": "builtin", "start": 1120, "end": 1123}, - {"type": "operator", "start": 1124, "end": 1126}, - {"type": "operator", "start": 1129, "end": 1130}, - {"type": "punctuation", "start": 1132, "end": 1133}, - {"type": "comment", "start": 1135, "end": 1157}, - {"type": "keyword", "start": 1158, "end": 1164}, - {"type": "keyword", "start": 1165, "end": 1170}, + {"type": "punctuation", "start": 955, "end": 956}, + {"type": "punctuation", "start": 956, "end": 957}, + {"type": "punctuation", "start": 960, "end": 961}, + {"type": "special_keyword", "start": 962, "end": 969}, + {"type": "punctuation", "start": 970, "end": 971}, + {"type": "builtin", "start": 975, "end": 982}, + {"type": "punctuation", "start": 982, "end": 983}, + {"type": "function", "start": 983, "end": 986}, + {"type": "punctuation", "start": 986, "end": 987}, + {"type": "string", "start": 987, "end": 1002}, + {"type": "punctuation", "start": 1002, "end": 1003}, + {"type": "punctuation", "start": 1003, "end": 1004}, + {"type": "punctuation", "start": 1007, "end": 1008}, + {"type": "punctuation", "start": 1010, "end": 1011}, + {"type": "punctuation", "start": 1012, "end": 1013}, + {"type": "comment", "start": 1015, "end": 1025}, + {"type": "comment", "start": 1027, "end": 1070}, + {"type": "comment", "start": 1072, "end": 1096}, + {"type": "special_keyword", "start": 1098, "end": 1104}, + {"type": "punctuation", "start": 1105, "end": 1106}, + {"type": "punctuation", "start": 1118, "end": 1119}, + {"type": "keyword", "start": 1120, "end": 1124}, + {"type": "class_name", "start": 1125, "end": 1136}, + {"type": "punctuation", "start": 1136, "end": 1137}, + {"type": "keyword", "start": 1138, "end": 1142}, + {"type": "class_name", "start": 1143, "end": 1154}, + {"type": "punctuation", "start": 1154, "end": 1155}, + {"type": "special_keyword", "start": 1156, "end": 1160}, + {"type": "string", "start": 1161, "end": 1180}, + {"type": "punctuation", "start": 1180, "end": 1181}, + {"type": "special_keyword", "start": 1182, "end": 1188}, {"type": "operator", "start": 1189, "end": 1190}, - {"type": "string", "start": 1191, "end": 1220}, + {"type": "special_keyword", "start": 1191, "end": 1193}, + {"type": "constant", "start": 1194, "end": 1195}, + {"type": "special_keyword", "start": 1196, "end": 1200}, + {"type": "string", "start": 1201, "end": 1220}, {"type": "punctuation", "start": 1220, "end": 1221}, - {"type": "keyword", "start": 1222, "end": 1228}, - {"type": "keyword", "start": 1229, "end": 1234}, - {"type": "operator", "start": 1252, "end": 1253}, - {"type": "string", "start": 1254, "end": 1280}, - {"type": "punctuation", "start": 1280, "end": 1281}, - {"type": "keyword", "start": 1282, "end": 1288}, - {"type": "keyword", "start": 1289, "end": 1294}, - {"type": "operator", "start": 1314, "end": 1315}, - {"type": "template_string", "start": 1316, "end": 1333}, - {"type": "template_punctuation", "start": 1316, "end": 1317}, - {"type": "string", "start": 1317, "end": 1324}, - {"type": "interpolation", "start": 1324, "end": 1332}, - {"type": "interpolation_punctuation", "start": 1324, "end": 1326}, - {"type": "number", "start": 1326, "end": 1327}, - {"type": "operator", "start": 1328, "end": 1329}, - {"type": "number", "start": 1330, "end": 1331}, - {"type": "interpolation_punctuation", "start": 1331, "end": 1332}, - {"type": "template_punctuation", "start": 1332, "end": 1333}, - {"type": "punctuation", "start": 1333, "end": 1334}, - {"type": "comment", "start": 1336, "end": 1368}, - {"type": "keyword", "start": 1369, "end": 1375}, + {"type": "special_keyword", "start": 1236, "end": 1238}, + {"type": "builtin", "start": 1239, "end": 1246}, + {"type": "special_keyword", "start": 1247, "end": 1249}, + {"type": "special_keyword", "start": 1262, "end": 1264}, + {"type": "builtin", "start": 1265, "end": 1268}, + {"type": "special_keyword", "start": 1269, "end": 1271}, + {"type": "punctuation", "start": 1283, "end": 1284}, + {"type": "special_keyword", "start": 1286, "end": 1292}, + {"type": "punctuation", "start": 1293, "end": 1294}, + {"type": "punctuation", "start": 1295, "end": 1296}, + {"type": "constant", "start": 1297, "end": 1298}, + {"type": "punctuation", "start": 1298, "end": 1299}, + {"type": "punctuation", "start": 1301, "end": 1302}, + {"type": "punctuation", "start": 1304, "end": 1305}, + {"type": "constant", "start": 1306, "end": 1307}, + {"type": "punctuation", "start": 1307, "end": 1308}, + {"type": "punctuation", "start": 1308, "end": 1309}, + {"type": "special_keyword", "start": 1311, "end": 1317}, + {"type": "keyword", "start": 1318, "end": 1327}, + {"type": "class_name", "start": 1328, "end": 1334}, + {"type": "punctuation", "start": 1335, "end": 1336}, + {"type": "operator", "start": 1342, "end": 1343}, + {"type": "builtin", "start": 1344, "end": 1350}, + {"type": "punctuation", "start": 1350, "end": 1351}, + {"type": "operator", "start": 1356, "end": 1357}, + {"type": "builtin", "start": 1358, "end": 1364}, + {"type": "punctuation", "start": 1364, "end": 1365}, + {"type": "punctuation", "start": 1366, "end": 1367}, + {"type": "special_keyword", "start": 1369, "end": 1375}, {"type": "keyword", "start": 1376, "end": 1381}, {"type": "operator", "start": 1388, "end": 1389}, - {"type": "regex", "start": 1390, "end": 1399}, - {"type": "regex_delimiter", "start": 1390, "end": 1391}, - {"type": "regex_source", "start": 1391, "end": 1397}, - {"type": "regex_delimiter", "start": 1397, "end": 1398}, - {"type": "regex_flags", "start": 1398, "end": 1399}, + {"type": "operator", "start": 1397, "end": 1398}, {"type": "punctuation", "start": 1399, "end": 1400}, - {"type": "keyword", "start": 1401, "end": 1407}, - {"type": "keyword", "start": 1408, "end": 1413}, - {"type": "operator", "start": 1428, "end": 1429}, - {"type": "regex", "start": 1430, "end": 1462}, - {"type": "regex_delimiter", "start": 1430, "end": 1431}, - {"type": "regex_source", "start": 1431, "end": 1461}, - {"type": "regex_delimiter", "start": 1461, "end": 1462}, - {"type": "punctuation", "start": 1462, "end": 1463}, - {"type": "comment", "start": 1465, "end": 1521}, - {"type": "comment", "start": 1522, "end": 1573} + {"type": "operator", "start": 1404, "end": 1405}, + {"type": "string", "start": 1406, "end": 1413}, + {"type": "punctuation", "start": 1413, "end": 1414}, + {"type": "operator", "start": 1418, "end": 1419}, + {"type": "number", "start": 1420, "end": 1423}, + {"type": "punctuation", "start": 1423, "end": 1424}, + {"type": "punctuation", "start": 1424, "end": 1425}, + {"type": "special_keyword", "start": 1427, "end": 1433}, + {"type": "keyword", "start": 1434, "end": 1442}, + {"type": "function", "start": 1443, "end": 1446}, + {"type": "punctuation", "start": 1446, "end": 1447}, + {"type": "operator", "start": 1448, "end": 1449}, + {"type": "builtin", "start": 1450, "end": 1456}, + {"type": "punctuation", "start": 1456, "end": 1457}, + {"type": "operator", "start": 1459, "end": 1460}, + {"type": "builtin", "start": 1461, "end": 1467}, + {"type": "punctuation", "start": 1467, "end": 1468}, + {"type": "operator", "start": 1468, "end": 1469}, + {"type": "builtin", "start": 1470, "end": 1476}, + {"type": "punctuation", "start": 1477, "end": 1478}, + {"type": "special_keyword", "start": 1480, "end": 1486}, + {"type": "operator", "start": 1489, "end": 1490}, + {"type": "punctuation", "start": 1492, "end": 1493}, + {"type": "punctuation", "start": 1494, "end": 1495}, + {"type": "special_keyword", "start": 1497, "end": 1503}, + {"type": "keyword", "start": 1504, "end": 1509}, + {"type": "operator", "start": 1515, "end": 1516}, + {"type": "punctuation", "start": 1517, "end": 1518}, + {"type": "operator", "start": 1519, "end": 1520}, + {"type": "builtin", "start": 1521, "end": 1524}, + {"type": "punctuation", "start": 1524, "end": 1525}, + {"type": "operator", "start": 1527, "end": 1528}, + {"type": "builtin", "start": 1529, "end": 1532}, + {"type": "punctuation", "start": 1532, "end": 1533}, + {"type": "operator", "start": 1533, "end": 1534}, + {"type": "builtin", "start": 1535, "end": 1538}, + {"type": "operator", "start": 1539, "end": 1541}, + {"type": "operator", "start": 1544, "end": 1545}, + {"type": "punctuation", "start": 1547, "end": 1548}, + {"type": "comment", "start": 1550, "end": 1572}, + {"type": "special_keyword", "start": 1573, "end": 1579}, + {"type": "keyword", "start": 1580, "end": 1585}, + {"type": "operator", "start": 1604, "end": 1605}, + {"type": "string", "start": 1606, "end": 1635}, + {"type": "punctuation", "start": 1635, "end": 1636}, + {"type": "special_keyword", "start": 1637, "end": 1643}, + {"type": "keyword", "start": 1644, "end": 1649}, + {"type": "operator", "start": 1667, "end": 1668}, + {"type": "string", "start": 1669, "end": 1695}, + {"type": "punctuation", "start": 1695, "end": 1696}, + {"type": "special_keyword", "start": 1697, "end": 1703}, + {"type": "keyword", "start": 1704, "end": 1709}, + {"type": "operator", "start": 1729, "end": 1730}, + {"type": "template_string", "start": 1731, "end": 1748}, + {"type": "template_punctuation", "start": 1731, "end": 1732}, + {"type": "string", "start": 1732, "end": 1739}, + {"type": "interpolation", "start": 1739, "end": 1747}, + {"type": "interpolation_punctuation", "start": 1739, "end": 1741}, + {"type": "number", "start": 1741, "end": 1742}, + {"type": "operator", "start": 1743, "end": 1744}, + {"type": "number", "start": 1745, "end": 1746}, + {"type": "interpolation_punctuation", "start": 1746, "end": 1747}, + {"type": "template_punctuation", "start": 1747, "end": 1748}, + {"type": "punctuation", "start": 1748, "end": 1749}, + {"type": "comment", "start": 1751, "end": 1783}, + {"type": "special_keyword", "start": 1784, "end": 1790}, + {"type": "keyword", "start": 1791, "end": 1796}, + {"type": "operator", "start": 1803, "end": 1804}, + {"type": "regex", "start": 1805, "end": 1814}, + {"type": "regex_delimiter", "start": 1805, "end": 1806}, + {"type": "regex_source", "start": 1806, "end": 1812}, + {"type": "regex_delimiter", "start": 1812, "end": 1813}, + {"type": "regex_flags", "start": 1813, "end": 1814}, + {"type": "punctuation", "start": 1814, "end": 1815}, + {"type": "special_keyword", "start": 1816, "end": 1822}, + {"type": "keyword", "start": 1823, "end": 1828}, + {"type": "operator", "start": 1843, "end": 1844}, + {"type": "regex", "start": 1845, "end": 1877}, + {"type": "regex_delimiter", "start": 1845, "end": 1846}, + {"type": "regex_source", "start": 1846, "end": 1876}, + {"type": "regex_delimiter", "start": 1876, "end": 1877}, + {"type": "punctuation", "start": 1877, "end": 1878}, + {"type": "comment", "start": 1880, "end": 1936}, + {"type": "comment", "start": 1937, "end": 1988} ], - "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tfor (const c2 of this.d1) {\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected protected_method(): void {\n\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\twhile (i < 3) i++;\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/fixtures/generated/ts/ts_complex.txt index 730c4b06..88a20055 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/fixtures/generated/ts/ts_complex.txt @@ -11,7 +11,7 @@ 38-39 operator = 40-44 boolean true 44-45 punctuation ; - 47-53 keyword export + 47-53 special_keyword export 54-58 keyword type 59-68 class_name Some_Type 69-70 operator = @@ -56,7 +56,7 @@ 213-214 operator : 215-221 builtin string 222-223 punctuation { - 226-232 keyword return + 226-232 special_keyword return 233-252 template_string `Hello, ${this.d1}` 233-234 template_punctuation ` 234-241 string Hello, @@ -76,231 +76,339 @@ 286-288 operator => 289-290 punctuation { 293-302 comment /* ... */ - 305-308 keyword for - 309-310 punctuation ( - 310-315 keyword const - 319-321 keyword of - 322-326 keyword this - 326-327 punctuation . - 329-330 punctuation ) - 331-332 punctuation { - 336-340 keyword this - 340-341 punctuation . - 341-356 function #private_method - 356-357 punctuation ( - 358-359 punctuation , - 362-363 punctuation ) - 363-364 punctuation ; - 367-368 punctuation } - 371-377 comment // foo - 379-380 punctuation } - 380-381 punctuation ; - 384-399 function #private_method - 399-400 punctuation ( - 402-403 operator : - 404-410 builtin number - 410-411 punctuation , - 414-415 operator : - 416-419 builtin any - 419-420 punctuation ) - 421-422 punctuation { - 425-430 keyword throw - 431-434 keyword new - 435-440 class_name Error - 440-441 punctuation ( - 441-488 template_string `${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` - 441-442 template_punctuation ` - 442-452 interpolation ${this.d1} - 442-444 interpolation_punctuation ${ - 444-448 keyword this - 448-449 punctuation . - 451-452 interpolation_punctuation } - 452-474 string \n\t\t\tmultiline\n\t\t\tetc - 474-484 interpolation ${a2 + c2} - 474-476 interpolation_punctuation ${ - 479-480 operator + - 483-484 interpolation_punctuation } - 484-487 string \n\t\t - 487-488 template_punctuation ` - 488-489 punctuation ) - 489-490 punctuation ; - 492-493 punctuation } - 496-505 keyword protected - 506-522 function protected_method + 305-308 keyword let + 311-312 operator = + 313-314 number 0 + 314-315 punctuation ; + 318-323 special_keyword while + 324-325 punctuation ( + 327-328 operator < + 329-330 number 3 + 330-331 punctuation ) + 333-335 operator ++ + 335-336 punctuation ; + 339-342 special_keyword for + 343-344 punctuation ( + 344-349 keyword const + 353-355 keyword of + 356-360 keyword this + 360-361 punctuation . + 363-364 punctuation ) + 365-366 punctuation { + 370-372 special_keyword if + 373-374 punctuation ( + 377-380 operator === + 381-384 string 'd' + 384-385 punctuation ) + 386-394 special_keyword continue + 394-395 punctuation ; + 399-401 special_keyword if + 402-403 punctuation ( + 403-404 operator ! + 406-407 punctuation ) + 408-413 special_keyword break + 413-414 punctuation ; + 418-422 keyword this + 422-423 punctuation . + 423-438 function #private_method + 438-439 punctuation ( + 440-441 punctuation , + 444-445 punctuation ) + 445-446 punctuation ; + 449-450 punctuation } + 453-459 comment // foo + 461-462 punctuation } + 462-463 punctuation ; + 466-481 function #private_method + 481-482 punctuation ( + 484-485 operator : + 486-492 builtin number + 492-493 punctuation , + 496-497 operator : + 498-501 builtin any + 501-502 punctuation ) + 503-504 punctuation { + 507-512 special_keyword throw + 513-516 keyword new + 517-522 class_name Error 522-523 punctuation ( - 523-524 punctuation ) - 524-525 operator : - 526-530 keyword void - 531-532 punctuation { - 535-542 builtin console - 542-543 punctuation . - 543-546 function log - 546-547 punctuation ( - 547-550 keyword new - 551-555 class_name Date - 555-556 punctuation ( - 556-557 punctuation ) - 557-558 punctuation ) - 558-559 punctuation ; - 560-593 comment // eslint-disable-line no-console - 595-596 punctuation } - 597-598 punctuation } - 600-610 comment // comment - 612-655 comment /*\nother comment\n\nconst comment = false;\n*/ - 657-681 comment /**\n * JSDoc comment\n */ - 683-689 keyword import - 690-691 punctuation { - 703-704 punctuation , - 705-709 keyword type - 710-721 class_name Code_Sample - 721-722 punctuation , - 723-727 keyword type - 728-739 class_name Sample_Lang - 739-740 punctuation } - 741-745 keyword from - 746-765 string '../code_sample.js' - 765-766 punctuation ; - 767-773 keyword import - 774-775 operator * - 776-778 keyword as - 779-780 constant A - 781-785 keyword from - 786-805 string '../code_sample.js' - 805-806 punctuation ; - 821-823 keyword as - 824-831 builtin unknown - 832-834 keyword as - 847-849 keyword as - 850-853 builtin any - 854-856 keyword as - 868-869 punctuation ; - 871-877 keyword export - 878-879 punctuation { - 880-881 punctuation , - 882-883 constant A - 883-884 punctuation , - 886-887 punctuation , - 889-890 punctuation , - 891-892 constant D - 892-893 punctuation } - 893-894 punctuation ; - 896-902 keyword export - 903-912 keyword interface - 913-919 class_name Some_E - 920-921 punctuation { - 927-928 operator : - 929-935 builtin string - 935-936 punctuation ; - 941-942 operator : - 943-949 builtin number - 949-950 punctuation ; - 951-952 punctuation } - 954-960 keyword export - 961-966 keyword const - 973-974 operator : - 982-983 operator = - 984-985 punctuation { - 989-990 operator : - 991-998 string 'A. H.' - 998-999 punctuation , -1003-1004 operator : -1005-1008 number 100 -1008-1009 punctuation } -1009-1010 punctuation ; -1012-1018 keyword export -1019-1027 keyword function -1028-1031 function add -1031-1032 punctuation ( -1033-1034 operator : -1035-1041 builtin number -1041-1042 punctuation , -1044-1045 operator : -1046-1052 builtin number -1052-1053 punctuation ) -1053-1054 operator : -1055-1061 builtin number -1062-1063 punctuation { -1065-1071 keyword return -1074-1075 operator + -1077-1078 punctuation ; -1079-1080 punctuation } -1082-1088 keyword export -1089-1094 keyword const -1100-1101 operator = -1102-1103 punctuation ( -1104-1105 operator : -1106-1109 builtin any -1109-1110 punctuation , -1112-1113 operator : -1114-1117 builtin any -1117-1118 punctuation ) -1118-1119 operator : -1120-1123 builtin any -1124-1126 operator => -1129-1130 operator + -1132-1133 punctuation ; -1135-1157 comment // boundary test cases -1158-1164 keyword export -1165-1170 keyword const -1189-1190 operator = -1191-1220 string 'const class function string' + 523-570 template_string `${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` + 523-524 template_punctuation ` + 524-534 interpolation ${this.d1} + 524-526 interpolation_punctuation ${ + 526-530 keyword this + 530-531 punctuation . + 533-534 interpolation_punctuation } + 534-556 string \n\t\t\tmultiline\n\t\t\tetc + 556-566 interpolation ${a2 + c2} + 556-558 interpolation_punctuation ${ + 561-562 operator + + 565-566 interpolation_punctuation } + 566-569 string \n\t\t + 569-570 template_punctuation ` + 570-571 punctuation ) + 571-572 punctuation ; + 574-575 punctuation } + 578-587 keyword protected + 588-593 keyword async + 594-610 function protected_method + 610-611 punctuation ( + 611-612 punctuation ) + 612-613 operator : + 614-621 builtin Promise + 621-622 operator < + 622-626 keyword void + 626-627 operator > + 628-629 punctuation { + 632-635 special_keyword try + 636-637 punctuation { + 641-646 special_keyword await + 647-650 keyword new + 651-658 class_name Promise + 651-658 builtin Promise + 658-659 punctuation ( + 659-660 punctuation ( + 667-668 punctuation ) + 669-671 operator => + 672-682 function setTimeout + 682-683 punctuation ( + 690-691 punctuation , + 692-695 number 100 + 695-696 punctuation ) + 696-697 punctuation ) + 697-698 punctuation ; + 702-704 special_keyword if + 705-706 punctuation ( + 710-711 punctuation . + 711-717 function random + 717-718 punctuation ( + 718-719 punctuation ) + 720-721 operator > + 722-725 number 0.5 + 725-726 punctuation ) + 727-728 punctuation { + 733-740 builtin console + 740-741 punctuation . + 741-744 function log + 744-745 punctuation ( + 745-748 keyword new + 749-753 class_name Date + 753-754 punctuation ( + 754-755 punctuation ) + 755-756 punctuation ) + 756-757 punctuation ; + 758-791 comment // eslint-disable-line no-console + 795-796 punctuation } + 797-801 special_keyword else + 802-804 special_keyword if + 805-806 punctuation ( + 810-811 punctuation . + 811-817 function random + 817-818 punctuation ( + 818-819 punctuation ) + 820-821 operator > + 822-825 number 0.2 + 825-826 punctuation ) + 827-828 punctuation { + 833-840 builtin console + 840-841 punctuation . + 841-844 function log + 844-845 punctuation ( + 845-861 string 'else if branch' + 861-862 punctuation ) + 862-863 punctuation ; + 867-868 punctuation } + 869-873 special_keyword else + 874-875 punctuation { + 880-887 builtin console + 887-888 punctuation . + 888-891 function log + 891-892 punctuation ( + 892-905 string 'else branch' + 905-906 punctuation ) + 906-907 punctuation ; + 911-912 punctuation } + 915-916 punctuation } + 917-922 special_keyword catch + 923-924 punctuation ( + 929-930 punctuation ) + 931-932 punctuation { + 936-943 builtin console + 943-944 punctuation . + 944-949 function error + 949-950 punctuation ( + 955-956 punctuation ) + 956-957 punctuation ; + 960-961 punctuation } + 962-969 special_keyword finally + 970-971 punctuation { + 975-982 builtin console + 982-983 punctuation . + 983-986 function log + 986-987 punctuation ( + 987-1002 string 'finally block' +1002-1003 punctuation ) +1003-1004 punctuation ; +1007-1008 punctuation } +1010-1011 punctuation } +1012-1013 punctuation } +1015-1025 comment // comment +1027-1070 comment /*\nother comment\n\nconst comment = false;\n*/ +1072-1096 comment /**\n * JSDoc comment\n */ +1098-1104 special_keyword import +1105-1106 punctuation { +1118-1119 punctuation , +1120-1124 keyword type +1125-1136 class_name Code_Sample +1136-1137 punctuation , +1138-1142 keyword type +1143-1154 class_name Sample_Lang +1154-1155 punctuation } +1156-1160 special_keyword from +1161-1180 string '../code_sample.js' +1180-1181 punctuation ; +1182-1188 special_keyword import +1189-1190 operator * +1191-1193 special_keyword as +1194-1195 constant A +1196-1200 special_keyword from +1201-1220 string '../code_sample.js' 1220-1221 punctuation ; -1222-1228 keyword export -1229-1234 keyword const -1252-1253 operator = -1254-1280 string '// this is not a comment' -1280-1281 punctuation ; -1282-1288 keyword export -1289-1294 keyword const -1314-1315 operator = -1316-1333 template_string `Value: ${1 + 2}` -1316-1317 template_punctuation ` -1317-1324 string Value: -1324-1332 interpolation ${1 + 2} -1324-1326 interpolation_punctuation ${ -1326-1327 number 1 -1328-1329 operator + -1330-1331 number 2 -1331-1332 interpolation_punctuation } -1332-1333 template_punctuation ` -1333-1334 punctuation ; -1336-1368 comment // regex that looks like comment -1369-1375 keyword export +1236-1238 special_keyword as +1239-1246 builtin unknown +1247-1249 special_keyword as +1262-1264 special_keyword as +1265-1268 builtin any +1269-1271 special_keyword as +1283-1284 punctuation ; +1286-1292 special_keyword export +1293-1294 punctuation { +1295-1296 punctuation , +1297-1298 constant A +1298-1299 punctuation , +1301-1302 punctuation , +1304-1305 punctuation , +1306-1307 constant D +1307-1308 punctuation } +1308-1309 punctuation ; +1311-1317 special_keyword export +1318-1327 keyword interface +1328-1334 class_name Some_E +1335-1336 punctuation { +1342-1343 operator : +1344-1350 builtin string +1350-1351 punctuation ; +1356-1357 operator : +1358-1364 builtin number +1364-1365 punctuation ; +1366-1367 punctuation } +1369-1375 special_keyword export 1376-1381 keyword const -1388-1389 operator = -1390-1399 regex /\/\/.*/g -1390-1391 regex_delimiter / -1391-1397 regex_source \/\/.* -1397-1398 regex_delimiter / -1398-1399 regex_flags g -1399-1400 punctuation ; -1401-1407 keyword export -1408-1413 keyword const -1428-1429 operator = -1430-1462 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ -1430-1431 regex_delimiter / -1431-1461 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ -1461-1462 regex_delimiter / -1462-1463 punctuation ; -1465-1521 comment // string in comment should not be highlighted as string -1522-1573 comment // const commented = "this string is in a comment"; +1388-1389 operator : +1397-1398 operator = +1399-1400 punctuation { +1404-1405 operator : +1406-1413 string 'A. H.' +1413-1414 punctuation , +1418-1419 operator : +1420-1423 number 100 +1423-1424 punctuation } +1424-1425 punctuation ; +1427-1433 special_keyword export +1434-1442 keyword function +1443-1446 function add +1446-1447 punctuation ( +1448-1449 operator : +1450-1456 builtin number +1456-1457 punctuation , +1459-1460 operator : +1461-1467 builtin number +1467-1468 punctuation ) +1468-1469 operator : +1470-1476 builtin number +1477-1478 punctuation { +1480-1486 special_keyword return +1489-1490 operator + +1492-1493 punctuation ; +1494-1495 punctuation } +1497-1503 special_keyword export +1504-1509 keyword const +1515-1516 operator = +1517-1518 punctuation ( +1519-1520 operator : +1521-1524 builtin any +1524-1525 punctuation , +1527-1528 operator : +1529-1532 builtin any +1532-1533 punctuation ) +1533-1534 operator : +1535-1538 builtin any +1539-1541 operator => +1544-1545 operator + +1547-1548 punctuation ; +1550-1572 comment // boundary test cases +1573-1579 special_keyword export +1580-1585 keyword const +1604-1605 operator = +1606-1635 string 'const class function string' +1635-1636 punctuation ; +1637-1643 special_keyword export +1644-1649 keyword const +1667-1668 operator = +1669-1695 string '// this is not a comment' +1695-1696 punctuation ; +1697-1703 special_keyword export +1704-1709 keyword const +1729-1730 operator = +1731-1748 template_string `Value: ${1 + 2}` +1731-1732 template_punctuation ` +1732-1739 string Value: +1739-1747 interpolation ${1 + 2} +1739-1741 interpolation_punctuation ${ +1741-1742 number 1 +1743-1744 operator + +1745-1746 number 2 +1746-1747 interpolation_punctuation } +1747-1748 template_punctuation ` +1748-1749 punctuation ; +1751-1783 comment // regex that looks like comment +1784-1790 special_keyword export +1791-1796 keyword const +1803-1804 operator = +1805-1814 regex /\/\/.*/g +1805-1806 regex_delimiter / +1806-1812 regex_source \/\/.* +1812-1813 regex_delimiter / +1813-1814 regex_flags g +1814-1815 punctuation ; +1816-1822 special_keyword export +1823-1828 keyword const +1843-1844 operator = +1845-1877 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ +1845-1846 regex_delimiter / +1846-1876 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +1876-1877 regex_delimiter / +1877-1878 punctuation ; +1880-1936 comment // string in comment should not be highlighted as string +1937-1988 comment // const commented = "this string is in a comment"; === STATS === -Total tokens: 285 -Sample length: 1574 characters +Total tokens: 392 +Sample length: 1989 characters Token types: - punctuation: 94 - keyword: 53 - operator: 43 - builtin: 17 - string: 12 + punctuation: 152 + operator: 53 + special_keyword: 37 + keyword: 32 + builtin: 23 + string: 16 + function: 15 + number: 10 comment: 10 - function: 8 + class_name: 8 interpolation_punctuation: 8 - class_name: 7 template_punctuation: 6 - number: 5 constant: 4 interpolation: 4 regex_delimiter: 4 diff --git a/src/lib/grammar_js.ts b/src/lib/grammar_js.ts index 18ee65ff..6cb76787 100644 --- a/src/lib/grammar_js.ts +++ b/src/lib/grammar_js.ts @@ -22,13 +22,9 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { }, ], keyword: [ - { - pattern: /((?:^|\})\s*)catch\b/, - lookbehind: true, - }, { pattern: - /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/, + /(^|[^.]|\.\.\.\s*)\b(?:assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|class|const|debugger|default|delete|enum|extends|function|(?:get|set)(?=\s*(?:[#[$\w\xA0-\uFFFF]|$))|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with|yield)\b/, lookbehind: true, }, ], @@ -69,6 +65,10 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { (grammar_js as any).class_name[0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/; + syntax_styler.grammar_insert_before('js', 'function', { + special_keyword: /\b(?:as|await|break|case|catch|continue|do|else|export|finally|for|from|if|import|return|switch|throw|try|while)\b/, + }); + syntax_styler.grammar_insert_before('js', 'keyword', { regex: { pattern: RegExp( diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index ecd81466..0bd5bdc3 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -109,7 +109,11 @@ class D { instance_method = (): void => { /* ... */ + let i = 0; + while (i < 3) i++; for (const c2 of this.d1) { + if (c2 === 'd') continue; + if (!c2) break; this.#private_method(a, c2); } // foo @@ -122,8 +126,21 @@ class D { \`); } - protected protected_method(): void { - console.log(new Date()); // eslint-disable-line no-console + protected async protected_method(): Promise { + try { + await new Promise((resolve) => setTimeout(resolve, 100)); + if (Math.random() > 0.5) { + console.log(new Date()); // eslint-disable-line no-console + } else if (Math.random() > 0.2) { + console.log('else if branch'); + } else { + console.log('else branch'); + } + } catch (error) { + console.error(error); + } finally { + console.log('finally block'); + } } } diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index 00123664..3e234b71 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -21,7 +21,11 @@ class D { instance_method = (): void => { /* ... */ + let i = 0; + while (i < 3) i++; for (const c2 of this.d1) { + if (c2 === 'd') continue; + if (!c2) break; this.#private_method(a, c2); } // foo @@ -34,8 +38,21 @@ class D { `); } - protected protected_method(): void { - console.log(new Date()); // eslint-disable-line no-console + protected async protected_method(): Promise { + try { + await new Promise((resolve) => setTimeout(resolve, 100)); + if (Math.random() > 0.5) { + console.log(new Date()); // eslint-disable-line no-console + } else if (Math.random() > 0.2) { + console.log('else if branch'); + } else { + console.log('else branch'); + } + } catch (error) { + console.error(error); + } finally { + console.log('finally block'); + } } } diff --git a/src/lib/theme.css b/src/lib/theme.css index f4a1d212..3a861baa 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -34,7 +34,6 @@ color: var(--color_a_5); } -/* TODO keywords like `throw`/`return`/`export` are color_g */ .token.keyword, ::highlight(keyword), .token.null, @@ -46,6 +45,11 @@ color: var(--color_a_5); } +.token.special_keyword, +::highlight(special_keyword) { + color: var(--color_g_5); +} + .token.comment, ::highlight(comment), .token.attr_value, From 4b9df1eed10c5e4c8c63cbb1197d8ed580ad9984 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 07:57:45 -0400 Subject: [PATCH 12/49] wip --- src/lib/grammar_js.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/grammar_js.ts b/src/lib/grammar_js.ts index 6cb76787..3c5f393b 100644 --- a/src/lib/grammar_js.ts +++ b/src/lib/grammar_js.ts @@ -66,7 +66,8 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/; syntax_styler.grammar_insert_before('js', 'function', { - special_keyword: /\b(?:as|await|break|case|catch|continue|do|else|export|finally|for|from|if|import|return|switch|throw|try|while)\b/, + special_keyword: + /\b(?:as|await|break|case|catch|continue|do|else|export|finally|for|from|if|import|return|switch|throw|try|while)\b/, }); syntax_styler.grammar_insert_before('js', 'keyword', { @@ -128,6 +129,7 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { }, { pattern: + // TODO BLOCK fix with special_keyword /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, lookbehind: true, inside: grammar_js, From f2252d87e551b27c3e519a9b23e24c588cb5775d Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 11:49:54 -0400 Subject: [PATCH 13/49] wip --- fixtures/generated/svelte/svelte_complex.json | 3 ++- fixtures/generated/svelte/svelte_complex.txt | 5 +++-- fixtures/generated/ts/ts_complex.json | 4 +++- fixtures/generated/ts/ts_complex.txt | 5 ++++- src/lib/grammar_js.ts | 1 + src/lib/grammar_ts.ts | 6 ++++++ src/lib/highlight_manager.ts | 16 ++++++++++++++++ src/lib/theme.css | 6 +----- 8 files changed, 36 insertions(+), 10 deletions(-) diff --git a/fixtures/generated/svelte/svelte_complex.json b/fixtures/generated/svelte/svelte_complex.json index 82f49967..054751a2 100644 --- a/fixtures/generated/svelte/svelte_complex.json +++ b/fixtures/generated/svelte/svelte_complex.json @@ -267,6 +267,7 @@ {"type": "punctuation", "start": 1212, "end": 1213}, {"type": "special_keyword", "start": 1216, "end": 1222}, {"type": "keyword", "start": 1223, "end": 1228}, + {"type": "function_variable", "start": 1229, "end": 1233}, {"type": "operator", "start": 1234, "end": 1235}, {"type": "punctuation", "start": 1236, "end": 1237}, {"type": "operator", "start": 1238, "end": 1239}, @@ -583,5 +584,5 @@ {"type": "punctuation", "start": 2324, "end": 2326}, {"type": "punctuation", "start": 2331, "end": 2332} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/fixtures/generated/svelte/svelte_complex.txt b/fixtures/generated/svelte/svelte_complex.txt index 324acaa9..0f0f3108 100644 --- a/fixtures/generated/svelte/svelte_complex.txt +++ b/fixtures/generated/svelte/svelte_complex.txt @@ -260,6 +260,7 @@ 1212-1213 punctuation } 1216-1222 special_keyword export 1223-1228 keyword const +1229-1233 function_variable plus 1234-1235 operator = 1236-1237 punctuation ( 1238-1239 operator : @@ -577,7 +578,7 @@ 2331-2332 punctuation > === STATS === -Total tokens: 576 +Total tokens: 577 Sample length: 2333 characters Token types: @@ -604,8 +605,8 @@ Token types: script: 2 template_string: 2 interpolation: 2 + function_variable: 2 each: 2 - function_variable: 1 decorator: 1 at: 1 doctype: 1 diff --git a/fixtures/generated/ts/ts_complex.json b/fixtures/generated/ts/ts_complex.json index d34cc0ac..1f6ed567 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/fixtures/generated/ts/ts_complex.json @@ -75,6 +75,7 @@ {"type": "template_punctuation", "start": 251, "end": 252}, {"type": "punctuation", "start": 252, "end": 253}, {"type": "punctuation", "start": 255, "end": 256}, + {"type": "function_variable", "start": 259, "end": 274}, {"type": "operator", "start": 275, "end": 276}, {"type": "punctuation", "start": 277, "end": 278}, {"type": "punctuation", "start": 278, "end": 279}, @@ -340,6 +341,7 @@ {"type": "punctuation", "start": 1494, "end": 1495}, {"type": "special_keyword", "start": 1497, "end": 1503}, {"type": "keyword", "start": 1504, "end": 1509}, + {"type": "function_variable", "start": 1510, "end": 1514}, {"type": "operator", "start": 1515, "end": 1516}, {"type": "punctuation", "start": 1517, "end": 1518}, {"type": "operator", "start": 1519, "end": 1520}, @@ -399,5 +401,5 @@ {"type": "comment", "start": 1880, "end": 1936}, {"type": "comment", "start": 1937, "end": 1988} ], - "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\twhile (i < 3) i++;\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\twhile (i < 3) i++;\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/fixtures/generated/ts/ts_complex.txt index 88a20055..9467fe0d 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/fixtures/generated/ts/ts_complex.txt @@ -68,6 +68,7 @@ 251-252 template_punctuation ` 252-253 punctuation ; 255-256 punctuation } + 259-274 function_variable instance_method 275-276 operator = 277-278 punctuation ( 278-279 punctuation ) @@ -333,6 +334,7 @@ 1494-1495 punctuation } 1497-1503 special_keyword export 1504-1509 keyword const +1510-1514 function_variable plus 1515-1516 operator = 1517-1518 punctuation ( 1519-1520 operator : @@ -393,7 +395,7 @@ 1937-1988 comment // const commented = "this string is in a comment"; === STATS === -Total tokens: 392 +Total tokens: 394 Sample length: 1989 characters Token types: @@ -414,6 +416,7 @@ Token types: regex_delimiter: 4 template_string: 3 boolean: 2 + function_variable: 2 regex: 2 regex_source: 2 regex_flags: 1 diff --git a/src/lib/grammar_js.ts b/src/lib/grammar_js.ts index 3c5f393b..9a2808a3 100644 --- a/src/lib/grammar_js.ts +++ b/src/lib/grammar_js.ts @@ -103,6 +103,7 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { regex_flags: /^[a-z]+$/, }, }, + // Arrow function and function expression variable names // This must be declared before keyword because we use "function" inside the look-forward function_variable: { pattern: diff --git a/src/lib/grammar_ts.ts b/src/lib/grammar_ts.ts index ffe413db..a3632d67 100644 --- a/src/lib/grammar_ts.ts +++ b/src/lib/grammar_ts.ts @@ -19,6 +19,12 @@ export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { }, builtin: /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/, + // TypeScript arrow functions with type annotations + function_variable: { + pattern: + /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)(?:\s*:\s*(?:(?!=>).)+)?\s*=>|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*=>)))/, + alias: 'function', + }, }); // The keywords TypeScript adds to JS diff --git a/src/lib/highlight_manager.ts b/src/lib/highlight_manager.ts index 6cc092f2..3e40a2db 100644 --- a/src/lib/highlight_manager.ts +++ b/src/lib/highlight_manager.ts @@ -114,11 +114,27 @@ export class Highlight_Manager { range.setStart(text_node, pos); range.setEnd(text_node, end_pos); + // Add range for the token type const type = token.type; if (!ranges_by_type.has(type)) { ranges_by_type.set(type, []); } ranges_by_type.get(type)!.push(range); + + // Also add range for any aliases + if (token.alias) { + const aliases = Array.isArray(token.alias) ? token.alias : [token.alias]; + for (const alias of aliases) { + if (!ranges_by_type.has(alias)) { + ranges_by_type.set(alias, []); + } + // Create a new range for each alias (ranges can't be reused) + const aliasRange = new Range(); + aliasRange.setStart(text_node, pos); + aliasRange.setEnd(text_node, end_pos); + ranges_by_type.get(alias)!.push(aliasRange); + } + } } catch (e) { throw new Error(`Failed to create range for ${token.type}: ${e}`); } diff --git a/src/lib/theme.css b/src/lib/theme.css index 3a861baa..d1de6d39 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -180,11 +180,7 @@ ::highlight(property_string) { color: var(--color_a_5); } - -.token.function_variable, -::highlight(function_variable) { - color: var(--color_d_5); -} */ + */ /* Additional tokens */ /* From 5b9f1998e1f04bc73c588ffccdc558b0e6ff8dc7 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 11:58:43 -0400 Subject: [PATCH 14/49] wip --- fixtures/generated/ts/ts_complex.json | 875 ++++++++++++++---------- fixtures/generated/ts/ts_complex.txt | 927 +++++++++++++++----------- src/lib/samples/all.ts | 62 +- src/lib/samples/sample_complex.ts | 62 +- 4 files changed, 1165 insertions(+), 761 deletions(-) diff --git a/fixtures/generated/ts/ts_complex.json b/fixtures/generated/ts/ts_complex.json index 1f6ed567..cd05f3e1 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/fixtures/generated/ts/ts_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "ts", "variant": "complex", - "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\twhile (i < 3) i++;\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", + "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", "filepath": "src/lib/samples/sample_complex.ts" }, "tokens": [ @@ -28,378 +28,533 @@ {"type": "operator", "start": 79, "end": 80}, {"type": "boolean", "start": 81, "end": 85}, {"type": "punctuation", "start": 85, "end": 86}, - {"type": "keyword", "start": 88, "end": 93}, - {"type": "class_name", "start": 94, "end": 95}, - {"type": "constant", "start": 94, "end": 95}, - {"type": "punctuation", "start": 96, "end": 97}, - {"type": "operator", "start": 101, "end": 102}, - {"type": "builtin", "start": 103, "end": 109}, - {"type": "operator", "start": 110, "end": 111}, - {"type": "string", "start": 112, "end": 115}, - {"type": "punctuation", "start": 115, "end": 116}, - {"type": "operator", "start": 120, "end": 121}, - {"type": "builtin", "start": 122, "end": 128}, - {"type": "punctuation", "start": 128, "end": 129}, - {"type": "operator", "start": 134, "end": 135}, - {"type": "function", "start": 136, "end": 142}, - {"type": "punctuation", "start": 142, "end": 143}, - {"type": "keyword", "start": 143, "end": 147}, + {"type": "keyword", "start": 88, "end": 95}, + {"type": "keyword", "start": 96, "end": 101}, + {"type": "operator", "start": 117, "end": 118}, + {"type": "builtin", "start": 119, "end": 122}, + {"type": "punctuation", "start": 122, "end": 123}, + {"type": "operator", "start": 142, "end": 143}, + {"type": "builtin", "start": 144, "end": 147}, {"type": "punctuation", "start": 147, "end": 148}, - {"type": "punctuation", "start": 148, "end": 149}, - {"type": "function", "start": 152, "end": 163}, - {"type": "punctuation", "start": 163, "end": 164}, - {"type": "operator", "start": 166, "end": 167}, - {"type": "builtin", "start": 168, "end": 174}, - {"type": "punctuation", "start": 174, "end": 175}, - {"type": "punctuation", "start": 176, "end": 177}, - {"type": "keyword", "start": 180, "end": 184}, - {"type": "punctuation", "start": 184, "end": 185}, - {"type": "operator", "start": 188, "end": 189}, - {"type": "punctuation", "start": 192, "end": 193}, - {"type": "punctuation", "start": 195, "end": 196}, - {"type": "function", "start": 199, "end": 211}, - {"type": "punctuation", "start": 211, "end": 212}, - {"type": "punctuation", "start": 212, "end": 213}, - {"type": "operator", "start": 213, "end": 214}, - {"type": "builtin", "start": 215, "end": 221}, - {"type": "punctuation", "start": 222, "end": 223}, - {"type": "special_keyword", "start": 226, "end": 232}, - {"type": "template_string", "start": 233, "end": 252}, - {"type": "template_punctuation", "start": 233, "end": 234}, - {"type": "string", "start": 234, "end": 241}, - {"type": "interpolation", "start": 241, "end": 251}, - {"type": "interpolation_punctuation", "start": 241, "end": 243}, - {"type": "keyword", "start": 243, "end": 247}, - {"type": "punctuation", "start": 247, "end": 248}, - {"type": "interpolation_punctuation", "start": 250, "end": 251}, - {"type": "template_punctuation", "start": 251, "end": 252}, - {"type": "punctuation", "start": 252, "end": 253}, - {"type": "punctuation", "start": 255, "end": 256}, - {"type": "function_variable", "start": 259, "end": 274}, - {"type": "operator", "start": 275, "end": 276}, - {"type": "punctuation", "start": 277, "end": 278}, - {"type": "punctuation", "start": 278, "end": 279}, - {"type": "operator", "start": 279, "end": 280}, - {"type": "keyword", "start": 281, "end": 285}, - {"type": "operator", "start": 286, "end": 288}, - {"type": "punctuation", "start": 289, "end": 290}, - {"type": "comment", "start": 293, "end": 302}, - {"type": "keyword", "start": 305, "end": 308}, - {"type": "operator", "start": 311, "end": 312}, - {"type": "number", "start": 313, "end": 314}, - {"type": "punctuation", "start": 314, "end": 315}, - {"type": "special_keyword", "start": 318, "end": 323}, - {"type": "punctuation", "start": 324, "end": 325}, - {"type": "operator", "start": 327, "end": 328}, - {"type": "number", "start": 329, "end": 330}, - {"type": "punctuation", "start": 330, "end": 331}, - {"type": "operator", "start": 333, "end": 335}, - {"type": "punctuation", "start": 335, "end": 336}, - {"type": "special_keyword", "start": 339, "end": 342}, - {"type": "punctuation", "start": 343, "end": 344}, - {"type": "keyword", "start": 344, "end": 349}, - {"type": "keyword", "start": 353, "end": 355}, - {"type": "keyword", "start": 356, "end": 360}, - {"type": "punctuation", "start": 360, "end": 361}, - {"type": "punctuation", "start": 363, "end": 364}, - {"type": "punctuation", "start": 365, "end": 366}, - {"type": "special_keyword", "start": 370, "end": 372}, + {"type": "operator", "start": 165, "end": 166}, + {"type": "builtin", "start": 167, "end": 170}, + {"type": "punctuation", "start": 170, "end": 171}, + {"type": "keyword", "start": 173, "end": 181}, + {"type": "keyword", "start": 182, "end": 187}, + {"type": "class_name", "start": 188, "end": 192}, + {"type": "punctuation", "start": 193, "end": 194}, + {"type": "keyword", "start": 196, "end": 204}, + {"type": "function", "start": 205, "end": 220}, + {"type": "punctuation", "start": 220, "end": 221}, + {"type": "punctuation", "start": 221, "end": 222}, + {"type": "operator", "start": 222, "end": 223}, + {"type": "keyword", "start": 224, "end": 228}, + {"type": "punctuation", "start": 228, "end": 229}, + {"type": "punctuation", "start": 230, "end": 231}, + {"type": "decorator", "start": 233, "end": 249}, + {"type": "at", "start": 233, "end": 234}, + {"type": "function", "start": 234, "end": 249}, + {"type": "keyword", "start": 250, "end": 255}, + {"type": "class_name", "start": 256, "end": 257}, + {"type": "constant", "start": 256, "end": 257}, + {"type": "keyword", "start": 258, "end": 265}, + {"type": "class_name", "start": 266, "end": 270}, + {"type": "punctuation", "start": 271, "end": 272}, + {"type": "keyword", "start": 274, "end": 282}, + {"type": "operator", "start": 285, "end": 286}, + {"type": "builtin", "start": 287, "end": 293}, + {"type": "operator", "start": 294, "end": 295}, + {"type": "string", "start": 296, "end": 299}, + {"type": "punctuation", "start": 299, "end": 300}, + {"type": "operator", "start": 304, "end": 305}, + {"type": "builtin", "start": 306, "end": 312}, + {"type": "punctuation", "start": 312, "end": 313}, + {"type": "operator", "start": 318, "end": 319}, + {"type": "function", "start": 320, "end": 326}, + {"type": "punctuation", "start": 326, "end": 327}, + {"type": "keyword", "start": 327, "end": 331}, + {"type": "punctuation", "start": 331, "end": 332}, + {"type": "punctuation", "start": 332, "end": 333}, + {"type": "decorator", "start": 336, "end": 355}, + {"type": "at", "start": 336, "end": 337}, + {"type": "function", "start": 337, "end": 355}, + {"type": "operator", "start": 367, "end": 368}, + {"type": "boolean", "start": 369, "end": 373}, {"type": "punctuation", "start": 373, "end": 374}, - {"type": "operator", "start": 377, "end": 380}, - {"type": "string", "start": 381, "end": 384}, - {"type": "punctuation", "start": 384, "end": 385}, - {"type": "special_keyword", "start": 386, "end": 394}, - {"type": "punctuation", "start": 394, "end": 395}, - {"type": "special_keyword", "start": 399, "end": 401}, - {"type": "punctuation", "start": 402, "end": 403}, - {"type": "operator", "start": 403, "end": 404}, - {"type": "punctuation", "start": 406, "end": 407}, - {"type": "special_keyword", "start": 408, "end": 413}, - {"type": "punctuation", "start": 413, "end": 414}, - {"type": "keyword", "start": 418, "end": 422}, - {"type": "punctuation", "start": 422, "end": 423}, - {"type": "function", "start": 423, "end": 438}, - {"type": "punctuation", "start": 438, "end": 439}, - {"type": "punctuation", "start": 440, "end": 441}, - {"type": "punctuation", "start": 444, "end": 445}, - {"type": "punctuation", "start": 445, "end": 446}, - {"type": "punctuation", "start": 449, "end": 450}, - {"type": "comment", "start": 453, "end": 459}, - {"type": "punctuation", "start": 461, "end": 462}, - {"type": "punctuation", "start": 462, "end": 463}, - {"type": "function", "start": 466, "end": 481}, - {"type": "punctuation", "start": 481, "end": 482}, - {"type": "operator", "start": 484, "end": 485}, - {"type": "builtin", "start": 486, "end": 492}, - {"type": "punctuation", "start": 492, "end": 493}, - {"type": "operator", "start": 496, "end": 497}, - {"type": "builtin", "start": 498, "end": 501}, - {"type": "punctuation", "start": 501, "end": 502}, - {"type": "punctuation", "start": 503, "end": 504}, - {"type": "special_keyword", "start": 507, "end": 512}, - {"type": "keyword", "start": 513, "end": 516}, - {"type": "class_name", "start": 517, "end": 522}, - {"type": "punctuation", "start": 522, "end": 523}, - {"type": "template_string", "start": 523, "end": 570}, - {"type": "template_punctuation", "start": 523, "end": 524}, - {"type": "interpolation", "start": 524, "end": 534}, - {"type": "interpolation_punctuation", "start": 524, "end": 526}, - {"type": "keyword", "start": 526, "end": 530}, - {"type": "punctuation", "start": 530, "end": 531}, - {"type": "interpolation_punctuation", "start": 533, "end": 534}, - {"type": "string", "start": 534, "end": 556}, - {"type": "interpolation", "start": 556, "end": 566}, - {"type": "interpolation_punctuation", "start": 556, "end": 558}, - {"type": "operator", "start": 561, "end": 562}, - {"type": "interpolation_punctuation", "start": 565, "end": 566}, - {"type": "string", "start": 566, "end": 569}, - {"type": "template_punctuation", "start": 569, "end": 570}, - {"type": "punctuation", "start": 570, "end": 571}, - {"type": "punctuation", "start": 571, "end": 572}, - {"type": "punctuation", "start": 574, "end": 575}, - {"type": "keyword", "start": 578, "end": 587}, - {"type": "keyword", "start": 588, "end": 593}, - {"type": "function", "start": 594, "end": 610}, - {"type": "punctuation", "start": 610, "end": 611}, - {"type": "punctuation", "start": 611, "end": 612}, - {"type": "operator", "start": 612, "end": 613}, - {"type": "builtin", "start": 614, "end": 621}, - {"type": "operator", "start": 621, "end": 622}, - {"type": "keyword", "start": 622, "end": 626}, - {"type": "operator", "start": 626, "end": 627}, - {"type": "punctuation", "start": 628, "end": 629}, - {"type": "special_keyword", "start": 632, "end": 635}, - {"type": "punctuation", "start": 636, "end": 637}, + {"type": "function", "start": 377, "end": 388}, + {"type": "punctuation", "start": 388, "end": 389}, + {"type": "operator", "start": 391, "end": 392}, + {"type": "builtin", "start": 393, "end": 399}, + {"type": "punctuation", "start": 399, "end": 400}, + {"type": "punctuation", "start": 401, "end": 402}, + {"type": "keyword", "start": 405, "end": 410}, + {"type": "punctuation", "start": 410, "end": 411}, + {"type": "punctuation", "start": 411, "end": 412}, + {"type": "punctuation", "start": 412, "end": 413}, + {"type": "keyword", "start": 416, "end": 420}, + {"type": "punctuation", "start": 420, "end": 421}, + {"type": "operator", "start": 424, "end": 425}, + {"type": "punctuation", "start": 428, "end": 429}, + {"type": "punctuation", "start": 431, "end": 432}, + {"type": "function", "start": 435, "end": 450}, + {"type": "punctuation", "start": 450, "end": 451}, + {"type": "punctuation", "start": 451, "end": 452}, + {"type": "operator", "start": 452, "end": 453}, + {"type": "keyword", "start": 454, "end": 458}, + {"type": "punctuation", "start": 459, "end": 460}, + {"type": "comment", "start": 463, "end": 480}, + {"type": "punctuation", "start": 482, "end": 483}, + {"type": "decorator", "start": 486, "end": 503}, + {"type": "at", "start": 486, "end": 487}, + {"type": "function", "start": 487, "end": 503}, + {"type": "function", "start": 505, "end": 517}, + {"type": "punctuation", "start": 517, "end": 518}, + {"type": "punctuation", "start": 518, "end": 519}, + {"type": "operator", "start": 519, "end": 520}, + {"type": "builtin", "start": 521, "end": 527}, + {"type": "punctuation", "start": 528, "end": 529}, + {"type": "special_keyword", "start": 532, "end": 538}, + {"type": "template_string", "start": 539, "end": 558}, + {"type": "template_punctuation", "start": 539, "end": 540}, + {"type": "string", "start": 540, "end": 547}, + {"type": "interpolation", "start": 547, "end": 557}, + {"type": "interpolation_punctuation", "start": 547, "end": 549}, + {"type": "keyword", "start": 549, "end": 553}, + {"type": "punctuation", "start": 553, "end": 554}, + {"type": "interpolation_punctuation", "start": 556, "end": 557}, + {"type": "template_punctuation", "start": 557, "end": 558}, + {"type": "punctuation", "start": 558, "end": 559}, + {"type": "punctuation", "start": 561, "end": 562}, + {"type": "function_variable", "start": 565, "end": 580}, + {"type": "operator", "start": 581, "end": 582}, + {"type": "punctuation", "start": 583, "end": 584}, + {"type": "punctuation", "start": 584, "end": 585}, + {"type": "operator", "start": 585, "end": 586}, + {"type": "keyword", "start": 587, "end": 591}, + {"type": "operator", "start": 592, "end": 594}, + {"type": "punctuation", "start": 595, "end": 596}, + {"type": "comment", "start": 599, "end": 608}, + {"type": "keyword", "start": 611, "end": 614}, + {"type": "operator", "start": 617, "end": 618}, + {"type": "number", "start": 619, "end": 620}, + {"type": "punctuation", "start": 620, "end": 621}, + {"type": "special_keyword", "start": 624, "end": 626}, + {"type": "punctuation", "start": 627, "end": 628}, + {"type": "operator", "start": 633, "end": 635}, + {"type": "punctuation", "start": 635, "end": 636}, + {"type": "punctuation", "start": 639, "end": 640}, {"type": "special_keyword", "start": 641, "end": 646}, - {"type": "keyword", "start": 647, "end": 650}, - {"type": "class_name", "start": 651, "end": 658}, - {"type": "builtin", "start": 651, "end": 658}, - {"type": "punctuation", "start": 658, "end": 659}, - {"type": "punctuation", "start": 659, "end": 660}, - {"type": "punctuation", "start": 667, "end": 668}, - {"type": "operator", "start": 669, "end": 671}, - {"type": "function", "start": 672, "end": 682}, - {"type": "punctuation", "start": 682, "end": 683}, - {"type": "punctuation", "start": 690, "end": 691}, - {"type": "number", "start": 692, "end": 695}, - {"type": "punctuation", "start": 695, "end": 696}, - {"type": "punctuation", "start": 696, "end": 697}, - {"type": "punctuation", "start": 697, "end": 698}, - {"type": "special_keyword", "start": 702, "end": 704}, - {"type": "punctuation", "start": 705, "end": 706}, - {"type": "punctuation", "start": 710, "end": 711}, - {"type": "function", "start": 711, "end": 717}, - {"type": "punctuation", "start": 717, "end": 718}, - {"type": "punctuation", "start": 718, "end": 719}, - {"type": "operator", "start": 720, "end": 721}, - {"type": "number", "start": 722, "end": 725}, - {"type": "punctuation", "start": 725, "end": 726}, - {"type": "punctuation", "start": 727, "end": 728}, - {"type": "builtin", "start": 733, "end": 740}, - {"type": "punctuation", "start": 740, "end": 741}, - {"type": "function", "start": 741, "end": 744}, - {"type": "punctuation", "start": 744, "end": 745}, - {"type": "keyword", "start": 745, "end": 748}, - {"type": "class_name", "start": 749, "end": 753}, - {"type": "punctuation", "start": 753, "end": 754}, - {"type": "punctuation", "start": 754, "end": 755}, - {"type": "punctuation", "start": 755, "end": 756}, - {"type": "punctuation", "start": 756, "end": 757}, - {"type": "comment", "start": 758, "end": 791}, - {"type": "punctuation", "start": 795, "end": 796}, - {"type": "special_keyword", "start": 797, "end": 801}, - {"type": "special_keyword", "start": 802, "end": 804}, - {"type": "punctuation", "start": 805, "end": 806}, - {"type": "punctuation", "start": 810, "end": 811}, - {"type": "function", "start": 811, "end": 817}, + {"type": "punctuation", "start": 647, "end": 648}, + {"type": "operator", "start": 650, "end": 651}, + {"type": "number", "start": 652, "end": 653}, + {"type": "punctuation", "start": 653, "end": 654}, + {"type": "punctuation", "start": 654, "end": 655}, + {"type": "special_keyword", "start": 659, "end": 662}, + {"type": "punctuation", "start": 663, "end": 664}, + {"type": "keyword", "start": 664, "end": 669}, + {"type": "keyword", "start": 673, "end": 675}, + {"type": "keyword", "start": 676, "end": 680}, + {"type": "punctuation", "start": 680, "end": 681}, + {"type": "punctuation", "start": 683, "end": 684}, + {"type": "punctuation", "start": 685, "end": 686}, + {"type": "special_keyword", "start": 690, "end": 692}, + {"type": "punctuation", "start": 693, "end": 694}, + {"type": "operator", "start": 697, "end": 700}, + {"type": "string", "start": 701, "end": 704}, + {"type": "punctuation", "start": 704, "end": 705}, + {"type": "special_keyword", "start": 706, "end": 714}, + {"type": "punctuation", "start": 714, "end": 715}, + {"type": "special_keyword", "start": 719, "end": 721}, + {"type": "punctuation", "start": 722, "end": 723}, + {"type": "operator", "start": 723, "end": 724}, + {"type": "punctuation", "start": 726, "end": 727}, + {"type": "special_keyword", "start": 728, "end": 733}, + {"type": "punctuation", "start": 733, "end": 734}, + {"type": "keyword", "start": 738, "end": 742}, + {"type": "punctuation", "start": 742, "end": 743}, + {"type": "function", "start": 743, "end": 758}, + {"type": "punctuation", "start": 758, "end": 759}, + {"type": "punctuation", "start": 760, "end": 761}, + {"type": "punctuation", "start": 764, "end": 765}, + {"type": "punctuation", "start": 765, "end": 766}, + {"type": "punctuation", "start": 769, "end": 770}, + {"type": "special_keyword", "start": 774, "end": 780}, + {"type": "punctuation", "start": 781, "end": 782}, + {"type": "keyword", "start": 782, "end": 786}, + {"type": "punctuation", "start": 786, "end": 787}, + {"type": "punctuation", "start": 789, "end": 790}, + {"type": "punctuation", "start": 791, "end": 792}, + {"type": "special_keyword", "start": 796, "end": 800}, + {"type": "string", "start": 801, "end": 804}, + {"type": "operator", "start": 804, "end": 805}, + {"type": "builtin", "start": 810, "end": 817}, {"type": "punctuation", "start": 817, "end": 818}, - {"type": "punctuation", "start": 818, "end": 819}, - {"type": "operator", "start": 820, "end": 821}, - {"type": "number", "start": 822, "end": 825}, - {"type": "punctuation", "start": 825, "end": 826}, - {"type": "punctuation", "start": 827, "end": 828}, - {"type": "builtin", "start": 833, "end": 840}, - {"type": "punctuation", "start": 840, "end": 841}, - {"type": "function", "start": 841, "end": 844}, - {"type": "punctuation", "start": 844, "end": 845}, - {"type": "string", "start": 845, "end": 861}, - {"type": "punctuation", "start": 861, "end": 862}, - {"type": "punctuation", "start": 862, "end": 863}, - {"type": "punctuation", "start": 867, "end": 868}, - {"type": "special_keyword", "start": 869, "end": 873}, - {"type": "punctuation", "start": 874, "end": 875}, - {"type": "builtin", "start": 880, "end": 887}, - {"type": "punctuation", "start": 887, "end": 888}, - {"type": "function", "start": 888, "end": 891}, - {"type": "punctuation", "start": 891, "end": 892}, - {"type": "string", "start": 892, "end": 905}, - {"type": "punctuation", "start": 905, "end": 906}, - {"type": "punctuation", "start": 906, "end": 907}, + {"type": "function", "start": 818, "end": 821}, + {"type": "punctuation", "start": 821, "end": 822}, + {"type": "string", "start": 822, "end": 830}, + {"type": "punctuation", "start": 830, "end": 831}, + {"type": "punctuation", "start": 831, "end": 832}, + {"type": "special_keyword", "start": 837, "end": 842}, + {"type": "punctuation", "start": 842, "end": 843}, + {"type": "special_keyword", "start": 847, "end": 851}, + {"type": "string", "start": 852, "end": 855}, + {"type": "operator", "start": 855, "end": 856}, + {"type": "special_keyword", "start": 860, "end": 864}, + {"type": "string", "start": 865, "end": 868}, + {"type": "operator", "start": 868, "end": 869}, + {"type": "builtin", "start": 874, "end": 881}, + {"type": "punctuation", "start": 881, "end": 882}, + {"type": "function", "start": 882, "end": 885}, + {"type": "punctuation", "start": 885, "end": 886}, + {"type": "string", "start": 886, "end": 899}, + {"type": "punctuation", "start": 899, "end": 900}, + {"type": "punctuation", "start": 900, "end": 901}, + {"type": "special_keyword", "start": 906, "end": 911}, {"type": "punctuation", "start": 911, "end": 912}, - {"type": "punctuation", "start": 915, "end": 916}, - {"type": "special_keyword", "start": 917, "end": 922}, - {"type": "punctuation", "start": 923, "end": 924}, - {"type": "punctuation", "start": 929, "end": 930}, - {"type": "punctuation", "start": 931, "end": 932}, - {"type": "builtin", "start": 936, "end": 943}, - {"type": "punctuation", "start": 943, "end": 944}, - {"type": "function", "start": 944, "end": 949}, - {"type": "punctuation", "start": 949, "end": 950}, + {"type": "keyword", "start": 916, "end": 923}, + {"type": "operator", "start": 923, "end": 924}, + {"type": "builtin", "start": 929, "end": 936}, + {"type": "punctuation", "start": 936, "end": 937}, + {"type": "function", "start": 937, "end": 940}, + {"type": "punctuation", "start": 940, "end": 941}, + {"type": "string", "start": 941, "end": 950}, + {"type": "punctuation", "start": 950, "end": 951}, + {"type": "punctuation", "start": 951, "end": 952}, {"type": "punctuation", "start": 955, "end": 956}, - {"type": "punctuation", "start": 956, "end": 957}, - {"type": "punctuation", "start": 960, "end": 961}, - {"type": "special_keyword", "start": 962, "end": 969}, - {"type": "punctuation", "start": 970, "end": 971}, - {"type": "builtin", "start": 975, "end": 982}, - {"type": "punctuation", "start": 982, "end": 983}, - {"type": "function", "start": 983, "end": 986}, - {"type": "punctuation", "start": 986, "end": 987}, - {"type": "string", "start": 987, "end": 1002}, - {"type": "punctuation", "start": 1002, "end": 1003}, + {"type": "keyword", "start": 960, "end": 965}, + {"type": "operator", "start": 969, "end": 970}, + {"type": "punctuation", "start": 971, "end": 972}, + {"type": "operator", "start": 978, "end": 979}, + {"type": "operator", "start": 979, "end": 980}, + {"type": "builtin", "start": 981, "end": 988}, + {"type": "punctuation", "start": 988, "end": 989}, + {"type": "operator", "start": 994, "end": 995}, + {"type": "builtin", "start": 996, "end": 1003}, {"type": "punctuation", "start": 1003, "end": 1004}, + {"type": "operator", "start": 1005, "end": 1006}, {"type": "punctuation", "start": 1007, "end": 1008}, - {"type": "punctuation", "start": 1010, "end": 1011}, - {"type": "punctuation", "start": 1012, "end": 1013}, - {"type": "comment", "start": 1015, "end": 1025}, - {"type": "comment", "start": 1027, "end": 1070}, - {"type": "comment", "start": 1072, "end": 1096}, - {"type": "special_keyword", "start": 1098, "end": 1104}, - {"type": "punctuation", "start": 1105, "end": 1106}, + {"type": "operator", "start": 1018, "end": 1019}, + {"type": "string", "start": 1020, "end": 1024}, + {"type": "keyword", "start": 1025, "end": 1027}, + {"type": "keyword", "start": 1028, "end": 1032}, + {"type": "punctuation", "start": 1032, "end": 1033}, + {"type": "operator", "start": 1041, "end": 1042}, + {"type": "keyword", "start": 1043, "end": 1047}, + {"type": "keyword", "start": 1048, "end": 1058}, + {"type": "class_name", "start": 1059, "end": 1060}, + {"type": "constant", "start": 1059, "end": 1060}, + {"type": "punctuation", "start": 1060, "end": 1061}, + {"type": "punctuation", "start": 1064, "end": 1065}, + {"type": "punctuation", "start": 1065, "end": 1066}, + {"type": "keyword", "start": 1069, "end": 1075}, + {"type": "punctuation", "start": 1079, "end": 1080}, + {"type": "punctuation", "start": 1086, "end": 1087}, + {"type": "comment", "start": 1090, "end": 1096}, + {"type": "punctuation", "start": 1098, "end": 1099}, + {"type": "punctuation", "start": 1099, "end": 1100}, + {"type": "function", "start": 1103, "end": 1118}, {"type": "punctuation", "start": 1118, "end": 1119}, - {"type": "keyword", "start": 1120, "end": 1124}, - {"type": "class_name", "start": 1125, "end": 1136}, - {"type": "punctuation", "start": 1136, "end": 1137}, - {"type": "keyword", "start": 1138, "end": 1142}, - {"type": "class_name", "start": 1143, "end": 1154}, - {"type": "punctuation", "start": 1154, "end": 1155}, - {"type": "special_keyword", "start": 1156, "end": 1160}, - {"type": "string", "start": 1161, "end": 1180}, - {"type": "punctuation", "start": 1180, "end": 1181}, - {"type": "special_keyword", "start": 1182, "end": 1188}, - {"type": "operator", "start": 1189, "end": 1190}, - {"type": "special_keyword", "start": 1191, "end": 1193}, - {"type": "constant", "start": 1194, "end": 1195}, - {"type": "special_keyword", "start": 1196, "end": 1200}, - {"type": "string", "start": 1201, "end": 1220}, - {"type": "punctuation", "start": 1220, "end": 1221}, - {"type": "special_keyword", "start": 1236, "end": 1238}, - {"type": "builtin", "start": 1239, "end": 1246}, - {"type": "special_keyword", "start": 1247, "end": 1249}, - {"type": "special_keyword", "start": 1262, "end": 1264}, - {"type": "builtin", "start": 1265, "end": 1268}, - {"type": "special_keyword", "start": 1269, "end": 1271}, - {"type": "punctuation", "start": 1283, "end": 1284}, - {"type": "special_keyword", "start": 1286, "end": 1292}, - {"type": "punctuation", "start": 1293, "end": 1294}, - {"type": "punctuation", "start": 1295, "end": 1296}, - {"type": "constant", "start": 1297, "end": 1298}, - {"type": "punctuation", "start": 1298, "end": 1299}, - {"type": "punctuation", "start": 1301, "end": 1302}, - {"type": "punctuation", "start": 1304, "end": 1305}, - {"type": "constant", "start": 1306, "end": 1307}, - {"type": "punctuation", "start": 1307, "end": 1308}, - {"type": "punctuation", "start": 1308, "end": 1309}, - {"type": "special_keyword", "start": 1311, "end": 1317}, - {"type": "keyword", "start": 1318, "end": 1327}, - {"type": "class_name", "start": 1328, "end": 1334}, - {"type": "punctuation", "start": 1335, "end": 1336}, - {"type": "operator", "start": 1342, "end": 1343}, - {"type": "builtin", "start": 1344, "end": 1350}, - {"type": "punctuation", "start": 1350, "end": 1351}, - {"type": "operator", "start": 1356, "end": 1357}, - {"type": "builtin", "start": 1358, "end": 1364}, - {"type": "punctuation", "start": 1364, "end": 1365}, - {"type": "punctuation", "start": 1366, "end": 1367}, - {"type": "special_keyword", "start": 1369, "end": 1375}, - {"type": "keyword", "start": 1376, "end": 1381}, - {"type": "operator", "start": 1388, "end": 1389}, - {"type": "operator", "start": 1397, "end": 1398}, - {"type": "punctuation", "start": 1399, "end": 1400}, - {"type": "operator", "start": 1404, "end": 1405}, - {"type": "string", "start": 1406, "end": 1413}, - {"type": "punctuation", "start": 1413, "end": 1414}, - {"type": "operator", "start": 1418, "end": 1419}, - {"type": "number", "start": 1420, "end": 1423}, - {"type": "punctuation", "start": 1423, "end": 1424}, - {"type": "punctuation", "start": 1424, "end": 1425}, - {"type": "special_keyword", "start": 1427, "end": 1433}, - {"type": "keyword", "start": 1434, "end": 1442}, - {"type": "function", "start": 1443, "end": 1446}, + {"type": "operator", "start": 1121, "end": 1122}, + {"type": "builtin", "start": 1123, "end": 1129}, + {"type": "punctuation", "start": 1129, "end": 1130}, + {"type": "operator", "start": 1133, "end": 1134}, + {"type": "builtin", "start": 1135, "end": 1138}, + {"type": "punctuation", "start": 1138, "end": 1139}, + {"type": "punctuation", "start": 1140, "end": 1141}, + {"type": "special_keyword", "start": 1144, "end": 1149}, + {"type": "keyword", "start": 1150, "end": 1153}, + {"type": "class_name", "start": 1154, "end": 1159}, + {"type": "punctuation", "start": 1159, "end": 1160}, + {"type": "template_string", "start": 1160, "end": 1206}, + {"type": "template_punctuation", "start": 1160, "end": 1161}, + {"type": "interpolation", "start": 1161, "end": 1171}, + {"type": "interpolation_punctuation", "start": 1161, "end": 1163}, + {"type": "keyword", "start": 1163, "end": 1167}, + {"type": "punctuation", "start": 1167, "end": 1168}, + {"type": "interpolation_punctuation", "start": 1170, "end": 1171}, + {"type": "string", "start": 1171, "end": 1192}, + {"type": "interpolation", "start": 1192, "end": 1202}, + {"type": "interpolation_punctuation", "start": 1192, "end": 1194}, + {"type": "operator", "start": 1197, "end": 1198}, + {"type": "interpolation_punctuation", "start": 1201, "end": 1202}, + {"type": "string", "start": 1202, "end": 1205}, + {"type": "template_punctuation", "start": 1205, "end": 1206}, + {"type": "punctuation", "start": 1206, "end": 1207}, + {"type": "punctuation", "start": 1207, "end": 1208}, + {"type": "punctuation", "start": 1210, "end": 1211}, + {"type": "operator", "start": 1214, "end": 1215}, + {"type": "function", "start": 1215, "end": 1224}, + {"type": "punctuation", "start": 1224, "end": 1225}, + {"type": "punctuation", "start": 1225, "end": 1226}, + {"type": "punctuation", "start": 1227, "end": 1228}, + {"type": "keyword", "start": 1231, "end": 1236}, + {"type": "number", "start": 1237, "end": 1238}, + {"type": "punctuation", "start": 1238, "end": 1239}, + {"type": "keyword", "start": 1242, "end": 1247}, + {"type": "operator", "start": 1247, "end": 1248}, + {"type": "punctuation", "start": 1249, "end": 1250}, + {"type": "number", "start": 1250, "end": 1251}, + {"type": "punctuation", "start": 1251, "end": 1252}, + {"type": "number", "start": 1253, "end": 1254}, + {"type": "punctuation", "start": 1254, "end": 1255}, + {"type": "punctuation", "start": 1255, "end": 1256}, + {"type": "punctuation", "start": 1258, "end": 1259}, + {"type": "operator", "start": 1268, "end": 1269}, + {"type": "function", "start": 1269, "end": 1284}, + {"type": "punctuation", "start": 1284, "end": 1285}, + {"type": "punctuation", "start": 1285, "end": 1286}, + {"type": "punctuation", "start": 1287, "end": 1288}, + {"type": "keyword", "start": 1291, "end": 1296}, + {"type": "special_keyword", "start": 1297, "end": 1302}, + {"type": "builtin", "start": 1303, "end": 1310}, + {"type": "punctuation", "start": 1310, "end": 1311}, + {"type": "function", "start": 1311, "end": 1318}, + {"type": "punctuation", "start": 1318, "end": 1319}, + {"type": "number", "start": 1319, "end": 1320}, + {"type": "punctuation", "start": 1320, "end": 1321}, + {"type": "punctuation", "start": 1321, "end": 1322}, + {"type": "punctuation", "start": 1324, "end": 1325}, + {"type": "keyword", "start": 1328, "end": 1337}, + {"type": "keyword", "start": 1338, "end": 1343}, + {"type": "function", "start": 1344, "end": 1360}, + {"type": "punctuation", "start": 1360, "end": 1361}, + {"type": "punctuation", "start": 1361, "end": 1362}, + {"type": "operator", "start": 1362, "end": 1363}, + {"type": "builtin", "start": 1364, "end": 1371}, + {"type": "operator", "start": 1371, "end": 1372}, + {"type": "keyword", "start": 1372, "end": 1376}, + {"type": "operator", "start": 1376, "end": 1377}, + {"type": "punctuation", "start": 1378, "end": 1379}, + {"type": "special_keyword", "start": 1382, "end": 1385}, + {"type": "punctuation", "start": 1386, "end": 1387}, + {"type": "special_keyword", "start": 1391, "end": 1396}, + {"type": "keyword", "start": 1397, "end": 1400}, + {"type": "class_name", "start": 1401, "end": 1408}, + {"type": "builtin", "start": 1401, "end": 1408}, + {"type": "punctuation", "start": 1408, "end": 1409}, + {"type": "punctuation", "start": 1409, "end": 1410}, + {"type": "punctuation", "start": 1417, "end": 1418}, + {"type": "operator", "start": 1419, "end": 1421}, + {"type": "function", "start": 1422, "end": 1432}, + {"type": "punctuation", "start": 1432, "end": 1433}, + {"type": "punctuation", "start": 1440, "end": 1441}, + {"type": "number", "start": 1442, "end": 1445}, + {"type": "punctuation", "start": 1445, "end": 1446}, {"type": "punctuation", "start": 1446, "end": 1447}, - {"type": "operator", "start": 1448, "end": 1449}, - {"type": "builtin", "start": 1450, "end": 1456}, - {"type": "punctuation", "start": 1456, "end": 1457}, - {"type": "operator", "start": 1459, "end": 1460}, - {"type": "builtin", "start": 1461, "end": 1467}, + {"type": "punctuation", "start": 1447, "end": 1448}, + {"type": "special_keyword", "start": 1452, "end": 1454}, + {"type": "punctuation", "start": 1455, "end": 1456}, + {"type": "punctuation", "start": 1460, "end": 1461}, + {"type": "function", "start": 1461, "end": 1467}, {"type": "punctuation", "start": 1467, "end": 1468}, - {"type": "operator", "start": 1468, "end": 1469}, - {"type": "builtin", "start": 1470, "end": 1476}, + {"type": "punctuation", "start": 1468, "end": 1469}, + {"type": "operator", "start": 1470, "end": 1471}, + {"type": "number", "start": 1472, "end": 1475}, + {"type": "punctuation", "start": 1475, "end": 1476}, {"type": "punctuation", "start": 1477, "end": 1478}, - {"type": "special_keyword", "start": 1480, "end": 1486}, - {"type": "operator", "start": 1489, "end": 1490}, - {"type": "punctuation", "start": 1492, "end": 1493}, + {"type": "builtin", "start": 1483, "end": 1490}, + {"type": "punctuation", "start": 1490, "end": 1491}, + {"type": "function", "start": 1491, "end": 1494}, {"type": "punctuation", "start": 1494, "end": 1495}, - {"type": "special_keyword", "start": 1497, "end": 1503}, - {"type": "keyword", "start": 1504, "end": 1509}, - {"type": "function_variable", "start": 1510, "end": 1514}, - {"type": "operator", "start": 1515, "end": 1516}, - {"type": "punctuation", "start": 1517, "end": 1518}, - {"type": "operator", "start": 1519, "end": 1520}, - {"type": "builtin", "start": 1521, "end": 1524}, - {"type": "punctuation", "start": 1524, "end": 1525}, - {"type": "operator", "start": 1527, "end": 1528}, - {"type": "builtin", "start": 1529, "end": 1532}, - {"type": "punctuation", "start": 1532, "end": 1533}, - {"type": "operator", "start": 1533, "end": 1534}, - {"type": "builtin", "start": 1535, "end": 1538}, - {"type": "operator", "start": 1539, "end": 1541}, - {"type": "operator", "start": 1544, "end": 1545}, - {"type": "punctuation", "start": 1547, "end": 1548}, - {"type": "comment", "start": 1550, "end": 1572}, - {"type": "special_keyword", "start": 1573, "end": 1579}, - {"type": "keyword", "start": 1580, "end": 1585}, - {"type": "operator", "start": 1604, "end": 1605}, - {"type": "string", "start": 1606, "end": 1635}, - {"type": "punctuation", "start": 1635, "end": 1636}, - {"type": "special_keyword", "start": 1637, "end": 1643}, - {"type": "keyword", "start": 1644, "end": 1649}, - {"type": "operator", "start": 1667, "end": 1668}, - {"type": "string", "start": 1669, "end": 1695}, - {"type": "punctuation", "start": 1695, "end": 1696}, - {"type": "special_keyword", "start": 1697, "end": 1703}, - {"type": "keyword", "start": 1704, "end": 1709}, - {"type": "operator", "start": 1729, "end": 1730}, - {"type": "template_string", "start": 1731, "end": 1748}, - {"type": "template_punctuation", "start": 1731, "end": 1732}, - {"type": "string", "start": 1732, "end": 1739}, - {"type": "interpolation", "start": 1739, "end": 1747}, - {"type": "interpolation_punctuation", "start": 1739, "end": 1741}, - {"type": "number", "start": 1741, "end": 1742}, - {"type": "operator", "start": 1743, "end": 1744}, - {"type": "number", "start": 1745, "end": 1746}, - {"type": "interpolation_punctuation", "start": 1746, "end": 1747}, - {"type": "template_punctuation", "start": 1747, "end": 1748}, - {"type": "punctuation", "start": 1748, "end": 1749}, - {"type": "comment", "start": 1751, "end": 1783}, - {"type": "special_keyword", "start": 1784, "end": 1790}, - {"type": "keyword", "start": 1791, "end": 1796}, - {"type": "operator", "start": 1803, "end": 1804}, - {"type": "regex", "start": 1805, "end": 1814}, - {"type": "regex_delimiter", "start": 1805, "end": 1806}, - {"type": "regex_source", "start": 1806, "end": 1812}, - {"type": "regex_delimiter", "start": 1812, "end": 1813}, - {"type": "regex_flags", "start": 1813, "end": 1814}, - {"type": "punctuation", "start": 1814, "end": 1815}, - {"type": "special_keyword", "start": 1816, "end": 1822}, - {"type": "keyword", "start": 1823, "end": 1828}, - {"type": "operator", "start": 1843, "end": 1844}, - {"type": "regex", "start": 1845, "end": 1877}, - {"type": "regex_delimiter", "start": 1845, "end": 1846}, - {"type": "regex_source", "start": 1846, "end": 1876}, - {"type": "regex_delimiter", "start": 1876, "end": 1877}, + {"type": "keyword", "start": 1495, "end": 1498}, + {"type": "class_name", "start": 1499, "end": 1503}, + {"type": "punctuation", "start": 1503, "end": 1504}, + {"type": "punctuation", "start": 1504, "end": 1505}, + {"type": "punctuation", "start": 1505, "end": 1506}, + {"type": "punctuation", "start": 1506, "end": 1507}, + {"type": "comment", "start": 1508, "end": 1541}, + {"type": "punctuation", "start": 1545, "end": 1546}, + {"type": "special_keyword", "start": 1547, "end": 1551}, + {"type": "special_keyword", "start": 1552, "end": 1554}, + {"type": "punctuation", "start": 1555, "end": 1556}, + {"type": "punctuation", "start": 1560, "end": 1561}, + {"type": "function", "start": 1561, "end": 1567}, + {"type": "punctuation", "start": 1567, "end": 1568}, + {"type": "punctuation", "start": 1568, "end": 1569}, + {"type": "operator", "start": 1570, "end": 1571}, + {"type": "number", "start": 1572, "end": 1575}, + {"type": "punctuation", "start": 1575, "end": 1576}, + {"type": "punctuation", "start": 1577, "end": 1578}, + {"type": "builtin", "start": 1583, "end": 1590}, + {"type": "punctuation", "start": 1590, "end": 1591}, + {"type": "function", "start": 1591, "end": 1594}, + {"type": "punctuation", "start": 1594, "end": 1595}, + {"type": "string", "start": 1595, "end": 1611}, + {"type": "punctuation", "start": 1611, "end": 1612}, + {"type": "punctuation", "start": 1612, "end": 1613}, + {"type": "punctuation", "start": 1617, "end": 1618}, + {"type": "special_keyword", "start": 1619, "end": 1623}, + {"type": "punctuation", "start": 1624, "end": 1625}, + {"type": "builtin", "start": 1630, "end": 1637}, + {"type": "punctuation", "start": 1637, "end": 1638}, + {"type": "function", "start": 1638, "end": 1641}, + {"type": "punctuation", "start": 1641, "end": 1642}, + {"type": "string", "start": 1642, "end": 1655}, + {"type": "punctuation", "start": 1655, "end": 1656}, + {"type": "punctuation", "start": 1656, "end": 1657}, + {"type": "punctuation", "start": 1661, "end": 1662}, + {"type": "punctuation", "start": 1665, "end": 1666}, + {"type": "special_keyword", "start": 1667, "end": 1672}, + {"type": "punctuation", "start": 1673, "end": 1674}, + {"type": "operator", "start": 1679, "end": 1680}, + {"type": "builtin", "start": 1681, "end": 1688}, + {"type": "punctuation", "start": 1688, "end": 1689}, + {"type": "punctuation", "start": 1690, "end": 1691}, + {"type": "builtin", "start": 1695, "end": 1702}, + {"type": "punctuation", "start": 1702, "end": 1703}, + {"type": "function", "start": 1703, "end": 1708}, + {"type": "punctuation", "start": 1708, "end": 1709}, + {"type": "punctuation", "start": 1714, "end": 1715}, + {"type": "punctuation", "start": 1715, "end": 1716}, + {"type": "punctuation", "start": 1719, "end": 1720}, + {"type": "special_keyword", "start": 1721, "end": 1728}, + {"type": "punctuation", "start": 1729, "end": 1730}, + {"type": "builtin", "start": 1734, "end": 1741}, + {"type": "punctuation", "start": 1741, "end": 1742}, + {"type": "function", "start": 1742, "end": 1745}, + {"type": "punctuation", "start": 1745, "end": 1746}, + {"type": "string", "start": 1746, "end": 1761}, + {"type": "punctuation", "start": 1761, "end": 1762}, + {"type": "punctuation", "start": 1762, "end": 1763}, + {"type": "punctuation", "start": 1766, "end": 1767}, + {"type": "punctuation", "start": 1769, "end": 1770}, + {"type": "punctuation", "start": 1771, "end": 1772}, + {"type": "comment", "start": 1774, "end": 1784}, + {"type": "comment", "start": 1786, "end": 1829}, + {"type": "comment", "start": 1831, "end": 1855}, + {"type": "special_keyword", "start": 1857, "end": 1863}, + {"type": "punctuation", "start": 1864, "end": 1865}, {"type": "punctuation", "start": 1877, "end": 1878}, - {"type": "comment", "start": 1880, "end": 1936}, - {"type": "comment", "start": 1937, "end": 1988} + {"type": "keyword", "start": 1879, "end": 1883}, + {"type": "class_name", "start": 1884, "end": 1895}, + {"type": "punctuation", "start": 1895, "end": 1896}, + {"type": "special_keyword", "start": 1897, "end": 1901}, + {"type": "string", "start": 1902, "end": 1921}, + {"type": "punctuation", "start": 1921, "end": 1922}, + {"type": "special_keyword", "start": 1923, "end": 1929}, + {"type": "operator", "start": 1930, "end": 1931}, + {"type": "special_keyword", "start": 1932, "end": 1934}, + {"type": "constant", "start": 1935, "end": 1936}, + {"type": "special_keyword", "start": 1937, "end": 1941}, + {"type": "string", "start": 1942, "end": 1961}, + {"type": "punctuation", "start": 1961, "end": 1962}, + {"type": "special_keyword", "start": 1964, "end": 1970}, + {"type": "punctuation", "start": 1971, "end": 1972}, + {"type": "punctuation", "start": 1973, "end": 1974}, + {"type": "constant", "start": 1975, "end": 1976}, + {"type": "punctuation", "start": 1976, "end": 1977}, + {"type": "punctuation", "start": 1979, "end": 1980}, + {"type": "punctuation", "start": 1982, "end": 1983}, + {"type": "constant", "start": 1984, "end": 1985}, + {"type": "punctuation", "start": 1985, "end": 1986}, + {"type": "punctuation", "start": 1986, "end": 1987}, + {"type": "special_keyword", "start": 2002, "end": 2004}, + {"type": "builtin", "start": 2005, "end": 2012}, + {"type": "special_keyword", "start": 2013, "end": 2015}, + {"type": "builtin", "start": 2016, "end": 2019}, + {"type": "special_keyword", "start": 2020, "end": 2022}, + {"type": "punctuation", "start": 2056, "end": 2057}, + {"type": "special_keyword", "start": 2059, "end": 2065}, + {"type": "keyword", "start": 2066, "end": 2075}, + {"type": "class_name", "start": 2076, "end": 2082}, + {"type": "punctuation", "start": 2083, "end": 2084}, + {"type": "operator", "start": 2090, "end": 2091}, + {"type": "builtin", "start": 2092, "end": 2098}, + {"type": "punctuation", "start": 2098, "end": 2099}, + {"type": "operator", "start": 2104, "end": 2105}, + {"type": "builtin", "start": 2106, "end": 2112}, + {"type": "punctuation", "start": 2112, "end": 2113}, + {"type": "punctuation", "start": 2114, "end": 2115}, + {"type": "special_keyword", "start": 2117, "end": 2123}, + {"type": "keyword", "start": 2124, "end": 2129}, + {"type": "operator", "start": 2136, "end": 2137}, + {"type": "operator", "start": 2145, "end": 2146}, + {"type": "punctuation", "start": 2147, "end": 2148}, + {"type": "operator", "start": 2152, "end": 2153}, + {"type": "string", "start": 2154, "end": 2161}, + {"type": "punctuation", "start": 2161, "end": 2162}, + {"type": "operator", "start": 2166, "end": 2167}, + {"type": "number", "start": 2168, "end": 2171}, + {"type": "punctuation", "start": 2171, "end": 2172}, + {"type": "punctuation", "start": 2172, "end": 2173}, + {"type": "special_keyword", "start": 2175, "end": 2181}, + {"type": "keyword", "start": 2182, "end": 2190}, + {"type": "function", "start": 2191, "end": 2194}, + {"type": "punctuation", "start": 2194, "end": 2195}, + {"type": "operator", "start": 2196, "end": 2197}, + {"type": "builtin", "start": 2198, "end": 2204}, + {"type": "punctuation", "start": 2204, "end": 2205}, + {"type": "operator", "start": 2207, "end": 2208}, + {"type": "builtin", "start": 2209, "end": 2215}, + {"type": "punctuation", "start": 2215, "end": 2216}, + {"type": "operator", "start": 2216, "end": 2217}, + {"type": "builtin", "start": 2218, "end": 2224}, + {"type": "punctuation", "start": 2225, "end": 2226}, + {"type": "special_keyword", "start": 2228, "end": 2234}, + {"type": "operator", "start": 2237, "end": 2238}, + {"type": "punctuation", "start": 2240, "end": 2241}, + {"type": "punctuation", "start": 2242, "end": 2243}, + {"type": "special_keyword", "start": 2245, "end": 2251}, + {"type": "keyword", "start": 2252, "end": 2257}, + {"type": "function_variable", "start": 2258, "end": 2262}, + {"type": "operator", "start": 2263, "end": 2264}, + {"type": "punctuation", "start": 2265, "end": 2266}, + {"type": "operator", "start": 2267, "end": 2268}, + {"type": "builtin", "start": 2269, "end": 2272}, + {"type": "punctuation", "start": 2272, "end": 2273}, + {"type": "operator", "start": 2275, "end": 2276}, + {"type": "builtin", "start": 2277, "end": 2280}, + {"type": "punctuation", "start": 2280, "end": 2281}, + {"type": "operator", "start": 2281, "end": 2282}, + {"type": "builtin", "start": 2283, "end": 2286}, + {"type": "operator", "start": 2287, "end": 2289}, + {"type": "operator", "start": 2292, "end": 2293}, + {"type": "punctuation", "start": 2295, "end": 2296}, + {"type": "comment", "start": 2298, "end": 2320}, + {"type": "special_keyword", "start": 2321, "end": 2327}, + {"type": "keyword", "start": 2328, "end": 2333}, + {"type": "operator", "start": 2352, "end": 2353}, + {"type": "string", "start": 2354, "end": 2383}, + {"type": "punctuation", "start": 2383, "end": 2384}, + {"type": "special_keyword", "start": 2385, "end": 2391}, + {"type": "keyword", "start": 2392, "end": 2397}, + {"type": "operator", "start": 2415, "end": 2416}, + {"type": "string", "start": 2417, "end": 2443}, + {"type": "punctuation", "start": 2443, "end": 2444}, + {"type": "special_keyword", "start": 2445, "end": 2451}, + {"type": "keyword", "start": 2452, "end": 2457}, + {"type": "operator", "start": 2477, "end": 2478}, + {"type": "template_string", "start": 2479, "end": 2496}, + {"type": "template_punctuation", "start": 2479, "end": 2480}, + {"type": "string", "start": 2480, "end": 2487}, + {"type": "interpolation", "start": 2487, "end": 2495}, + {"type": "interpolation_punctuation", "start": 2487, "end": 2489}, + {"type": "number", "start": 2489, "end": 2490}, + {"type": "operator", "start": 2491, "end": 2492}, + {"type": "number", "start": 2493, "end": 2494}, + {"type": "interpolation_punctuation", "start": 2494, "end": 2495}, + {"type": "template_punctuation", "start": 2495, "end": 2496}, + {"type": "punctuation", "start": 2496, "end": 2497}, + {"type": "comment", "start": 2499, "end": 2531}, + {"type": "special_keyword", "start": 2532, "end": 2538}, + {"type": "keyword", "start": 2539, "end": 2544}, + {"type": "operator", "start": 2551, "end": 2552}, + {"type": "regex", "start": 2553, "end": 2562}, + {"type": "regex_delimiter", "start": 2553, "end": 2554}, + {"type": "regex_source", "start": 2554, "end": 2560}, + {"type": "regex_delimiter", "start": 2560, "end": 2561}, + {"type": "regex_flags", "start": 2561, "end": 2562}, + {"type": "punctuation", "start": 2562, "end": 2563}, + {"type": "special_keyword", "start": 2564, "end": 2570}, + {"type": "keyword", "start": 2571, "end": 2576}, + {"type": "operator", "start": 2591, "end": 2592}, + {"type": "regex", "start": 2593, "end": 2625}, + {"type": "regex_delimiter", "start": 2593, "end": 2594}, + {"type": "regex_source", "start": 2594, "end": 2624}, + {"type": "regex_delimiter", "start": 2624, "end": 2625}, + {"type": "punctuation", "start": 2625, "end": 2626}, + {"type": "comment", "start": 2628, "end": 2684}, + {"type": "comment", "start": 2685, "end": 2736} ], - "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\nclass D {\n\td1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\tconstructor(d2: number) {\n\t\tthis.d2 = d2;\n\t}\n\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\twhile (i < 3) i++;\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nsample_langs as unknown as Code_Sample as any as Sample_Lang;\n\nexport {a, A, b, c, D};\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/fixtures/generated/ts/ts_complex.txt index 9467fe0d..c873eb1a 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/fixtures/generated/ts/ts_complex.txt @@ -21,401 +21,558 @@ 79-80 operator | 81-85 boolean true 85-86 punctuation ; - 88-93 keyword class - 94-95 class_name D - 94-95 constant D - 96-97 punctuation { - 101-102 operator : - 103-109 builtin string - 110-111 operator = - 112-115 string 'd' - 115-116 punctuation ; - 120-121 operator : - 122-128 builtin number - 128-129 punctuation ; - 134-135 operator = - 136-142 function $state - 142-143 punctuation ( - 143-147 keyword null - 147-148 punctuation ) - 148-149 punctuation ; - 152-163 function constructor - 163-164 punctuation ( - 166-167 operator : - 168-174 builtin number - 174-175 punctuation ) - 176-177 punctuation { - 180-184 keyword this - 184-185 punctuation . - 188-189 operator = - 192-193 punctuation ; - 195-196 punctuation } - 199-211 function class_method - 211-212 punctuation ( - 212-213 punctuation ) - 213-214 operator : - 215-221 builtin string - 222-223 punctuation { - 226-232 special_keyword return - 233-252 template_string `Hello, ${this.d1}` - 233-234 template_punctuation ` - 234-241 string Hello, - 241-251 interpolation ${this.d1} - 241-243 interpolation_punctuation ${ - 243-247 keyword this - 247-248 punctuation . - 250-251 interpolation_punctuation } - 251-252 template_punctuation ` - 252-253 punctuation ; - 255-256 punctuation } - 259-274 function_variable instance_method - 275-276 operator = - 277-278 punctuation ( - 278-279 punctuation ) - 279-280 operator : - 281-285 keyword void - 286-288 operator => - 289-290 punctuation { - 293-302 comment /* ... */ - 305-308 keyword let - 311-312 operator = - 313-314 number 0 - 314-315 punctuation ; - 318-323 special_keyword while - 324-325 punctuation ( - 327-328 operator < - 329-330 number 3 - 330-331 punctuation ) - 333-335 operator ++ - 335-336 punctuation ; - 339-342 special_keyword for - 343-344 punctuation ( - 344-349 keyword const - 353-355 keyword of - 356-360 keyword this - 360-361 punctuation . - 363-364 punctuation ) - 365-366 punctuation { - 370-372 special_keyword if - 373-374 punctuation ( - 377-380 operator === - 381-384 string 'd' - 384-385 punctuation ) - 386-394 special_keyword continue - 394-395 punctuation ; - 399-401 special_keyword if - 402-403 punctuation ( - 403-404 operator ! - 406-407 punctuation ) - 408-413 special_keyword break - 413-414 punctuation ; - 418-422 keyword this - 422-423 punctuation . - 423-438 function #private_method - 438-439 punctuation ( - 440-441 punctuation , - 444-445 punctuation ) - 445-446 punctuation ; - 449-450 punctuation } - 453-459 comment // foo - 461-462 punctuation } - 462-463 punctuation ; - 466-481 function #private_method - 481-482 punctuation ( - 484-485 operator : - 486-492 builtin number - 492-493 punctuation , - 496-497 operator : - 498-501 builtin any - 501-502 punctuation ) - 503-504 punctuation { - 507-512 special_keyword throw - 513-516 keyword new - 517-522 class_name Error - 522-523 punctuation ( - 523-570 template_string `${this.d1} \n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` - 523-524 template_punctuation ` - 524-534 interpolation ${this.d1} - 524-526 interpolation_punctuation ${ - 526-530 keyword this - 530-531 punctuation . - 533-534 interpolation_punctuation } - 534-556 string \n\t\t\tmultiline\n\t\t\tetc - 556-566 interpolation ${a2 + c2} - 556-558 interpolation_punctuation ${ - 561-562 operator + - 565-566 interpolation_punctuation } - 566-569 string \n\t\t - 569-570 template_punctuation ` - 570-571 punctuation ) - 571-572 punctuation ; - 574-575 punctuation } - 578-587 keyword protected - 588-593 keyword async - 594-610 function protected_method - 610-611 punctuation ( - 611-612 punctuation ) - 612-613 operator : - 614-621 builtin Promise - 621-622 operator < - 622-626 keyword void - 626-627 operator > - 628-629 punctuation { - 632-635 special_keyword try - 636-637 punctuation { - 641-646 special_keyword await - 647-650 keyword new - 651-658 class_name Promise - 651-658 builtin Promise - 658-659 punctuation ( - 659-660 punctuation ( - 667-668 punctuation ) - 669-671 operator => - 672-682 function setTimeout - 682-683 punctuation ( - 690-691 punctuation , - 692-695 number 100 - 695-696 punctuation ) - 696-697 punctuation ) - 697-698 punctuation ; - 702-704 special_keyword if - 705-706 punctuation ( - 710-711 punctuation . - 711-717 function random - 717-718 punctuation ( - 718-719 punctuation ) - 720-721 operator > - 722-725 number 0.5 - 725-726 punctuation ) - 727-728 punctuation { - 733-740 builtin console - 740-741 punctuation . - 741-744 function log - 744-745 punctuation ( - 745-748 keyword new - 749-753 class_name Date - 753-754 punctuation ( - 754-755 punctuation ) - 755-756 punctuation ) - 756-757 punctuation ; - 758-791 comment // eslint-disable-line no-console - 795-796 punctuation } - 797-801 special_keyword else - 802-804 special_keyword if - 805-806 punctuation ( - 810-811 punctuation . - 811-817 function random - 817-818 punctuation ( - 818-819 punctuation ) - 820-821 operator > - 822-825 number 0.2 - 825-826 punctuation ) - 827-828 punctuation { - 833-840 builtin console - 840-841 punctuation . - 841-844 function log - 844-845 punctuation ( - 845-861 string 'else if branch' - 861-862 punctuation ) - 862-863 punctuation ; - 867-868 punctuation } - 869-873 special_keyword else - 874-875 punctuation { - 880-887 builtin console - 887-888 punctuation . - 888-891 function log - 891-892 punctuation ( - 892-905 string 'else branch' - 905-906 punctuation ) - 906-907 punctuation ; - 911-912 punctuation } - 915-916 punctuation } - 917-922 special_keyword catch - 923-924 punctuation ( - 929-930 punctuation ) - 931-932 punctuation { - 936-943 builtin console - 943-944 punctuation . - 944-949 function error - 949-950 punctuation ( - 955-956 punctuation ) - 956-957 punctuation ; - 960-961 punctuation } - 962-969 special_keyword finally - 970-971 punctuation { - 975-982 builtin console - 982-983 punctuation . - 983-986 function log - 986-987 punctuation ( - 987-1002 string 'finally block' -1002-1003 punctuation ) -1003-1004 punctuation ; -1007-1008 punctuation } -1010-1011 punctuation } -1012-1013 punctuation } -1015-1025 comment // comment -1027-1070 comment /*\nother comment\n\nconst comment = false;\n*/ -1072-1096 comment /**\n * JSDoc comment\n */ -1098-1104 special_keyword import -1105-1106 punctuation { -1118-1119 punctuation , -1120-1124 keyword type -1125-1136 class_name Code_Sample -1136-1137 punctuation , -1138-1142 keyword type -1143-1154 class_name Sample_Lang -1154-1155 punctuation } -1156-1160 special_keyword from -1161-1180 string '../code_sample.js' -1180-1181 punctuation ; -1182-1188 special_keyword import -1189-1190 operator * -1191-1193 special_keyword as -1194-1195 constant A -1196-1200 special_keyword from -1201-1220 string '../code_sample.js' -1220-1221 punctuation ; -1236-1238 special_keyword as -1239-1246 builtin unknown -1247-1249 special_keyword as -1262-1264 special_keyword as -1265-1268 builtin any -1269-1271 special_keyword as -1283-1284 punctuation ; -1286-1292 special_keyword export -1293-1294 punctuation { -1295-1296 punctuation , -1297-1298 constant A -1298-1299 punctuation , -1301-1302 punctuation , -1304-1305 punctuation , -1306-1307 constant D -1307-1308 punctuation } -1308-1309 punctuation ; -1311-1317 special_keyword export -1318-1327 keyword interface -1328-1334 class_name Some_E -1335-1336 punctuation { -1342-1343 operator : -1344-1350 builtin string -1350-1351 punctuation ; -1356-1357 operator : -1358-1364 builtin number -1364-1365 punctuation ; -1366-1367 punctuation } -1369-1375 special_keyword export -1376-1381 keyword const -1388-1389 operator : -1397-1398 operator = -1399-1400 punctuation { -1404-1405 operator : -1406-1413 string 'A. H.' -1413-1414 punctuation , -1418-1419 operator : -1420-1423 number 100 -1423-1424 punctuation } -1424-1425 punctuation ; -1427-1433 special_keyword export -1434-1442 keyword function -1443-1446 function add -1446-1447 punctuation ( -1448-1449 operator : -1450-1456 builtin number -1456-1457 punctuation , -1459-1460 operator : -1461-1467 builtin number -1467-1468 punctuation ) -1468-1469 operator : -1470-1476 builtin number + 88-95 keyword declare + 96-101 keyword const + 117-118 operator : + 119-122 builtin any + 122-123 punctuation , + 142-143 operator : + 144-147 builtin any + 147-148 punctuation , + 165-166 operator : + 167-170 builtin any + 170-171 punctuation ; + 173-181 keyword abstract + 182-187 keyword class + 188-192 class_name Base + 193-194 punctuation { + 196-204 keyword abstract + 205-220 function abstract_method + 220-221 punctuation ( + 221-222 punctuation ) + 222-223 operator : + 224-228 keyword void + 228-229 punctuation ; + 230-231 punctuation } + 233-249 decorator @class_decorator + 233-234 at @ + 234-249 function class_decorator + 250-255 keyword class + 256-257 class_name D + 256-257 constant D + 258-265 keyword extends + 266-270 class_name Base + 271-272 punctuation { + 274-282 keyword readonly + 285-286 operator : + 287-293 builtin string + 294-295 operator = + 296-299 string 'd' + 299-300 punctuation ; + 304-305 operator : + 306-312 builtin number + 312-313 punctuation ; + 318-319 operator = + 320-326 function $state + 326-327 punctuation ( + 327-331 keyword null + 331-332 punctuation ) + 332-333 punctuation ; + 336-355 decorator @property_decorator + 336-337 at @ + 337-355 function property_decorator + 367-368 operator = + 369-373 boolean true + 373-374 punctuation ; + 377-388 function constructor + 388-389 punctuation ( + 391-392 operator : + 393-399 builtin number + 399-400 punctuation ) + 401-402 punctuation { + 405-410 keyword super + 410-411 punctuation ( + 411-412 punctuation ) + 412-413 punctuation ; + 416-420 keyword this + 420-421 punctuation . + 424-425 operator = + 428-429 punctuation ; + 431-432 punctuation } + 435-450 function abstract_method + 450-451 punctuation ( + 451-452 punctuation ) + 452-453 operator : + 454-458 keyword void + 459-460 punctuation { + 463-480 comment // implementation + 482-483 punctuation } + 486-503 decorator @method_decorator + 486-487 at @ + 487-503 function method_decorator + 505-517 function class_method + 517-518 punctuation ( + 518-519 punctuation ) + 519-520 operator : + 521-527 builtin string + 528-529 punctuation { + 532-538 special_keyword return + 539-558 template_string `Hello, ${this.d1}` + 539-540 template_punctuation ` + 540-547 string Hello, + 547-557 interpolation ${this.d1} + 547-549 interpolation_punctuation ${ + 549-553 keyword this + 553-554 punctuation . + 556-557 interpolation_punctuation } + 557-558 template_punctuation ` + 558-559 punctuation ; + 561-562 punctuation } + 565-580 function_variable instance_method + 581-582 operator = + 583-584 punctuation ( + 584-585 punctuation ) + 585-586 operator : + 587-591 keyword void + 592-594 operator => + 595-596 punctuation { + 599-608 comment /* ... */ + 611-614 keyword let + 617-618 operator = + 619-620 number 0 + 620-621 punctuation ; + 624-626 special_keyword do + 627-628 punctuation { + 633-635 operator ++ + 635-636 punctuation ; + 639-640 punctuation } + 641-646 special_keyword while + 647-648 punctuation ( + 650-651 operator < + 652-653 number 3 + 653-654 punctuation ) + 654-655 punctuation ; + 659-662 special_keyword for + 663-664 punctuation ( + 664-669 keyword const + 673-675 keyword of + 676-680 keyword this + 680-681 punctuation . + 683-684 punctuation ) + 685-686 punctuation { + 690-692 special_keyword if + 693-694 punctuation ( + 697-700 operator === + 701-704 string 'd' + 704-705 punctuation ) + 706-714 special_keyword continue + 714-715 punctuation ; + 719-721 special_keyword if + 722-723 punctuation ( + 723-724 operator ! + 726-727 punctuation ) + 728-733 special_keyword break + 733-734 punctuation ; + 738-742 keyword this + 742-743 punctuation . + 743-758 function #private_method + 758-759 punctuation ( + 760-761 punctuation , + 764-765 punctuation ) + 765-766 punctuation ; + 769-770 punctuation } + 774-780 special_keyword switch + 781-782 punctuation ( + 782-786 keyword this + 786-787 punctuation . + 789-790 punctuation ) + 791-792 punctuation { + 796-800 special_keyword case + 801-804 string 'a' + 804-805 operator : + 810-817 builtin console + 817-818 punctuation . + 818-821 function log + 821-822 punctuation ( + 822-830 string 'case a' + 830-831 punctuation ) + 831-832 punctuation ; + 837-842 special_keyword break + 842-843 punctuation ; + 847-851 special_keyword case + 852-855 string 'b' + 855-856 operator : + 860-864 special_keyword case + 865-868 string 'c' + 868-869 operator : + 874-881 builtin console + 881-882 punctuation . + 882-885 function log + 885-886 punctuation ( + 886-899 string 'case b or c' + 899-900 punctuation ) + 900-901 punctuation ; + 906-911 special_keyword break + 911-912 punctuation ; + 916-923 keyword default + 923-924 operator : + 929-936 builtin console + 936-937 punctuation . + 937-940 function log + 940-941 punctuation ( + 941-950 string 'default' + 950-951 punctuation ) + 951-952 punctuation ; + 955-956 punctuation } + 960-965 keyword const + 969-970 operator : + 971-972 punctuation { + 978-979 operator ? + 979-980 operator : + 981-988 builtin boolean + 988-989 punctuation ; + 994-995 operator : + 996-1003 builtin boolean +1003-1004 punctuation } +1005-1006 operator = +1007-1008 punctuation { +1018-1019 operator : +1020-1024 string 'd1' +1025-1027 keyword in +1028-1032 keyword this +1032-1033 punctuation , +1041-1042 operator : +1043-1047 keyword this +1048-1058 keyword instanceof +1059-1060 class_name D +1059-1060 constant D +1060-1061 punctuation , +1064-1065 punctuation } +1065-1066 punctuation ; +1069-1075 keyword delete +1079-1080 punctuation . +1086-1087 punctuation ; +1090-1096 comment // foo +1098-1099 punctuation } +1099-1100 punctuation ; +1103-1118 function #private_method +1118-1119 punctuation ( +1121-1122 operator : +1123-1129 builtin number +1129-1130 punctuation , +1133-1134 operator : +1135-1138 builtin any +1138-1139 punctuation ) +1140-1141 punctuation { +1144-1149 special_keyword throw +1150-1153 keyword new +1154-1159 class_name Error +1159-1160 punctuation ( +1160-1206 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` +1160-1161 template_punctuation ` +1161-1171 interpolation ${this.d1} +1161-1163 interpolation_punctuation ${ +1163-1167 keyword this +1167-1168 punctuation . +1170-1171 interpolation_punctuation } +1171-1192 string \n\t\t\tmultiline\n\t\t\tetc +1192-1202 interpolation ${a2 + c2} +1192-1194 interpolation_punctuation ${ +1197-1198 operator + +1201-1202 interpolation_punctuation } +1202-1205 string \n\t\t +1205-1206 template_punctuation ` +1206-1207 punctuation ) +1207-1208 punctuation ; +1210-1211 punctuation } +1214-1215 operator * +1215-1224 function generator +1224-1225 punctuation ( +1225-1226 punctuation ) +1227-1228 punctuation { +1231-1236 keyword yield +1237-1238 number 1 +1238-1239 punctuation ; +1242-1247 keyword yield +1247-1248 operator * +1249-1250 punctuation [ +1250-1251 number 2 +1251-1252 punctuation , +1253-1254 number 3 +1254-1255 punctuation ] +1255-1256 punctuation ; +1258-1259 punctuation } +1268-1269 operator * +1269-1284 function async_generator +1284-1285 punctuation ( +1285-1286 punctuation ) +1287-1288 punctuation { +1291-1296 keyword yield +1297-1302 special_keyword await +1303-1310 builtin Promise +1310-1311 punctuation . +1311-1318 function resolve +1318-1319 punctuation ( +1319-1320 number 4 +1320-1321 punctuation ) +1321-1322 punctuation ; +1324-1325 punctuation } +1328-1337 keyword protected +1338-1343 keyword async +1344-1360 function protected_method +1360-1361 punctuation ( +1361-1362 punctuation ) +1362-1363 operator : +1364-1371 builtin Promise +1371-1372 operator < +1372-1376 keyword void +1376-1377 operator > +1378-1379 punctuation { +1382-1385 special_keyword try +1386-1387 punctuation { +1391-1396 special_keyword await +1397-1400 keyword new +1401-1408 class_name Promise +1401-1408 builtin Promise +1408-1409 punctuation ( +1409-1410 punctuation ( +1417-1418 punctuation ) +1419-1421 operator => +1422-1432 function setTimeout +1432-1433 punctuation ( +1440-1441 punctuation , +1442-1445 number 100 +1445-1446 punctuation ) +1446-1447 punctuation ) +1447-1448 punctuation ; +1452-1454 special_keyword if +1455-1456 punctuation ( +1460-1461 punctuation . +1461-1467 function random +1467-1468 punctuation ( +1468-1469 punctuation ) +1470-1471 operator > +1472-1475 number 0.5 +1475-1476 punctuation ) 1477-1478 punctuation { -1480-1486 special_keyword return -1489-1490 operator + -1492-1493 punctuation ; -1494-1495 punctuation } -1497-1503 special_keyword export -1504-1509 keyword const -1510-1514 function_variable plus -1515-1516 operator = -1517-1518 punctuation ( -1519-1520 operator : -1521-1524 builtin any -1524-1525 punctuation , -1527-1528 operator : -1529-1532 builtin any -1532-1533 punctuation ) -1533-1534 operator : -1535-1538 builtin any -1539-1541 operator => -1544-1545 operator + -1547-1548 punctuation ; -1550-1572 comment // boundary test cases -1573-1579 special_keyword export -1580-1585 keyword const -1604-1605 operator = -1606-1635 string 'const class function string' -1635-1636 punctuation ; -1637-1643 special_keyword export -1644-1649 keyword const -1667-1668 operator = -1669-1695 string '// this is not a comment' -1695-1696 punctuation ; -1697-1703 special_keyword export -1704-1709 keyword const -1729-1730 operator = -1731-1748 template_string `Value: ${1 + 2}` -1731-1732 template_punctuation ` -1732-1739 string Value: -1739-1747 interpolation ${1 + 2} -1739-1741 interpolation_punctuation ${ -1741-1742 number 1 -1743-1744 operator + -1745-1746 number 2 -1746-1747 interpolation_punctuation } -1747-1748 template_punctuation ` -1748-1749 punctuation ; -1751-1783 comment // regex that looks like comment -1784-1790 special_keyword export -1791-1796 keyword const -1803-1804 operator = -1805-1814 regex /\/\/.*/g -1805-1806 regex_delimiter / -1806-1812 regex_source \/\/.* -1812-1813 regex_delimiter / -1813-1814 regex_flags g -1814-1815 punctuation ; -1816-1822 special_keyword export -1823-1828 keyword const -1843-1844 operator = -1845-1877 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ -1845-1846 regex_delimiter / -1846-1876 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ -1876-1877 regex_delimiter / -1877-1878 punctuation ; -1880-1936 comment // string in comment should not be highlighted as string -1937-1988 comment // const commented = "this string is in a comment"; +1483-1490 builtin console +1490-1491 punctuation . +1491-1494 function log +1494-1495 punctuation ( +1495-1498 keyword new +1499-1503 class_name Date +1503-1504 punctuation ( +1504-1505 punctuation ) +1505-1506 punctuation ) +1506-1507 punctuation ; +1508-1541 comment // eslint-disable-line no-console +1545-1546 punctuation } +1547-1551 special_keyword else +1552-1554 special_keyword if +1555-1556 punctuation ( +1560-1561 punctuation . +1561-1567 function random +1567-1568 punctuation ( +1568-1569 punctuation ) +1570-1571 operator > +1572-1575 number 0.2 +1575-1576 punctuation ) +1577-1578 punctuation { +1583-1590 builtin console +1590-1591 punctuation . +1591-1594 function log +1594-1595 punctuation ( +1595-1611 string 'else if branch' +1611-1612 punctuation ) +1612-1613 punctuation ; +1617-1618 punctuation } +1619-1623 special_keyword else +1624-1625 punctuation { +1630-1637 builtin console +1637-1638 punctuation . +1638-1641 function log +1641-1642 punctuation ( +1642-1655 string 'else branch' +1655-1656 punctuation ) +1656-1657 punctuation ; +1661-1662 punctuation } +1665-1666 punctuation } +1667-1672 special_keyword catch +1673-1674 punctuation ( +1679-1680 operator : +1681-1688 builtin unknown +1688-1689 punctuation ) +1690-1691 punctuation { +1695-1702 builtin console +1702-1703 punctuation . +1703-1708 function error +1708-1709 punctuation ( +1714-1715 punctuation ) +1715-1716 punctuation ; +1719-1720 punctuation } +1721-1728 special_keyword finally +1729-1730 punctuation { +1734-1741 builtin console +1741-1742 punctuation . +1742-1745 function log +1745-1746 punctuation ( +1746-1761 string 'finally block' +1761-1762 punctuation ) +1762-1763 punctuation ; +1766-1767 punctuation } +1769-1770 punctuation } +1771-1772 punctuation } +1774-1784 comment // comment +1786-1829 comment /*\nother comment\n\nconst comment = false;\n*/ +1831-1855 comment /**\n * JSDoc comment\n */ +1857-1863 special_keyword import +1864-1865 punctuation { +1877-1878 punctuation , +1879-1883 keyword type +1884-1895 class_name Sample_Lang +1895-1896 punctuation } +1897-1901 special_keyword from +1902-1921 string '../code_sample.js' +1921-1922 punctuation ; +1923-1929 special_keyword import +1930-1931 operator * +1932-1934 special_keyword as +1935-1936 constant A +1937-1941 special_keyword from +1942-1961 string '../code_sample.js' +1961-1962 punctuation ; +1964-1970 special_keyword export +1971-1972 punctuation { +1973-1974 punctuation , +1975-1976 constant A +1976-1977 punctuation , +1979-1980 punctuation , +1982-1983 punctuation , +1984-1985 constant D +1985-1986 punctuation } +1986-1987 punctuation ; +2002-2004 special_keyword as +2005-2012 builtin unknown +2013-2015 special_keyword as +2016-2019 builtin any +2020-2022 special_keyword as +2056-2057 punctuation ; +2059-2065 special_keyword export +2066-2075 keyword interface +2076-2082 class_name Some_E +2083-2084 punctuation { +2090-2091 operator : +2092-2098 builtin string +2098-2099 punctuation ; +2104-2105 operator : +2106-2112 builtin number +2112-2113 punctuation ; +2114-2115 punctuation } +2117-2123 special_keyword export +2124-2129 keyword const +2136-2137 operator : +2145-2146 operator = +2147-2148 punctuation { +2152-2153 operator : +2154-2161 string 'A. H.' +2161-2162 punctuation , +2166-2167 operator : +2168-2171 number 100 +2171-2172 punctuation } +2172-2173 punctuation ; +2175-2181 special_keyword export +2182-2190 keyword function +2191-2194 function add +2194-2195 punctuation ( +2196-2197 operator : +2198-2204 builtin number +2204-2205 punctuation , +2207-2208 operator : +2209-2215 builtin number +2215-2216 punctuation ) +2216-2217 operator : +2218-2224 builtin number +2225-2226 punctuation { +2228-2234 special_keyword return +2237-2238 operator + +2240-2241 punctuation ; +2242-2243 punctuation } +2245-2251 special_keyword export +2252-2257 keyword const +2258-2262 function_variable plus +2263-2264 operator = +2265-2266 punctuation ( +2267-2268 operator : +2269-2272 builtin any +2272-2273 punctuation , +2275-2276 operator : +2277-2280 builtin any +2280-2281 punctuation ) +2281-2282 operator : +2283-2286 builtin any +2287-2289 operator => +2292-2293 operator + +2295-2296 punctuation ; +2298-2320 comment // boundary test cases +2321-2327 special_keyword export +2328-2333 keyword const +2352-2353 operator = +2354-2383 string 'const class function string' +2383-2384 punctuation ; +2385-2391 special_keyword export +2392-2397 keyword const +2415-2416 operator = +2417-2443 string '// this is not a comment' +2443-2444 punctuation ; +2445-2451 special_keyword export +2452-2457 keyword const +2477-2478 operator = +2479-2496 template_string `Value: ${1 + 2}` +2479-2480 template_punctuation ` +2480-2487 string Value: +2487-2495 interpolation ${1 + 2} +2487-2489 interpolation_punctuation ${ +2489-2490 number 1 +2491-2492 operator + +2493-2494 number 2 +2494-2495 interpolation_punctuation } +2495-2496 template_punctuation ` +2496-2497 punctuation ; +2499-2531 comment // regex that looks like comment +2532-2538 special_keyword export +2539-2544 keyword const +2551-2552 operator = +2553-2562 regex /\/\/.*/g +2553-2554 regex_delimiter / +2554-2560 regex_source \/\/.* +2560-2561 regex_delimiter / +2561-2562 regex_flags g +2562-2563 punctuation ; +2564-2570 special_keyword export +2571-2576 keyword const +2591-2592 operator = +2593-2625 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ +2593-2594 regex_delimiter / +2594-2624 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +2624-2625 regex_delimiter / +2625-2626 punctuation ; +2628-2684 comment // string in comment should not be highlighted as string +2685-2736 comment // const commented = "this string is in a comment"; === STATS === -Total tokens: 394 -Sample length: 1989 characters +Total tokens: 549 +Sample length: 2737 characters Token types: - punctuation: 152 - operator: 53 - special_keyword: 37 - keyword: 32 - builtin: 23 - string: 16 - function: 15 - number: 10 - comment: 10 - class_name: 8 + punctuation: 216 + operator: 74 + keyword: 52 + special_keyword: 44 + builtin: 33 + function: 26 + string: 23 + number: 14 + comment: 11 + class_name: 10 interpolation_punctuation: 8 template_punctuation: 6 - constant: 4 + constant: 5 interpolation: 4 regex_delimiter: 4 + boolean: 3 + decorator: 3 + at: 3 template_string: 3 - boolean: 2 function_variable: 2 regex: 2 regex_source: 2 diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 0bd5bdc3..fa5b5566 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -94,15 +94,31 @@ const c = true; export type Some_Type = 1 | 'b' | true; -class D { - d1: string = 'd'; +declare const class_decorator: any, property_decorator: any, method_decorator: any; + +abstract class Base { + abstract abstract_method(): void; +} + +@class_decorator +class D extends Base { + readonly d1: string = 'd'; d2: number; d3 = $state(null); + @property_decorator + decorated = true; + constructor(d2: number) { + super(); this.d2 = d2; } + abstract_method(): void { + // implementation + } + + @method_decorator class_method(): string { return \`Hello, \${this.d1}\`; } @@ -110,22 +126,52 @@ class D { instance_method = (): void => { /* ... */ let i = 0; - while (i < 3) i++; + do { + i++; + } while (i < 3); + for (const c2 of this.d1) { if (c2 === 'd') continue; if (!c2) break; this.#private_method(a, c2); } + + switch (this.d1) { + case 'a': + console.log('case a'); + break; + case 'b': + case 'c': + console.log('case b or c'); + break; + default: + console.log('default'); + } + + const obj: {has_d1?: boolean; is_d: boolean} = { + has_d1: 'd1' in this, + is_d: this instanceof D, + }; + delete obj.has_d1; // foo }; #private_method(a2: number, c2: any) { - throw new Error(\`\${this.d1} + throw new Error(\`\${this.d1} multiline etc \${a2 + c2} \`); } + *generator() { + yield 1; + yield* [2, 3]; + } + + async *async_generator() { + yield await Promise.resolve(4); + } + protected async protected_method(): Promise { try { await new Promise((resolve) => setTimeout(resolve, 100)); @@ -136,7 +182,7 @@ class D { } else { console.log('else branch'); } - } catch (error) { + } catch (error: unknown) { console.error(error); } finally { console.log('finally block'); @@ -156,13 +202,13 @@ const comment = false; * JSDoc comment */ -import {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js'; +import {sample_langs, type Sample_Lang} from '../code_sample.js'; import * as A from '../code_sample.js'; -sample_langs as unknown as Code_Sample as any as Sample_Lang; - export {a, A, b, c, D}; +sample_langs as unknown as any as Sample_Lang satisfies Sample_Lang; + export interface Some_E { name: string; age: number; diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index 3e234b71..1247bcb2 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -6,15 +6,31 @@ const c = true; export type Some_Type = 1 | 'b' | true; -class D { - d1: string = 'd'; +declare const class_decorator: any, property_decorator: any, method_decorator: any; + +abstract class Base { + abstract abstract_method(): void; +} + +@class_decorator +class D extends Base { + readonly d1: string = 'd'; d2: number; d3 = $state(null); + @property_decorator + decorated = true; + constructor(d2: number) { + super(); this.d2 = d2; } + abstract_method(): void { + // implementation + } + + @method_decorator class_method(): string { return `Hello, ${this.d1}`; } @@ -22,22 +38,52 @@ class D { instance_method = (): void => { /* ... */ let i = 0; - while (i < 3) i++; + do { + i++; + } while (i < 3); + for (const c2 of this.d1) { if (c2 === 'd') continue; if (!c2) break; this.#private_method(a, c2); } + + switch (this.d1) { + case 'a': + console.log('case a'); + break; + case 'b': + case 'c': + console.log('case b or c'); + break; + default: + console.log('default'); + } + + const obj: {has_d1?: boolean; is_d: boolean} = { + has_d1: 'd1' in this, + is_d: this instanceof D, + }; + delete obj.has_d1; // foo }; #private_method(a2: number, c2: any) { - throw new Error(`${this.d1} + throw new Error(`${this.d1} multiline etc ${a2 + c2} `); } + *generator() { + yield 1; + yield* [2, 3]; + } + + async *async_generator() { + yield await Promise.resolve(4); + } + protected async protected_method(): Promise { try { await new Promise((resolve) => setTimeout(resolve, 100)); @@ -48,7 +94,7 @@ class D { } else { console.log('else branch'); } - } catch (error) { + } catch (error: unknown) { console.error(error); } finally { console.log('finally block'); @@ -68,13 +114,13 @@ const comment = false; * JSDoc comment */ -import {sample_langs, type Code_Sample, type Sample_Lang} from '../code_sample.js'; +import {sample_langs, type Sample_Lang} from '../code_sample.js'; import * as A from '../code_sample.js'; -sample_langs as unknown as Code_Sample as any as Sample_Lang; - export {a, A, b, c, D}; +sample_langs as unknown as any as Sample_Lang satisfies Sample_Lang; + export interface Some_E { name: string; age: number; From 5de8c6bb72390e03dae7d8f35c85da1733cbf583 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 12:10:28 -0400 Subject: [PATCH 15/49] wip --- fixtures/generated/svelte/svelte_complex.json | 2 +- fixtures/generated/ts/ts_complex.json | 862 +++++++++-------- fixtures/generated/ts/ts_complex.txt | 912 +++++++++--------- src/lib/grammar_ts.ts | 5 +- src/lib/samples/all.ts | 2 +- src/lib/samples/sample_complex.ts | 2 +- src/lib/theme.css | 14 +- 7 files changed, 911 insertions(+), 888 deletions(-) diff --git a/fixtures/generated/svelte/svelte_complex.json b/fixtures/generated/svelte/svelte_complex.json index 054751a2..d77b7e9c 100644 --- a/fixtures/generated/svelte/svelte_complex.json +++ b/fixtures/generated/svelte/svelte_complex.json @@ -584,5 +584,5 @@ {"type": "punctuation", "start": 2324, "end": 2326}, {"type": "punctuation", "start": 2331, "end": 2332} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/fixtures/generated/ts/ts_complex.json b/fixtures/generated/ts/ts_complex.json index cd05f3e1..cb94de63 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/fixtures/generated/ts/ts_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "ts", "variant": "complex", - "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", + "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", "filepath": "src/lib/samples/sample_complex.ts" }, "tokens": [ @@ -107,454 +107,462 @@ {"type": "decorator", "start": 486, "end": 503}, {"type": "at", "start": 486, "end": 487}, {"type": "function", "start": 487, "end": 503}, - {"type": "function", "start": 505, "end": 517}, - {"type": "punctuation", "start": 517, "end": 518}, - {"type": "punctuation", "start": 518, "end": 519}, - {"type": "operator", "start": 519, "end": 520}, - {"type": "builtin", "start": 521, "end": 527}, + {"type": "punctuation", "start": 503, "end": 504}, + {"type": "string", "start": 504, "end": 513}, + {"type": "punctuation", "start": 513, "end": 514}, + {"type": "punctuation", "start": 515, "end": 516}, + {"type": "operator", "start": 522, "end": 523}, + {"type": "boolean", "start": 524, "end": 528}, {"type": "punctuation", "start": 528, "end": 529}, - {"type": "special_keyword", "start": 532, "end": 538}, - {"type": "template_string", "start": 539, "end": 558}, - {"type": "template_punctuation", "start": 539, "end": 540}, - {"type": "string", "start": 540, "end": 547}, - {"type": "interpolation", "start": 547, "end": 557}, - {"type": "interpolation_punctuation", "start": 547, "end": 549}, - {"type": "keyword", "start": 549, "end": 553}, - {"type": "punctuation", "start": 553, "end": 554}, - {"type": "interpolation_punctuation", "start": 556, "end": 557}, - {"type": "template_punctuation", "start": 557, "end": 558}, - {"type": "punctuation", "start": 558, "end": 559}, - {"type": "punctuation", "start": 561, "end": 562}, - {"type": "function_variable", "start": 565, "end": 580}, - {"type": "operator", "start": 581, "end": 582}, - {"type": "punctuation", "start": 583, "end": 584}, - {"type": "punctuation", "start": 584, "end": 585}, - {"type": "operator", "start": 585, "end": 586}, - {"type": "keyword", "start": 587, "end": 591}, - {"type": "operator", "start": 592, "end": 594}, - {"type": "punctuation", "start": 595, "end": 596}, - {"type": "comment", "start": 599, "end": 608}, - {"type": "keyword", "start": 611, "end": 614}, - {"type": "operator", "start": 617, "end": 618}, - {"type": "number", "start": 619, "end": 620}, - {"type": "punctuation", "start": 620, "end": 621}, - {"type": "special_keyword", "start": 624, "end": 626}, - {"type": "punctuation", "start": 627, "end": 628}, - {"type": "operator", "start": 633, "end": 635}, - {"type": "punctuation", "start": 635, "end": 636}, - {"type": "punctuation", "start": 639, "end": 640}, - {"type": "special_keyword", "start": 641, "end": 646}, + {"type": "punctuation", "start": 529, "end": 530}, + {"type": "function", "start": 532, "end": 544}, + {"type": "punctuation", "start": 544, "end": 545}, + {"type": "punctuation", "start": 545, "end": 546}, + {"type": "operator", "start": 546, "end": 547}, + {"type": "builtin", "start": 548, "end": 554}, + {"type": "punctuation", "start": 555, "end": 556}, + {"type": "special_keyword", "start": 559, "end": 565}, + {"type": "template_string", "start": 566, "end": 585}, + {"type": "template_punctuation", "start": 566, "end": 567}, + {"type": "string", "start": 567, "end": 574}, + {"type": "interpolation", "start": 574, "end": 584}, + {"type": "interpolation_punctuation", "start": 574, "end": 576}, + {"type": "keyword", "start": 576, "end": 580}, + {"type": "punctuation", "start": 580, "end": 581}, + {"type": "interpolation_punctuation", "start": 583, "end": 584}, + {"type": "template_punctuation", "start": 584, "end": 585}, + {"type": "punctuation", "start": 585, "end": 586}, + {"type": "punctuation", "start": 588, "end": 589}, + {"type": "function_variable", "start": 592, "end": 607}, + {"type": "operator", "start": 608, "end": 609}, + {"type": "punctuation", "start": 610, "end": 611}, + {"type": "punctuation", "start": 611, "end": 612}, + {"type": "operator", "start": 612, "end": 613}, + {"type": "keyword", "start": 614, "end": 618}, + {"type": "operator", "start": 619, "end": 621}, + {"type": "punctuation", "start": 622, "end": 623}, + {"type": "comment", "start": 626, "end": 635}, + {"type": "keyword", "start": 638, "end": 641}, + {"type": "operator", "start": 644, "end": 645}, + {"type": "number", "start": 646, "end": 647}, {"type": "punctuation", "start": 647, "end": 648}, - {"type": "operator", "start": 650, "end": 651}, - {"type": "number", "start": 652, "end": 653}, - {"type": "punctuation", "start": 653, "end": 654}, + {"type": "special_keyword", "start": 651, "end": 653}, {"type": "punctuation", "start": 654, "end": 655}, - {"type": "special_keyword", "start": 659, "end": 662}, - {"type": "punctuation", "start": 663, "end": 664}, - {"type": "keyword", "start": 664, "end": 669}, - {"type": "keyword", "start": 673, "end": 675}, - {"type": "keyword", "start": 676, "end": 680}, + {"type": "operator", "start": 660, "end": 662}, + {"type": "punctuation", "start": 662, "end": 663}, + {"type": "punctuation", "start": 666, "end": 667}, + {"type": "special_keyword", "start": 668, "end": 673}, + {"type": "punctuation", "start": 674, "end": 675}, + {"type": "operator", "start": 677, "end": 678}, + {"type": "number", "start": 679, "end": 680}, {"type": "punctuation", "start": 680, "end": 681}, - {"type": "punctuation", "start": 683, "end": 684}, - {"type": "punctuation", "start": 685, "end": 686}, - {"type": "special_keyword", "start": 690, "end": 692}, - {"type": "punctuation", "start": 693, "end": 694}, - {"type": "operator", "start": 697, "end": 700}, - {"type": "string", "start": 701, "end": 704}, - {"type": "punctuation", "start": 704, "end": 705}, - {"type": "special_keyword", "start": 706, "end": 714}, - {"type": "punctuation", "start": 714, "end": 715}, - {"type": "special_keyword", "start": 719, "end": 721}, - {"type": "punctuation", "start": 722, "end": 723}, - {"type": "operator", "start": 723, "end": 724}, - {"type": "punctuation", "start": 726, "end": 727}, - {"type": "special_keyword", "start": 728, "end": 733}, - {"type": "punctuation", "start": 733, "end": 734}, - {"type": "keyword", "start": 738, "end": 742}, - {"type": "punctuation", "start": 742, "end": 743}, - {"type": "function", "start": 743, "end": 758}, - {"type": "punctuation", "start": 758, "end": 759}, + {"type": "punctuation", "start": 681, "end": 682}, + {"type": "special_keyword", "start": 686, "end": 689}, + {"type": "punctuation", "start": 690, "end": 691}, + {"type": "keyword", "start": 691, "end": 696}, + {"type": "keyword", "start": 700, "end": 702}, + {"type": "keyword", "start": 703, "end": 707}, + {"type": "punctuation", "start": 707, "end": 708}, + {"type": "punctuation", "start": 710, "end": 711}, + {"type": "punctuation", "start": 712, "end": 713}, + {"type": "special_keyword", "start": 717, "end": 719}, + {"type": "punctuation", "start": 720, "end": 721}, + {"type": "operator", "start": 724, "end": 727}, + {"type": "string", "start": 728, "end": 731}, + {"type": "punctuation", "start": 731, "end": 732}, + {"type": "special_keyword", "start": 733, "end": 741}, + {"type": "punctuation", "start": 741, "end": 742}, + {"type": "special_keyword", "start": 746, "end": 748}, + {"type": "punctuation", "start": 749, "end": 750}, + {"type": "operator", "start": 750, "end": 751}, + {"type": "punctuation", "start": 753, "end": 754}, + {"type": "special_keyword", "start": 755, "end": 760}, {"type": "punctuation", "start": 760, "end": 761}, - {"type": "punctuation", "start": 764, "end": 765}, - {"type": "punctuation", "start": 765, "end": 766}, + {"type": "keyword", "start": 765, "end": 769}, {"type": "punctuation", "start": 769, "end": 770}, - {"type": "special_keyword", "start": 774, "end": 780}, - {"type": "punctuation", "start": 781, "end": 782}, - {"type": "keyword", "start": 782, "end": 786}, - {"type": "punctuation", "start": 786, "end": 787}, - {"type": "punctuation", "start": 789, "end": 790}, + {"type": "function", "start": 770, "end": 785}, + {"type": "punctuation", "start": 785, "end": 786}, + {"type": "punctuation", "start": 787, "end": 788}, {"type": "punctuation", "start": 791, "end": 792}, - {"type": "special_keyword", "start": 796, "end": 800}, - {"type": "string", "start": 801, "end": 804}, - {"type": "operator", "start": 804, "end": 805}, - {"type": "builtin", "start": 810, "end": 817}, - {"type": "punctuation", "start": 817, "end": 818}, - {"type": "function", "start": 818, "end": 821}, - {"type": "punctuation", "start": 821, "end": 822}, - {"type": "string", "start": 822, "end": 830}, - {"type": "punctuation", "start": 830, "end": 831}, - {"type": "punctuation", "start": 831, "end": 832}, - {"type": "special_keyword", "start": 837, "end": 842}, - {"type": "punctuation", "start": 842, "end": 843}, - {"type": "special_keyword", "start": 847, "end": 851}, - {"type": "string", "start": 852, "end": 855}, - {"type": "operator", "start": 855, "end": 856}, - {"type": "special_keyword", "start": 860, "end": 864}, - {"type": "string", "start": 865, "end": 868}, - {"type": "operator", "start": 868, "end": 869}, - {"type": "builtin", "start": 874, "end": 881}, - {"type": "punctuation", "start": 881, "end": 882}, - {"type": "function", "start": 882, "end": 885}, - {"type": "punctuation", "start": 885, "end": 886}, - {"type": "string", "start": 886, "end": 899}, - {"type": "punctuation", "start": 899, "end": 900}, - {"type": "punctuation", "start": 900, "end": 901}, - {"type": "special_keyword", "start": 906, "end": 911}, - {"type": "punctuation", "start": 911, "end": 912}, - {"type": "keyword", "start": 916, "end": 923}, - {"type": "operator", "start": 923, "end": 924}, - {"type": "builtin", "start": 929, "end": 936}, - {"type": "punctuation", "start": 936, "end": 937}, - {"type": "function", "start": 937, "end": 940}, - {"type": "punctuation", "start": 940, "end": 941}, - {"type": "string", "start": 941, "end": 950}, - {"type": "punctuation", "start": 950, "end": 951}, - {"type": "punctuation", "start": 951, "end": 952}, - {"type": "punctuation", "start": 955, "end": 956}, - {"type": "keyword", "start": 960, "end": 965}, - {"type": "operator", "start": 969, "end": 970}, - {"type": "punctuation", "start": 971, "end": 972}, - {"type": "operator", "start": 978, "end": 979}, - {"type": "operator", "start": 979, "end": 980}, - {"type": "builtin", "start": 981, "end": 988}, - {"type": "punctuation", "start": 988, "end": 989}, - {"type": "operator", "start": 994, "end": 995}, - {"type": "builtin", "start": 996, "end": 1003}, - {"type": "punctuation", "start": 1003, "end": 1004}, + {"type": "punctuation", "start": 792, "end": 793}, + {"type": "punctuation", "start": 796, "end": 797}, + {"type": "special_keyword", "start": 801, "end": 807}, + {"type": "punctuation", "start": 808, "end": 809}, + {"type": "keyword", "start": 809, "end": 813}, + {"type": "punctuation", "start": 813, "end": 814}, + {"type": "punctuation", "start": 816, "end": 817}, + {"type": "punctuation", "start": 818, "end": 819}, + {"type": "special_keyword", "start": 823, "end": 827}, + {"type": "string", "start": 828, "end": 831}, + {"type": "operator", "start": 831, "end": 832}, + {"type": "builtin", "start": 837, "end": 844}, + {"type": "punctuation", "start": 844, "end": 845}, + {"type": "function", "start": 845, "end": 848}, + {"type": "punctuation", "start": 848, "end": 849}, + {"type": "string", "start": 849, "end": 857}, + {"type": "punctuation", "start": 857, "end": 858}, + {"type": "punctuation", "start": 858, "end": 859}, + {"type": "special_keyword", "start": 864, "end": 869}, + {"type": "punctuation", "start": 869, "end": 870}, + {"type": "special_keyword", "start": 874, "end": 878}, + {"type": "string", "start": 879, "end": 882}, + {"type": "operator", "start": 882, "end": 883}, + {"type": "special_keyword", "start": 887, "end": 891}, + {"type": "string", "start": 892, "end": 895}, + {"type": "operator", "start": 895, "end": 896}, + {"type": "builtin", "start": 901, "end": 908}, + {"type": "punctuation", "start": 908, "end": 909}, + {"type": "function", "start": 909, "end": 912}, + {"type": "punctuation", "start": 912, "end": 913}, + {"type": "string", "start": 913, "end": 926}, + {"type": "punctuation", "start": 926, "end": 927}, + {"type": "punctuation", "start": 927, "end": 928}, + {"type": "special_keyword", "start": 933, "end": 938}, + {"type": "punctuation", "start": 938, "end": 939}, + {"type": "keyword", "start": 943, "end": 950}, + {"type": "operator", "start": 950, "end": 951}, + {"type": "builtin", "start": 956, "end": 963}, + {"type": "punctuation", "start": 963, "end": 964}, + {"type": "function", "start": 964, "end": 967}, + {"type": "punctuation", "start": 967, "end": 968}, + {"type": "string", "start": 968, "end": 977}, + {"type": "punctuation", "start": 977, "end": 978}, + {"type": "punctuation", "start": 978, "end": 979}, + {"type": "punctuation", "start": 982, "end": 983}, + {"type": "keyword", "start": 987, "end": 992}, + {"type": "operator", "start": 996, "end": 997}, + {"type": "punctuation", "start": 998, "end": 999}, {"type": "operator", "start": 1005, "end": 1006}, - {"type": "punctuation", "start": 1007, "end": 1008}, - {"type": "operator", "start": 1018, "end": 1019}, - {"type": "string", "start": 1020, "end": 1024}, - {"type": "keyword", "start": 1025, "end": 1027}, - {"type": "keyword", "start": 1028, "end": 1032}, - {"type": "punctuation", "start": 1032, "end": 1033}, - {"type": "operator", "start": 1041, "end": 1042}, - {"type": "keyword", "start": 1043, "end": 1047}, - {"type": "keyword", "start": 1048, "end": 1058}, - {"type": "class_name", "start": 1059, "end": 1060}, - {"type": "constant", "start": 1059, "end": 1060}, - {"type": "punctuation", "start": 1060, "end": 1061}, - {"type": "punctuation", "start": 1064, "end": 1065}, - {"type": "punctuation", "start": 1065, "end": 1066}, - {"type": "keyword", "start": 1069, "end": 1075}, - {"type": "punctuation", "start": 1079, "end": 1080}, - {"type": "punctuation", "start": 1086, "end": 1087}, - {"type": "comment", "start": 1090, "end": 1096}, - {"type": "punctuation", "start": 1098, "end": 1099}, - {"type": "punctuation", "start": 1099, "end": 1100}, - {"type": "function", "start": 1103, "end": 1118}, - {"type": "punctuation", "start": 1118, "end": 1119}, - {"type": "operator", "start": 1121, "end": 1122}, - {"type": "builtin", "start": 1123, "end": 1129}, - {"type": "punctuation", "start": 1129, "end": 1130}, - {"type": "operator", "start": 1133, "end": 1134}, - {"type": "builtin", "start": 1135, "end": 1138}, - {"type": "punctuation", "start": 1138, "end": 1139}, - {"type": "punctuation", "start": 1140, "end": 1141}, - {"type": "special_keyword", "start": 1144, "end": 1149}, - {"type": "keyword", "start": 1150, "end": 1153}, - {"type": "class_name", "start": 1154, "end": 1159}, - {"type": "punctuation", "start": 1159, "end": 1160}, - {"type": "template_string", "start": 1160, "end": 1206}, - {"type": "template_punctuation", "start": 1160, "end": 1161}, - {"type": "interpolation", "start": 1161, "end": 1171}, - {"type": "interpolation_punctuation", "start": 1161, "end": 1163}, - {"type": "keyword", "start": 1163, "end": 1167}, + {"type": "operator", "start": 1006, "end": 1007}, + {"type": "builtin", "start": 1008, "end": 1015}, + {"type": "punctuation", "start": 1015, "end": 1016}, + {"type": "operator", "start": 1021, "end": 1022}, + {"type": "builtin", "start": 1023, "end": 1030}, + {"type": "punctuation", "start": 1030, "end": 1031}, + {"type": "operator", "start": 1032, "end": 1033}, + {"type": "punctuation", "start": 1034, "end": 1035}, + {"type": "operator", "start": 1045, "end": 1046}, + {"type": "string", "start": 1047, "end": 1051}, + {"type": "keyword", "start": 1052, "end": 1054}, + {"type": "keyword", "start": 1055, "end": 1059}, + {"type": "punctuation", "start": 1059, "end": 1060}, + {"type": "operator", "start": 1068, "end": 1069}, + {"type": "keyword", "start": 1070, "end": 1074}, + {"type": "keyword", "start": 1075, "end": 1085}, + {"type": "class_name", "start": 1086, "end": 1087}, + {"type": "constant", "start": 1086, "end": 1087}, + {"type": "punctuation", "start": 1087, "end": 1088}, + {"type": "punctuation", "start": 1091, "end": 1092}, + {"type": "punctuation", "start": 1092, "end": 1093}, + {"type": "keyword", "start": 1096, "end": 1102}, + {"type": "punctuation", "start": 1106, "end": 1107}, + {"type": "punctuation", "start": 1113, "end": 1114}, + {"type": "comment", "start": 1117, "end": 1123}, + {"type": "punctuation", "start": 1125, "end": 1126}, + {"type": "punctuation", "start": 1126, "end": 1127}, + {"type": "function", "start": 1130, "end": 1145}, + {"type": "punctuation", "start": 1145, "end": 1146}, + {"type": "operator", "start": 1148, "end": 1149}, + {"type": "builtin", "start": 1150, "end": 1156}, + {"type": "punctuation", "start": 1156, "end": 1157}, + {"type": "operator", "start": 1160, "end": 1161}, + {"type": "builtin", "start": 1162, "end": 1165}, + {"type": "punctuation", "start": 1165, "end": 1166}, {"type": "punctuation", "start": 1167, "end": 1168}, - {"type": "interpolation_punctuation", "start": 1170, "end": 1171}, - {"type": "string", "start": 1171, "end": 1192}, - {"type": "interpolation", "start": 1192, "end": 1202}, - {"type": "interpolation_punctuation", "start": 1192, "end": 1194}, - {"type": "operator", "start": 1197, "end": 1198}, - {"type": "interpolation_punctuation", "start": 1201, "end": 1202}, - {"type": "string", "start": 1202, "end": 1205}, - {"type": "template_punctuation", "start": 1205, "end": 1206}, - {"type": "punctuation", "start": 1206, "end": 1207}, - {"type": "punctuation", "start": 1207, "end": 1208}, - {"type": "punctuation", "start": 1210, "end": 1211}, - {"type": "operator", "start": 1214, "end": 1215}, - {"type": "function", "start": 1215, "end": 1224}, - {"type": "punctuation", "start": 1224, "end": 1225}, - {"type": "punctuation", "start": 1225, "end": 1226}, - {"type": "punctuation", "start": 1227, "end": 1228}, - {"type": "keyword", "start": 1231, "end": 1236}, - {"type": "number", "start": 1237, "end": 1238}, - {"type": "punctuation", "start": 1238, "end": 1239}, - {"type": "keyword", "start": 1242, "end": 1247}, - {"type": "operator", "start": 1247, "end": 1248}, - {"type": "punctuation", "start": 1249, "end": 1250}, - {"type": "number", "start": 1250, "end": 1251}, + {"type": "special_keyword", "start": 1171, "end": 1176}, + {"type": "keyword", "start": 1177, "end": 1180}, + {"type": "class_name", "start": 1181, "end": 1186}, + {"type": "punctuation", "start": 1186, "end": 1187}, + {"type": "template_string", "start": 1187, "end": 1233}, + {"type": "template_punctuation", "start": 1187, "end": 1188}, + {"type": "interpolation", "start": 1188, "end": 1198}, + {"type": "interpolation_punctuation", "start": 1188, "end": 1190}, + {"type": "keyword", "start": 1190, "end": 1194}, + {"type": "punctuation", "start": 1194, "end": 1195}, + {"type": "interpolation_punctuation", "start": 1197, "end": 1198}, + {"type": "string", "start": 1198, "end": 1219}, + {"type": "interpolation", "start": 1219, "end": 1229}, + {"type": "interpolation_punctuation", "start": 1219, "end": 1221}, + {"type": "operator", "start": 1224, "end": 1225}, + {"type": "interpolation_punctuation", "start": 1228, "end": 1229}, + {"type": "string", "start": 1229, "end": 1232}, + {"type": "template_punctuation", "start": 1232, "end": 1233}, + {"type": "punctuation", "start": 1233, "end": 1234}, + {"type": "punctuation", "start": 1234, "end": 1235}, + {"type": "punctuation", "start": 1237, "end": 1238}, + {"type": "operator", "start": 1241, "end": 1242}, + {"type": "function", "start": 1242, "end": 1251}, {"type": "punctuation", "start": 1251, "end": 1252}, - {"type": "number", "start": 1253, "end": 1254}, + {"type": "punctuation", "start": 1252, "end": 1253}, {"type": "punctuation", "start": 1254, "end": 1255}, - {"type": "punctuation", "start": 1255, "end": 1256}, - {"type": "punctuation", "start": 1258, "end": 1259}, - {"type": "operator", "start": 1268, "end": 1269}, - {"type": "function", "start": 1269, "end": 1284}, - {"type": "punctuation", "start": 1284, "end": 1285}, + {"type": "keyword", "start": 1258, "end": 1263}, + {"type": "number", "start": 1264, "end": 1265}, + {"type": "punctuation", "start": 1265, "end": 1266}, + {"type": "keyword", "start": 1269, "end": 1274}, + {"type": "operator", "start": 1274, "end": 1275}, + {"type": "punctuation", "start": 1276, "end": 1277}, + {"type": "number", "start": 1277, "end": 1278}, + {"type": "punctuation", "start": 1278, "end": 1279}, + {"type": "number", "start": 1280, "end": 1281}, + {"type": "punctuation", "start": 1281, "end": 1282}, + {"type": "punctuation", "start": 1282, "end": 1283}, {"type": "punctuation", "start": 1285, "end": 1286}, - {"type": "punctuation", "start": 1287, "end": 1288}, - {"type": "keyword", "start": 1291, "end": 1296}, - {"type": "special_keyword", "start": 1297, "end": 1302}, - {"type": "builtin", "start": 1303, "end": 1310}, - {"type": "punctuation", "start": 1310, "end": 1311}, - {"type": "function", "start": 1311, "end": 1318}, - {"type": "punctuation", "start": 1318, "end": 1319}, - {"type": "number", "start": 1319, "end": 1320}, - {"type": "punctuation", "start": 1320, "end": 1321}, - {"type": "punctuation", "start": 1321, "end": 1322}, - {"type": "punctuation", "start": 1324, "end": 1325}, - {"type": "keyword", "start": 1328, "end": 1337}, - {"type": "keyword", "start": 1338, "end": 1343}, - {"type": "function", "start": 1344, "end": 1360}, - {"type": "punctuation", "start": 1360, "end": 1361}, - {"type": "punctuation", "start": 1361, "end": 1362}, - {"type": "operator", "start": 1362, "end": 1363}, - {"type": "builtin", "start": 1364, "end": 1371}, - {"type": "operator", "start": 1371, "end": 1372}, - {"type": "keyword", "start": 1372, "end": 1376}, - {"type": "operator", "start": 1376, "end": 1377}, - {"type": "punctuation", "start": 1378, "end": 1379}, - {"type": "special_keyword", "start": 1382, "end": 1385}, - {"type": "punctuation", "start": 1386, "end": 1387}, - {"type": "special_keyword", "start": 1391, "end": 1396}, - {"type": "keyword", "start": 1397, "end": 1400}, - {"type": "class_name", "start": 1401, "end": 1408}, - {"type": "builtin", "start": 1401, "end": 1408}, - {"type": "punctuation", "start": 1408, "end": 1409}, - {"type": "punctuation", "start": 1409, "end": 1410}, - {"type": "punctuation", "start": 1417, "end": 1418}, - {"type": "operator", "start": 1419, "end": 1421}, - {"type": "function", "start": 1422, "end": 1432}, - {"type": "punctuation", "start": 1432, "end": 1433}, - {"type": "punctuation", "start": 1440, "end": 1441}, - {"type": "number", "start": 1442, "end": 1445}, - {"type": "punctuation", "start": 1445, "end": 1446}, - {"type": "punctuation", "start": 1446, "end": 1447}, - {"type": "punctuation", "start": 1447, "end": 1448}, - {"type": "special_keyword", "start": 1452, "end": 1454}, - {"type": "punctuation", "start": 1455, "end": 1456}, - {"type": "punctuation", "start": 1460, "end": 1461}, - {"type": "function", "start": 1461, "end": 1467}, + {"type": "operator", "start": 1295, "end": 1296}, + {"type": "function", "start": 1296, "end": 1311}, + {"type": "punctuation", "start": 1311, "end": 1312}, + {"type": "punctuation", "start": 1312, "end": 1313}, + {"type": "punctuation", "start": 1314, "end": 1315}, + {"type": "keyword", "start": 1318, "end": 1323}, + {"type": "special_keyword", "start": 1324, "end": 1329}, + {"type": "builtin", "start": 1330, "end": 1337}, + {"type": "punctuation", "start": 1337, "end": 1338}, + {"type": "function", "start": 1338, "end": 1345}, + {"type": "punctuation", "start": 1345, "end": 1346}, + {"type": "number", "start": 1346, "end": 1347}, + {"type": "punctuation", "start": 1347, "end": 1348}, + {"type": "punctuation", "start": 1348, "end": 1349}, + {"type": "punctuation", "start": 1351, "end": 1352}, + {"type": "keyword", "start": 1355, "end": 1364}, + {"type": "keyword", "start": 1365, "end": 1370}, + {"type": "function", "start": 1371, "end": 1387}, + {"type": "punctuation", "start": 1387, "end": 1388}, + {"type": "punctuation", "start": 1388, "end": 1389}, + {"type": "operator", "start": 1389, "end": 1390}, + {"type": "builtin", "start": 1391, "end": 1398}, + {"type": "operator", "start": 1398, "end": 1399}, + {"type": "keyword", "start": 1399, "end": 1403}, + {"type": "operator", "start": 1403, "end": 1404}, + {"type": "punctuation", "start": 1405, "end": 1406}, + {"type": "special_keyword", "start": 1409, "end": 1412}, + {"type": "punctuation", "start": 1413, "end": 1414}, + {"type": "special_keyword", "start": 1418, "end": 1423}, + {"type": "keyword", "start": 1424, "end": 1427}, + {"type": "class_name", "start": 1428, "end": 1435}, + {"type": "builtin", "start": 1428, "end": 1435}, + {"type": "punctuation", "start": 1435, "end": 1436}, + {"type": "punctuation", "start": 1436, "end": 1437}, + {"type": "punctuation", "start": 1444, "end": 1445}, + {"type": "operator", "start": 1446, "end": 1448}, + {"type": "function", "start": 1449, "end": 1459}, + {"type": "punctuation", "start": 1459, "end": 1460}, {"type": "punctuation", "start": 1467, "end": 1468}, - {"type": "punctuation", "start": 1468, "end": 1469}, - {"type": "operator", "start": 1470, "end": 1471}, - {"type": "number", "start": 1472, "end": 1475}, - {"type": "punctuation", "start": 1475, "end": 1476}, - {"type": "punctuation", "start": 1477, "end": 1478}, - {"type": "builtin", "start": 1483, "end": 1490}, - {"type": "punctuation", "start": 1490, "end": 1491}, - {"type": "function", "start": 1491, "end": 1494}, + {"type": "number", "start": 1469, "end": 1472}, + {"type": "punctuation", "start": 1472, "end": 1473}, + {"type": "punctuation", "start": 1473, "end": 1474}, + {"type": "punctuation", "start": 1474, "end": 1475}, + {"type": "special_keyword", "start": 1479, "end": 1481}, + {"type": "punctuation", "start": 1482, "end": 1483}, + {"type": "punctuation", "start": 1487, "end": 1488}, + {"type": "function", "start": 1488, "end": 1494}, {"type": "punctuation", "start": 1494, "end": 1495}, - {"type": "keyword", "start": 1495, "end": 1498}, - {"type": "class_name", "start": 1499, "end": 1503}, - {"type": "punctuation", "start": 1503, "end": 1504}, + {"type": "punctuation", "start": 1495, "end": 1496}, + {"type": "operator", "start": 1497, "end": 1498}, + {"type": "number", "start": 1499, "end": 1502}, + {"type": "punctuation", "start": 1502, "end": 1503}, {"type": "punctuation", "start": 1504, "end": 1505}, - {"type": "punctuation", "start": 1505, "end": 1506}, - {"type": "punctuation", "start": 1506, "end": 1507}, - {"type": "comment", "start": 1508, "end": 1541}, - {"type": "punctuation", "start": 1545, "end": 1546}, - {"type": "special_keyword", "start": 1547, "end": 1551}, - {"type": "special_keyword", "start": 1552, "end": 1554}, - {"type": "punctuation", "start": 1555, "end": 1556}, - {"type": "punctuation", "start": 1560, "end": 1561}, - {"type": "function", "start": 1561, "end": 1567}, - {"type": "punctuation", "start": 1567, "end": 1568}, - {"type": "punctuation", "start": 1568, "end": 1569}, - {"type": "operator", "start": 1570, "end": 1571}, - {"type": "number", "start": 1572, "end": 1575}, - {"type": "punctuation", "start": 1575, "end": 1576}, - {"type": "punctuation", "start": 1577, "end": 1578}, - {"type": "builtin", "start": 1583, "end": 1590}, - {"type": "punctuation", "start": 1590, "end": 1591}, - {"type": "function", "start": 1591, "end": 1594}, + {"type": "builtin", "start": 1510, "end": 1517}, + {"type": "punctuation", "start": 1517, "end": 1518}, + {"type": "function", "start": 1518, "end": 1521}, + {"type": "punctuation", "start": 1521, "end": 1522}, + {"type": "keyword", "start": 1522, "end": 1525}, + {"type": "class_name", "start": 1526, "end": 1530}, + {"type": "punctuation", "start": 1530, "end": 1531}, + {"type": "punctuation", "start": 1531, "end": 1532}, + {"type": "punctuation", "start": 1532, "end": 1533}, + {"type": "punctuation", "start": 1533, "end": 1534}, + {"type": "comment", "start": 1535, "end": 1568}, + {"type": "punctuation", "start": 1572, "end": 1573}, + {"type": "special_keyword", "start": 1574, "end": 1578}, + {"type": "special_keyword", "start": 1579, "end": 1581}, + {"type": "punctuation", "start": 1582, "end": 1583}, + {"type": "punctuation", "start": 1587, "end": 1588}, + {"type": "function", "start": 1588, "end": 1594}, {"type": "punctuation", "start": 1594, "end": 1595}, - {"type": "string", "start": 1595, "end": 1611}, - {"type": "punctuation", "start": 1611, "end": 1612}, - {"type": "punctuation", "start": 1612, "end": 1613}, + {"type": "punctuation", "start": 1595, "end": 1596}, + {"type": "operator", "start": 1597, "end": 1598}, + {"type": "number", "start": 1599, "end": 1602}, + {"type": "punctuation", "start": 1602, "end": 1603}, + {"type": "punctuation", "start": 1604, "end": 1605}, + {"type": "builtin", "start": 1610, "end": 1617}, {"type": "punctuation", "start": 1617, "end": 1618}, - {"type": "special_keyword", "start": 1619, "end": 1623}, - {"type": "punctuation", "start": 1624, "end": 1625}, - {"type": "builtin", "start": 1630, "end": 1637}, - {"type": "punctuation", "start": 1637, "end": 1638}, - {"type": "function", "start": 1638, "end": 1641}, - {"type": "punctuation", "start": 1641, "end": 1642}, - {"type": "string", "start": 1642, "end": 1655}, - {"type": "punctuation", "start": 1655, "end": 1656}, - {"type": "punctuation", "start": 1656, "end": 1657}, - {"type": "punctuation", "start": 1661, "end": 1662}, - {"type": "punctuation", "start": 1665, "end": 1666}, - {"type": "special_keyword", "start": 1667, "end": 1672}, - {"type": "punctuation", "start": 1673, "end": 1674}, - {"type": "operator", "start": 1679, "end": 1680}, - {"type": "builtin", "start": 1681, "end": 1688}, + {"type": "function", "start": 1618, "end": 1621}, + {"type": "punctuation", "start": 1621, "end": 1622}, + {"type": "string", "start": 1622, "end": 1638}, + {"type": "punctuation", "start": 1638, "end": 1639}, + {"type": "punctuation", "start": 1639, "end": 1640}, + {"type": "punctuation", "start": 1644, "end": 1645}, + {"type": "special_keyword", "start": 1646, "end": 1650}, + {"type": "punctuation", "start": 1651, "end": 1652}, + {"type": "builtin", "start": 1657, "end": 1664}, + {"type": "punctuation", "start": 1664, "end": 1665}, + {"type": "function", "start": 1665, "end": 1668}, + {"type": "punctuation", "start": 1668, "end": 1669}, + {"type": "string", "start": 1669, "end": 1682}, + {"type": "punctuation", "start": 1682, "end": 1683}, + {"type": "punctuation", "start": 1683, "end": 1684}, {"type": "punctuation", "start": 1688, "end": 1689}, - {"type": "punctuation", "start": 1690, "end": 1691}, - {"type": "builtin", "start": 1695, "end": 1702}, - {"type": "punctuation", "start": 1702, "end": 1703}, - {"type": "function", "start": 1703, "end": 1708}, - {"type": "punctuation", "start": 1708, "end": 1709}, - {"type": "punctuation", "start": 1714, "end": 1715}, + {"type": "punctuation", "start": 1692, "end": 1693}, + {"type": "special_keyword", "start": 1694, "end": 1699}, + {"type": "punctuation", "start": 1700, "end": 1701}, + {"type": "operator", "start": 1706, "end": 1707}, + {"type": "builtin", "start": 1708, "end": 1715}, {"type": "punctuation", "start": 1715, "end": 1716}, - {"type": "punctuation", "start": 1719, "end": 1720}, - {"type": "special_keyword", "start": 1721, "end": 1728}, + {"type": "punctuation", "start": 1717, "end": 1718}, + {"type": "builtin", "start": 1722, "end": 1729}, {"type": "punctuation", "start": 1729, "end": 1730}, - {"type": "builtin", "start": 1734, "end": 1741}, + {"type": "function", "start": 1730, "end": 1735}, + {"type": "punctuation", "start": 1735, "end": 1736}, {"type": "punctuation", "start": 1741, "end": 1742}, - {"type": "function", "start": 1742, "end": 1745}, - {"type": "punctuation", "start": 1745, "end": 1746}, - {"type": "string", "start": 1746, "end": 1761}, - {"type": "punctuation", "start": 1761, "end": 1762}, - {"type": "punctuation", "start": 1762, "end": 1763}, - {"type": "punctuation", "start": 1766, "end": 1767}, - {"type": "punctuation", "start": 1769, "end": 1770}, - {"type": "punctuation", "start": 1771, "end": 1772}, - {"type": "comment", "start": 1774, "end": 1784}, - {"type": "comment", "start": 1786, "end": 1829}, - {"type": "comment", "start": 1831, "end": 1855}, - {"type": "special_keyword", "start": 1857, "end": 1863}, - {"type": "punctuation", "start": 1864, "end": 1865}, - {"type": "punctuation", "start": 1877, "end": 1878}, - {"type": "keyword", "start": 1879, "end": 1883}, - {"type": "class_name", "start": 1884, "end": 1895}, - {"type": "punctuation", "start": 1895, "end": 1896}, - {"type": "special_keyword", "start": 1897, "end": 1901}, - {"type": "string", "start": 1902, "end": 1921}, - {"type": "punctuation", "start": 1921, "end": 1922}, - {"type": "special_keyword", "start": 1923, "end": 1929}, - {"type": "operator", "start": 1930, "end": 1931}, - {"type": "special_keyword", "start": 1932, "end": 1934}, - {"type": "constant", "start": 1935, "end": 1936}, - {"type": "special_keyword", "start": 1937, "end": 1941}, - {"type": "string", "start": 1942, "end": 1961}, - {"type": "punctuation", "start": 1961, "end": 1962}, - {"type": "special_keyword", "start": 1964, "end": 1970}, - {"type": "punctuation", "start": 1971, "end": 1972}, - {"type": "punctuation", "start": 1973, "end": 1974}, - {"type": "constant", "start": 1975, "end": 1976}, - {"type": "punctuation", "start": 1976, "end": 1977}, - {"type": "punctuation", "start": 1979, "end": 1980}, - {"type": "punctuation", "start": 1982, "end": 1983}, - {"type": "constant", "start": 1984, "end": 1985}, - {"type": "punctuation", "start": 1985, "end": 1986}, - {"type": "punctuation", "start": 1986, "end": 1987}, - {"type": "special_keyword", "start": 2002, "end": 2004}, - {"type": "builtin", "start": 2005, "end": 2012}, - {"type": "special_keyword", "start": 2013, "end": 2015}, - {"type": "builtin", "start": 2016, "end": 2019}, - {"type": "special_keyword", "start": 2020, "end": 2022}, - {"type": "punctuation", "start": 2056, "end": 2057}, - {"type": "special_keyword", "start": 2059, "end": 2065}, - {"type": "keyword", "start": 2066, "end": 2075}, - {"type": "class_name", "start": 2076, "end": 2082}, + {"type": "punctuation", "start": 1742, "end": 1743}, + {"type": "punctuation", "start": 1746, "end": 1747}, + {"type": "special_keyword", "start": 1748, "end": 1755}, + {"type": "punctuation", "start": 1756, "end": 1757}, + {"type": "builtin", "start": 1761, "end": 1768}, + {"type": "punctuation", "start": 1768, "end": 1769}, + {"type": "function", "start": 1769, "end": 1772}, + {"type": "punctuation", "start": 1772, "end": 1773}, + {"type": "string", "start": 1773, "end": 1788}, + {"type": "punctuation", "start": 1788, "end": 1789}, + {"type": "punctuation", "start": 1789, "end": 1790}, + {"type": "punctuation", "start": 1793, "end": 1794}, + {"type": "punctuation", "start": 1796, "end": 1797}, + {"type": "punctuation", "start": 1798, "end": 1799}, + {"type": "comment", "start": 1801, "end": 1811}, + {"type": "comment", "start": 1813, "end": 1856}, + {"type": "comment", "start": 1858, "end": 1882}, + {"type": "special_keyword", "start": 1884, "end": 1890}, + {"type": "punctuation", "start": 1891, "end": 1892}, + {"type": "punctuation", "start": 1904, "end": 1905}, + {"type": "keyword", "start": 1906, "end": 1910}, + {"type": "class_name", "start": 1911, "end": 1922}, + {"type": "punctuation", "start": 1922, "end": 1923}, + {"type": "special_keyword", "start": 1924, "end": 1928}, + {"type": "string", "start": 1929, "end": 1948}, + {"type": "punctuation", "start": 1948, "end": 1949}, + {"type": "special_keyword", "start": 1950, "end": 1956}, + {"type": "operator", "start": 1957, "end": 1958}, + {"type": "special_keyword", "start": 1959, "end": 1961}, + {"type": "constant", "start": 1962, "end": 1963}, + {"type": "special_keyword", "start": 1964, "end": 1968}, + {"type": "string", "start": 1969, "end": 1988}, + {"type": "punctuation", "start": 1988, "end": 1989}, + {"type": "special_keyword", "start": 1991, "end": 1997}, + {"type": "punctuation", "start": 1998, "end": 1999}, + {"type": "punctuation", "start": 2000, "end": 2001}, + {"type": "constant", "start": 2002, "end": 2003}, + {"type": "punctuation", "start": 2003, "end": 2004}, + {"type": "punctuation", "start": 2006, "end": 2007}, + {"type": "punctuation", "start": 2009, "end": 2010}, + {"type": "constant", "start": 2011, "end": 2012}, + {"type": "punctuation", "start": 2012, "end": 2013}, + {"type": "punctuation", "start": 2013, "end": 2014}, + {"type": "special_keyword", "start": 2029, "end": 2031}, + {"type": "builtin", "start": 2032, "end": 2039}, + {"type": "special_keyword", "start": 2040, "end": 2042}, + {"type": "builtin", "start": 2043, "end": 2046}, + {"type": "special_keyword", "start": 2047, "end": 2049}, {"type": "punctuation", "start": 2083, "end": 2084}, - {"type": "operator", "start": 2090, "end": 2091}, - {"type": "builtin", "start": 2092, "end": 2098}, - {"type": "punctuation", "start": 2098, "end": 2099}, - {"type": "operator", "start": 2104, "end": 2105}, - {"type": "builtin", "start": 2106, "end": 2112}, - {"type": "punctuation", "start": 2112, "end": 2113}, - {"type": "punctuation", "start": 2114, "end": 2115}, - {"type": "special_keyword", "start": 2117, "end": 2123}, - {"type": "keyword", "start": 2124, "end": 2129}, - {"type": "operator", "start": 2136, "end": 2137}, - {"type": "operator", "start": 2145, "end": 2146}, - {"type": "punctuation", "start": 2147, "end": 2148}, - {"type": "operator", "start": 2152, "end": 2153}, - {"type": "string", "start": 2154, "end": 2161}, - {"type": "punctuation", "start": 2161, "end": 2162}, - {"type": "operator", "start": 2166, "end": 2167}, - {"type": "number", "start": 2168, "end": 2171}, - {"type": "punctuation", "start": 2171, "end": 2172}, - {"type": "punctuation", "start": 2172, "end": 2173}, - {"type": "special_keyword", "start": 2175, "end": 2181}, - {"type": "keyword", "start": 2182, "end": 2190}, - {"type": "function", "start": 2191, "end": 2194}, - {"type": "punctuation", "start": 2194, "end": 2195}, - {"type": "operator", "start": 2196, "end": 2197}, - {"type": "builtin", "start": 2198, "end": 2204}, - {"type": "punctuation", "start": 2204, "end": 2205}, - {"type": "operator", "start": 2207, "end": 2208}, - {"type": "builtin", "start": 2209, "end": 2215}, - {"type": "punctuation", "start": 2215, "end": 2216}, - {"type": "operator", "start": 2216, "end": 2217}, - {"type": "builtin", "start": 2218, "end": 2224}, - {"type": "punctuation", "start": 2225, "end": 2226}, - {"type": "special_keyword", "start": 2228, "end": 2234}, - {"type": "operator", "start": 2237, "end": 2238}, - {"type": "punctuation", "start": 2240, "end": 2241}, + {"type": "special_keyword", "start": 2086, "end": 2092}, + {"type": "keyword", "start": 2093, "end": 2102}, + {"type": "class_name", "start": 2103, "end": 2109}, + {"type": "punctuation", "start": 2110, "end": 2111}, + {"type": "operator", "start": 2117, "end": 2118}, + {"type": "builtin", "start": 2119, "end": 2125}, + {"type": "punctuation", "start": 2125, "end": 2126}, + {"type": "operator", "start": 2131, "end": 2132}, + {"type": "builtin", "start": 2133, "end": 2139}, + {"type": "punctuation", "start": 2139, "end": 2140}, + {"type": "punctuation", "start": 2141, "end": 2142}, + {"type": "special_keyword", "start": 2144, "end": 2150}, + {"type": "keyword", "start": 2151, "end": 2156}, + {"type": "operator", "start": 2163, "end": 2164}, + {"type": "operator", "start": 2172, "end": 2173}, + {"type": "punctuation", "start": 2174, "end": 2175}, + {"type": "operator", "start": 2179, "end": 2180}, + {"type": "string", "start": 2181, "end": 2188}, + {"type": "punctuation", "start": 2188, "end": 2189}, + {"type": "operator", "start": 2193, "end": 2194}, + {"type": "number", "start": 2195, "end": 2198}, + {"type": "punctuation", "start": 2198, "end": 2199}, + {"type": "punctuation", "start": 2199, "end": 2200}, + {"type": "special_keyword", "start": 2202, "end": 2208}, + {"type": "keyword", "start": 2209, "end": 2217}, + {"type": "function", "start": 2218, "end": 2221}, + {"type": "punctuation", "start": 2221, "end": 2222}, + {"type": "operator", "start": 2223, "end": 2224}, + {"type": "builtin", "start": 2225, "end": 2231}, + {"type": "punctuation", "start": 2231, "end": 2232}, + {"type": "operator", "start": 2234, "end": 2235}, + {"type": "builtin", "start": 2236, "end": 2242}, {"type": "punctuation", "start": 2242, "end": 2243}, - {"type": "special_keyword", "start": 2245, "end": 2251}, - {"type": "keyword", "start": 2252, "end": 2257}, - {"type": "function_variable", "start": 2258, "end": 2262}, - {"type": "operator", "start": 2263, "end": 2264}, - {"type": "punctuation", "start": 2265, "end": 2266}, - {"type": "operator", "start": 2267, "end": 2268}, - {"type": "builtin", "start": 2269, "end": 2272}, - {"type": "punctuation", "start": 2272, "end": 2273}, - {"type": "operator", "start": 2275, "end": 2276}, - {"type": "builtin", "start": 2277, "end": 2280}, - {"type": "punctuation", "start": 2280, "end": 2281}, - {"type": "operator", "start": 2281, "end": 2282}, - {"type": "builtin", "start": 2283, "end": 2286}, - {"type": "operator", "start": 2287, "end": 2289}, - {"type": "operator", "start": 2292, "end": 2293}, - {"type": "punctuation", "start": 2295, "end": 2296}, - {"type": "comment", "start": 2298, "end": 2320}, - {"type": "special_keyword", "start": 2321, "end": 2327}, - {"type": "keyword", "start": 2328, "end": 2333}, - {"type": "operator", "start": 2352, "end": 2353}, - {"type": "string", "start": 2354, "end": 2383}, - {"type": "punctuation", "start": 2383, "end": 2384}, - {"type": "special_keyword", "start": 2385, "end": 2391}, - {"type": "keyword", "start": 2392, "end": 2397}, - {"type": "operator", "start": 2415, "end": 2416}, - {"type": "string", "start": 2417, "end": 2443}, - {"type": "punctuation", "start": 2443, "end": 2444}, - {"type": "special_keyword", "start": 2445, "end": 2451}, - {"type": "keyword", "start": 2452, "end": 2457}, - {"type": "operator", "start": 2477, "end": 2478}, - {"type": "template_string", "start": 2479, "end": 2496}, - {"type": "template_punctuation", "start": 2479, "end": 2480}, - {"type": "string", "start": 2480, "end": 2487}, - {"type": "interpolation", "start": 2487, "end": 2495}, - {"type": "interpolation_punctuation", "start": 2487, "end": 2489}, - {"type": "number", "start": 2489, "end": 2490}, - {"type": "operator", "start": 2491, "end": 2492}, - {"type": "number", "start": 2493, "end": 2494}, - {"type": "interpolation_punctuation", "start": 2494, "end": 2495}, - {"type": "template_punctuation", "start": 2495, "end": 2496}, - {"type": "punctuation", "start": 2496, "end": 2497}, - {"type": "comment", "start": 2499, "end": 2531}, - {"type": "special_keyword", "start": 2532, "end": 2538}, - {"type": "keyword", "start": 2539, "end": 2544}, - {"type": "operator", "start": 2551, "end": 2552}, - {"type": "regex", "start": 2553, "end": 2562}, - {"type": "regex_delimiter", "start": 2553, "end": 2554}, - {"type": "regex_source", "start": 2554, "end": 2560}, - {"type": "regex_delimiter", "start": 2560, "end": 2561}, - {"type": "regex_flags", "start": 2561, "end": 2562}, - {"type": "punctuation", "start": 2562, "end": 2563}, - {"type": "special_keyword", "start": 2564, "end": 2570}, - {"type": "keyword", "start": 2571, "end": 2576}, - {"type": "operator", "start": 2591, "end": 2592}, - {"type": "regex", "start": 2593, "end": 2625}, - {"type": "regex_delimiter", "start": 2593, "end": 2594}, - {"type": "regex_source", "start": 2594, "end": 2624}, - {"type": "regex_delimiter", "start": 2624, "end": 2625}, - {"type": "punctuation", "start": 2625, "end": 2626}, - {"type": "comment", "start": 2628, "end": 2684}, - {"type": "comment", "start": 2685, "end": 2736} + {"type": "operator", "start": 2243, "end": 2244}, + {"type": "builtin", "start": 2245, "end": 2251}, + {"type": "punctuation", "start": 2252, "end": 2253}, + {"type": "special_keyword", "start": 2255, "end": 2261}, + {"type": "operator", "start": 2264, "end": 2265}, + {"type": "punctuation", "start": 2267, "end": 2268}, + {"type": "punctuation", "start": 2269, "end": 2270}, + {"type": "special_keyword", "start": 2272, "end": 2278}, + {"type": "keyword", "start": 2279, "end": 2284}, + {"type": "function_variable", "start": 2285, "end": 2289}, + {"type": "operator", "start": 2290, "end": 2291}, + {"type": "punctuation", "start": 2292, "end": 2293}, + {"type": "operator", "start": 2294, "end": 2295}, + {"type": "builtin", "start": 2296, "end": 2299}, + {"type": "punctuation", "start": 2299, "end": 2300}, + {"type": "operator", "start": 2302, "end": 2303}, + {"type": "builtin", "start": 2304, "end": 2307}, + {"type": "punctuation", "start": 2307, "end": 2308}, + {"type": "operator", "start": 2308, "end": 2309}, + {"type": "builtin", "start": 2310, "end": 2313}, + {"type": "operator", "start": 2314, "end": 2316}, + {"type": "operator", "start": 2319, "end": 2320}, + {"type": "punctuation", "start": 2322, "end": 2323}, + {"type": "comment", "start": 2325, "end": 2347}, + {"type": "special_keyword", "start": 2348, "end": 2354}, + {"type": "keyword", "start": 2355, "end": 2360}, + {"type": "operator", "start": 2379, "end": 2380}, + {"type": "string", "start": 2381, "end": 2410}, + {"type": "punctuation", "start": 2410, "end": 2411}, + {"type": "special_keyword", "start": 2412, "end": 2418}, + {"type": "keyword", "start": 2419, "end": 2424}, + {"type": "operator", "start": 2442, "end": 2443}, + {"type": "string", "start": 2444, "end": 2470}, + {"type": "punctuation", "start": 2470, "end": 2471}, + {"type": "special_keyword", "start": 2472, "end": 2478}, + {"type": "keyword", "start": 2479, "end": 2484}, + {"type": "operator", "start": 2504, "end": 2505}, + {"type": "template_string", "start": 2506, "end": 2523}, + {"type": "template_punctuation", "start": 2506, "end": 2507}, + {"type": "string", "start": 2507, "end": 2514}, + {"type": "interpolation", "start": 2514, "end": 2522}, + {"type": "interpolation_punctuation", "start": 2514, "end": 2516}, + {"type": "number", "start": 2516, "end": 2517}, + {"type": "operator", "start": 2518, "end": 2519}, + {"type": "number", "start": 2520, "end": 2521}, + {"type": "interpolation_punctuation", "start": 2521, "end": 2522}, + {"type": "template_punctuation", "start": 2522, "end": 2523}, + {"type": "punctuation", "start": 2523, "end": 2524}, + {"type": "comment", "start": 2526, "end": 2558}, + {"type": "special_keyword", "start": 2559, "end": 2565}, + {"type": "keyword", "start": 2566, "end": 2571}, + {"type": "operator", "start": 2578, "end": 2579}, + {"type": "regex", "start": 2580, "end": 2589}, + {"type": "regex_delimiter", "start": 2580, "end": 2581}, + {"type": "regex_source", "start": 2581, "end": 2587}, + {"type": "regex_delimiter", "start": 2587, "end": 2588}, + {"type": "regex_flags", "start": 2588, "end": 2589}, + {"type": "punctuation", "start": 2589, "end": 2590}, + {"type": "special_keyword", "start": 2591, "end": 2597}, + {"type": "keyword", "start": 2598, "end": 2603}, + {"type": "operator", "start": 2618, "end": 2619}, + {"type": "regex", "start": 2620, "end": 2652}, + {"type": "regex_delimiter", "start": 2620, "end": 2621}, + {"type": "regex_source", "start": 2621, "end": 2651}, + {"type": "regex_delimiter", "start": 2651, "end": 2652}, + {"type": "punctuation", "start": 2652, "end": 2653}, + {"type": "comment", "start": 2655, "end": 2711}, + {"type": "comment", "start": 2712, "end": 2763} ], - "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/fixtures/generated/ts/ts_complex.txt index c873eb1a..8863b917 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/fixtures/generated/ts/ts_complex.txt @@ -100,476 +100,484 @@ 486-503 decorator @method_decorator 486-487 at @ 487-503 function method_decorator - 505-517 function class_method - 517-518 punctuation ( - 518-519 punctuation ) - 519-520 operator : - 521-527 builtin string - 528-529 punctuation { - 532-538 special_keyword return - 539-558 template_string `Hello, ${this.d1}` - 539-540 template_punctuation ` - 540-547 string Hello, - 547-557 interpolation ${this.d1} - 547-549 interpolation_punctuation ${ - 549-553 keyword this - 553-554 punctuation . - 556-557 interpolation_punctuation } - 557-558 template_punctuation ` - 558-559 punctuation ; - 561-562 punctuation } - 565-580 function_variable instance_method - 581-582 operator = - 583-584 punctuation ( - 584-585 punctuation ) - 585-586 operator : - 587-591 keyword void - 592-594 operator => - 595-596 punctuation { - 599-608 comment /* ... */ - 611-614 keyword let - 617-618 operator = - 619-620 number 0 - 620-621 punctuation ; - 624-626 special_keyword do - 627-628 punctuation { - 633-635 operator ++ - 635-636 punctuation ; - 639-640 punctuation } - 641-646 special_keyword while - 647-648 punctuation ( - 650-651 operator < - 652-653 number 3 - 653-654 punctuation ) - 654-655 punctuation ; - 659-662 special_keyword for - 663-664 punctuation ( - 664-669 keyword const - 673-675 keyword of - 676-680 keyword this - 680-681 punctuation . - 683-684 punctuation ) - 685-686 punctuation { - 690-692 special_keyword if - 693-694 punctuation ( - 697-700 operator === - 701-704 string 'd' - 704-705 punctuation ) - 706-714 special_keyword continue - 714-715 punctuation ; - 719-721 special_keyword if - 722-723 punctuation ( - 723-724 operator ! - 726-727 punctuation ) - 728-733 special_keyword break - 733-734 punctuation ; - 738-742 keyword this - 742-743 punctuation . - 743-758 function #private_method - 758-759 punctuation ( - 760-761 punctuation , - 764-765 punctuation ) - 765-766 punctuation ; - 769-770 punctuation } - 774-780 special_keyword switch - 781-782 punctuation ( - 782-786 keyword this - 786-787 punctuation . - 789-790 punctuation ) - 791-792 punctuation { - 796-800 special_keyword case - 801-804 string 'a' - 804-805 operator : - 810-817 builtin console - 817-818 punctuation . - 818-821 function log - 821-822 punctuation ( - 822-830 string 'case a' - 830-831 punctuation ) - 831-832 punctuation ; - 837-842 special_keyword break - 842-843 punctuation ; - 847-851 special_keyword case - 852-855 string 'b' - 855-856 operator : - 860-864 special_keyword case - 865-868 string 'c' - 868-869 operator : - 874-881 builtin console - 881-882 punctuation . - 882-885 function log - 885-886 punctuation ( - 886-899 string 'case b or c' - 899-900 punctuation ) - 900-901 punctuation ; - 906-911 special_keyword break - 911-912 punctuation ; - 916-923 keyword default - 923-924 operator : - 929-936 builtin console - 936-937 punctuation . - 937-940 function log - 940-941 punctuation ( - 941-950 string 'default' - 950-951 punctuation ) - 951-952 punctuation ; - 955-956 punctuation } - 960-965 keyword const - 969-970 operator : - 971-972 punctuation { - 978-979 operator ? - 979-980 operator : - 981-988 builtin boolean - 988-989 punctuation ; - 994-995 operator : - 996-1003 builtin boolean -1003-1004 punctuation } -1005-1006 operator = -1007-1008 punctuation { -1018-1019 operator : -1020-1024 string 'd1' -1025-1027 keyword in -1028-1032 keyword this -1032-1033 punctuation , -1041-1042 operator : -1043-1047 keyword this -1048-1058 keyword instanceof -1059-1060 class_name D -1059-1060 constant D -1060-1061 punctuation , -1064-1065 punctuation } -1065-1066 punctuation ; -1069-1075 keyword delete -1079-1080 punctuation . -1086-1087 punctuation ; -1090-1096 comment // foo -1098-1099 punctuation } -1099-1100 punctuation ; -1103-1118 function #private_method -1118-1119 punctuation ( -1121-1122 operator : -1123-1129 builtin number -1129-1130 punctuation , -1133-1134 operator : -1135-1138 builtin any -1138-1139 punctuation ) -1140-1141 punctuation { -1144-1149 special_keyword throw -1150-1153 keyword new -1154-1159 class_name Error -1159-1160 punctuation ( -1160-1206 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` -1160-1161 template_punctuation ` -1161-1171 interpolation ${this.d1} -1161-1163 interpolation_punctuation ${ -1163-1167 keyword this -1167-1168 punctuation . -1170-1171 interpolation_punctuation } -1171-1192 string \n\t\t\tmultiline\n\t\t\tetc -1192-1202 interpolation ${a2 + c2} -1192-1194 interpolation_punctuation ${ -1197-1198 operator + -1201-1202 interpolation_punctuation } -1202-1205 string \n\t\t -1205-1206 template_punctuation ` -1206-1207 punctuation ) -1207-1208 punctuation ; -1210-1211 punctuation } -1214-1215 operator * -1215-1224 function generator -1224-1225 punctuation ( -1225-1226 punctuation ) -1227-1228 punctuation { -1231-1236 keyword yield -1237-1238 number 1 -1238-1239 punctuation ; -1242-1247 keyword yield -1247-1248 operator * -1249-1250 punctuation [ -1250-1251 number 2 -1251-1252 punctuation , -1253-1254 number 3 -1254-1255 punctuation ] -1255-1256 punctuation ; -1258-1259 punctuation } -1268-1269 operator * -1269-1284 function async_generator -1284-1285 punctuation ( -1285-1286 punctuation ) -1287-1288 punctuation { -1291-1296 keyword yield -1297-1302 special_keyword await -1303-1310 builtin Promise -1310-1311 punctuation . -1311-1318 function resolve -1318-1319 punctuation ( -1319-1320 number 4 -1320-1321 punctuation ) -1321-1322 punctuation ; -1324-1325 punctuation } -1328-1337 keyword protected -1338-1343 keyword async -1344-1360 function protected_method -1360-1361 punctuation ( -1361-1362 punctuation ) -1362-1363 operator : -1364-1371 builtin Promise -1371-1372 operator < -1372-1376 keyword void -1376-1377 operator > -1378-1379 punctuation { -1382-1385 special_keyword try -1386-1387 punctuation { -1391-1396 special_keyword await -1397-1400 keyword new -1401-1408 class_name Promise -1401-1408 builtin Promise -1408-1409 punctuation ( -1409-1410 punctuation ( -1417-1418 punctuation ) -1419-1421 operator => -1422-1432 function setTimeout -1432-1433 punctuation ( -1440-1441 punctuation , -1442-1445 number 100 -1445-1446 punctuation ) -1446-1447 punctuation ) -1447-1448 punctuation ; -1452-1454 special_keyword if -1455-1456 punctuation ( -1460-1461 punctuation . -1461-1467 function random -1467-1468 punctuation ( -1468-1469 punctuation ) -1470-1471 operator > -1472-1475 number 0.5 -1475-1476 punctuation ) -1477-1478 punctuation { -1483-1490 builtin console -1490-1491 punctuation . -1491-1494 function log + 503-504 punctuation ( + 504-513 string 'example' + 513-514 punctuation , + 515-516 punctuation { + 522-523 operator : + 524-528 boolean true + 528-529 punctuation } + 529-530 punctuation ) + 532-544 function class_method + 544-545 punctuation ( + 545-546 punctuation ) + 546-547 operator : + 548-554 builtin string + 555-556 punctuation { + 559-565 special_keyword return + 566-585 template_string `Hello, ${this.d1}` + 566-567 template_punctuation ` + 567-574 string Hello, + 574-584 interpolation ${this.d1} + 574-576 interpolation_punctuation ${ + 576-580 keyword this + 580-581 punctuation . + 583-584 interpolation_punctuation } + 584-585 template_punctuation ` + 585-586 punctuation ; + 588-589 punctuation } + 592-607 function_variable instance_method + 608-609 operator = + 610-611 punctuation ( + 611-612 punctuation ) + 612-613 operator : + 614-618 keyword void + 619-621 operator => + 622-623 punctuation { + 626-635 comment /* ... */ + 638-641 keyword let + 644-645 operator = + 646-647 number 0 + 647-648 punctuation ; + 651-653 special_keyword do + 654-655 punctuation { + 660-662 operator ++ + 662-663 punctuation ; + 666-667 punctuation } + 668-673 special_keyword while + 674-675 punctuation ( + 677-678 operator < + 679-680 number 3 + 680-681 punctuation ) + 681-682 punctuation ; + 686-689 special_keyword for + 690-691 punctuation ( + 691-696 keyword const + 700-702 keyword of + 703-707 keyword this + 707-708 punctuation . + 710-711 punctuation ) + 712-713 punctuation { + 717-719 special_keyword if + 720-721 punctuation ( + 724-727 operator === + 728-731 string 'd' + 731-732 punctuation ) + 733-741 special_keyword continue + 741-742 punctuation ; + 746-748 special_keyword if + 749-750 punctuation ( + 750-751 operator ! + 753-754 punctuation ) + 755-760 special_keyword break + 760-761 punctuation ; + 765-769 keyword this + 769-770 punctuation . + 770-785 function #private_method + 785-786 punctuation ( + 787-788 punctuation , + 791-792 punctuation ) + 792-793 punctuation ; + 796-797 punctuation } + 801-807 special_keyword switch + 808-809 punctuation ( + 809-813 keyword this + 813-814 punctuation . + 816-817 punctuation ) + 818-819 punctuation { + 823-827 special_keyword case + 828-831 string 'a' + 831-832 operator : + 837-844 builtin console + 844-845 punctuation . + 845-848 function log + 848-849 punctuation ( + 849-857 string 'case a' + 857-858 punctuation ) + 858-859 punctuation ; + 864-869 special_keyword break + 869-870 punctuation ; + 874-878 special_keyword case + 879-882 string 'b' + 882-883 operator : + 887-891 special_keyword case + 892-895 string 'c' + 895-896 operator : + 901-908 builtin console + 908-909 punctuation . + 909-912 function log + 912-913 punctuation ( + 913-926 string 'case b or c' + 926-927 punctuation ) + 927-928 punctuation ; + 933-938 special_keyword break + 938-939 punctuation ; + 943-950 keyword default + 950-951 operator : + 956-963 builtin console + 963-964 punctuation . + 964-967 function log + 967-968 punctuation ( + 968-977 string 'default' + 977-978 punctuation ) + 978-979 punctuation ; + 982-983 punctuation } + 987-992 keyword const + 996-997 operator : + 998-999 punctuation { +1005-1006 operator ? +1006-1007 operator : +1008-1015 builtin boolean +1015-1016 punctuation ; +1021-1022 operator : +1023-1030 builtin boolean +1030-1031 punctuation } +1032-1033 operator = +1034-1035 punctuation { +1045-1046 operator : +1047-1051 string 'd1' +1052-1054 keyword in +1055-1059 keyword this +1059-1060 punctuation , +1068-1069 operator : +1070-1074 keyword this +1075-1085 keyword instanceof +1086-1087 class_name D +1086-1087 constant D +1087-1088 punctuation , +1091-1092 punctuation } +1092-1093 punctuation ; +1096-1102 keyword delete +1106-1107 punctuation . +1113-1114 punctuation ; +1117-1123 comment // foo +1125-1126 punctuation } +1126-1127 punctuation ; +1130-1145 function #private_method +1145-1146 punctuation ( +1148-1149 operator : +1150-1156 builtin number +1156-1157 punctuation , +1160-1161 operator : +1162-1165 builtin any +1165-1166 punctuation ) +1167-1168 punctuation { +1171-1176 special_keyword throw +1177-1180 keyword new +1181-1186 class_name Error +1186-1187 punctuation ( +1187-1233 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` +1187-1188 template_punctuation ` +1188-1198 interpolation ${this.d1} +1188-1190 interpolation_punctuation ${ +1190-1194 keyword this +1194-1195 punctuation . +1197-1198 interpolation_punctuation } +1198-1219 string \n\t\t\tmultiline\n\t\t\tetc +1219-1229 interpolation ${a2 + c2} +1219-1221 interpolation_punctuation ${ +1224-1225 operator + +1228-1229 interpolation_punctuation } +1229-1232 string \n\t\t +1232-1233 template_punctuation ` +1233-1234 punctuation ) +1234-1235 punctuation ; +1237-1238 punctuation } +1241-1242 operator * +1242-1251 function generator +1251-1252 punctuation ( +1252-1253 punctuation ) +1254-1255 punctuation { +1258-1263 keyword yield +1264-1265 number 1 +1265-1266 punctuation ; +1269-1274 keyword yield +1274-1275 operator * +1276-1277 punctuation [ +1277-1278 number 2 +1278-1279 punctuation , +1280-1281 number 3 +1281-1282 punctuation ] +1282-1283 punctuation ; +1285-1286 punctuation } +1295-1296 operator * +1296-1311 function async_generator +1311-1312 punctuation ( +1312-1313 punctuation ) +1314-1315 punctuation { +1318-1323 keyword yield +1324-1329 special_keyword await +1330-1337 builtin Promise +1337-1338 punctuation . +1338-1345 function resolve +1345-1346 punctuation ( +1346-1347 number 4 +1347-1348 punctuation ) +1348-1349 punctuation ; +1351-1352 punctuation } +1355-1364 keyword protected +1365-1370 keyword async +1371-1387 function protected_method +1387-1388 punctuation ( +1388-1389 punctuation ) +1389-1390 operator : +1391-1398 builtin Promise +1398-1399 operator < +1399-1403 keyword void +1403-1404 operator > +1405-1406 punctuation { +1409-1412 special_keyword try +1413-1414 punctuation { +1418-1423 special_keyword await +1424-1427 keyword new +1428-1435 class_name Promise +1428-1435 builtin Promise +1435-1436 punctuation ( +1436-1437 punctuation ( +1444-1445 punctuation ) +1446-1448 operator => +1449-1459 function setTimeout +1459-1460 punctuation ( +1467-1468 punctuation , +1469-1472 number 100 +1472-1473 punctuation ) +1473-1474 punctuation ) +1474-1475 punctuation ; +1479-1481 special_keyword if +1482-1483 punctuation ( +1487-1488 punctuation . +1488-1494 function random 1494-1495 punctuation ( -1495-1498 keyword new -1499-1503 class_name Date -1503-1504 punctuation ( -1504-1505 punctuation ) -1505-1506 punctuation ) -1506-1507 punctuation ; -1508-1541 comment // eslint-disable-line no-console -1545-1546 punctuation } -1547-1551 special_keyword else -1552-1554 special_keyword if -1555-1556 punctuation ( -1560-1561 punctuation . -1561-1567 function random -1567-1568 punctuation ( -1568-1569 punctuation ) -1570-1571 operator > -1572-1575 number 0.2 -1575-1576 punctuation ) -1577-1578 punctuation { -1583-1590 builtin console -1590-1591 punctuation . -1591-1594 function log +1495-1496 punctuation ) +1497-1498 operator > +1499-1502 number 0.5 +1502-1503 punctuation ) +1504-1505 punctuation { +1510-1517 builtin console +1517-1518 punctuation . +1518-1521 function log +1521-1522 punctuation ( +1522-1525 keyword new +1526-1530 class_name Date +1530-1531 punctuation ( +1531-1532 punctuation ) +1532-1533 punctuation ) +1533-1534 punctuation ; +1535-1568 comment // eslint-disable-line no-console +1572-1573 punctuation } +1574-1578 special_keyword else +1579-1581 special_keyword if +1582-1583 punctuation ( +1587-1588 punctuation . +1588-1594 function random 1594-1595 punctuation ( -1595-1611 string 'else if branch' -1611-1612 punctuation ) -1612-1613 punctuation ; -1617-1618 punctuation } -1619-1623 special_keyword else -1624-1625 punctuation { -1630-1637 builtin console -1637-1638 punctuation . -1638-1641 function log -1641-1642 punctuation ( -1642-1655 string 'else branch' -1655-1656 punctuation ) -1656-1657 punctuation ; -1661-1662 punctuation } -1665-1666 punctuation } -1667-1672 special_keyword catch -1673-1674 punctuation ( -1679-1680 operator : -1681-1688 builtin unknown -1688-1689 punctuation ) -1690-1691 punctuation { -1695-1702 builtin console -1702-1703 punctuation . -1703-1708 function error -1708-1709 punctuation ( -1714-1715 punctuation ) -1715-1716 punctuation ; -1719-1720 punctuation } -1721-1728 special_keyword finally -1729-1730 punctuation { -1734-1741 builtin console -1741-1742 punctuation . -1742-1745 function log -1745-1746 punctuation ( -1746-1761 string 'finally block' -1761-1762 punctuation ) -1762-1763 punctuation ; -1766-1767 punctuation } -1769-1770 punctuation } -1771-1772 punctuation } -1774-1784 comment // comment -1786-1829 comment /*\nother comment\n\nconst comment = false;\n*/ -1831-1855 comment /**\n * JSDoc comment\n */ -1857-1863 special_keyword import -1864-1865 punctuation { -1877-1878 punctuation , -1879-1883 keyword type -1884-1895 class_name Sample_Lang -1895-1896 punctuation } -1897-1901 special_keyword from -1902-1921 string '../code_sample.js' -1921-1922 punctuation ; -1923-1929 special_keyword import -1930-1931 operator * -1932-1934 special_keyword as -1935-1936 constant A -1937-1941 special_keyword from -1942-1961 string '../code_sample.js' -1961-1962 punctuation ; -1964-1970 special_keyword export -1971-1972 punctuation { -1973-1974 punctuation , -1975-1976 constant A -1976-1977 punctuation , -1979-1980 punctuation , -1982-1983 punctuation , -1984-1985 constant D -1985-1986 punctuation } -1986-1987 punctuation ; -2002-2004 special_keyword as -2005-2012 builtin unknown -2013-2015 special_keyword as -2016-2019 builtin any -2020-2022 special_keyword as -2056-2057 punctuation ; -2059-2065 special_keyword export -2066-2075 keyword interface -2076-2082 class_name Some_E -2083-2084 punctuation { -2090-2091 operator : -2092-2098 builtin string -2098-2099 punctuation ; -2104-2105 operator : -2106-2112 builtin number -2112-2113 punctuation ; -2114-2115 punctuation } -2117-2123 special_keyword export -2124-2129 keyword const -2136-2137 operator : -2145-2146 operator = -2147-2148 punctuation { -2152-2153 operator : -2154-2161 string 'A. H.' -2161-2162 punctuation , -2166-2167 operator : -2168-2171 number 100 -2171-2172 punctuation } -2172-2173 punctuation ; -2175-2181 special_keyword export -2182-2190 keyword function -2191-2194 function add -2194-2195 punctuation ( -2196-2197 operator : -2198-2204 builtin number -2204-2205 punctuation , -2207-2208 operator : -2209-2215 builtin number -2215-2216 punctuation ) -2216-2217 operator : -2218-2224 builtin number -2225-2226 punctuation { -2228-2234 special_keyword return -2237-2238 operator + -2240-2241 punctuation ; -2242-2243 punctuation } -2245-2251 special_keyword export -2252-2257 keyword const -2258-2262 function_variable plus -2263-2264 operator = -2265-2266 punctuation ( -2267-2268 operator : -2269-2272 builtin any -2272-2273 punctuation , -2275-2276 operator : -2277-2280 builtin any -2280-2281 punctuation ) -2281-2282 operator : -2283-2286 builtin any -2287-2289 operator => -2292-2293 operator + -2295-2296 punctuation ; -2298-2320 comment // boundary test cases -2321-2327 special_keyword export -2328-2333 keyword const -2352-2353 operator = -2354-2383 string 'const class function string' -2383-2384 punctuation ; -2385-2391 special_keyword export -2392-2397 keyword const -2415-2416 operator = -2417-2443 string '// this is not a comment' -2443-2444 punctuation ; -2445-2451 special_keyword export -2452-2457 keyword const -2477-2478 operator = -2479-2496 template_string `Value: ${1 + 2}` -2479-2480 template_punctuation ` -2480-2487 string Value: -2487-2495 interpolation ${1 + 2} -2487-2489 interpolation_punctuation ${ -2489-2490 number 1 -2491-2492 operator + -2493-2494 number 2 -2494-2495 interpolation_punctuation } -2495-2496 template_punctuation ` -2496-2497 punctuation ; -2499-2531 comment // regex that looks like comment -2532-2538 special_keyword export -2539-2544 keyword const -2551-2552 operator = -2553-2562 regex /\/\/.*/g -2553-2554 regex_delimiter / -2554-2560 regex_source \/\/.* -2560-2561 regex_delimiter / -2561-2562 regex_flags g -2562-2563 punctuation ; -2564-2570 special_keyword export -2571-2576 keyword const -2591-2592 operator = -2593-2625 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ -2593-2594 regex_delimiter / -2594-2624 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ -2624-2625 regex_delimiter / -2625-2626 punctuation ; -2628-2684 comment // string in comment should not be highlighted as string -2685-2736 comment // const commented = "this string is in a comment"; +1595-1596 punctuation ) +1597-1598 operator > +1599-1602 number 0.2 +1602-1603 punctuation ) +1604-1605 punctuation { +1610-1617 builtin console +1617-1618 punctuation . +1618-1621 function log +1621-1622 punctuation ( +1622-1638 string 'else if branch' +1638-1639 punctuation ) +1639-1640 punctuation ; +1644-1645 punctuation } +1646-1650 special_keyword else +1651-1652 punctuation { +1657-1664 builtin console +1664-1665 punctuation . +1665-1668 function log +1668-1669 punctuation ( +1669-1682 string 'else branch' +1682-1683 punctuation ) +1683-1684 punctuation ; +1688-1689 punctuation } +1692-1693 punctuation } +1694-1699 special_keyword catch +1700-1701 punctuation ( +1706-1707 operator : +1708-1715 builtin unknown +1715-1716 punctuation ) +1717-1718 punctuation { +1722-1729 builtin console +1729-1730 punctuation . +1730-1735 function error +1735-1736 punctuation ( +1741-1742 punctuation ) +1742-1743 punctuation ; +1746-1747 punctuation } +1748-1755 special_keyword finally +1756-1757 punctuation { +1761-1768 builtin console +1768-1769 punctuation . +1769-1772 function log +1772-1773 punctuation ( +1773-1788 string 'finally block' +1788-1789 punctuation ) +1789-1790 punctuation ; +1793-1794 punctuation } +1796-1797 punctuation } +1798-1799 punctuation } +1801-1811 comment // comment +1813-1856 comment /*\nother comment\n\nconst comment = false;\n*/ +1858-1882 comment /**\n * JSDoc comment\n */ +1884-1890 special_keyword import +1891-1892 punctuation { +1904-1905 punctuation , +1906-1910 keyword type +1911-1922 class_name Sample_Lang +1922-1923 punctuation } +1924-1928 special_keyword from +1929-1948 string '../code_sample.js' +1948-1949 punctuation ; +1950-1956 special_keyword import +1957-1958 operator * +1959-1961 special_keyword as +1962-1963 constant A +1964-1968 special_keyword from +1969-1988 string '../code_sample.js' +1988-1989 punctuation ; +1991-1997 special_keyword export +1998-1999 punctuation { +2000-2001 punctuation , +2002-2003 constant A +2003-2004 punctuation , +2006-2007 punctuation , +2009-2010 punctuation , +2011-2012 constant D +2012-2013 punctuation } +2013-2014 punctuation ; +2029-2031 special_keyword as +2032-2039 builtin unknown +2040-2042 special_keyword as +2043-2046 builtin any +2047-2049 special_keyword as +2083-2084 punctuation ; +2086-2092 special_keyword export +2093-2102 keyword interface +2103-2109 class_name Some_E +2110-2111 punctuation { +2117-2118 operator : +2119-2125 builtin string +2125-2126 punctuation ; +2131-2132 operator : +2133-2139 builtin number +2139-2140 punctuation ; +2141-2142 punctuation } +2144-2150 special_keyword export +2151-2156 keyword const +2163-2164 operator : +2172-2173 operator = +2174-2175 punctuation { +2179-2180 operator : +2181-2188 string 'A. H.' +2188-2189 punctuation , +2193-2194 operator : +2195-2198 number 100 +2198-2199 punctuation } +2199-2200 punctuation ; +2202-2208 special_keyword export +2209-2217 keyword function +2218-2221 function add +2221-2222 punctuation ( +2223-2224 operator : +2225-2231 builtin number +2231-2232 punctuation , +2234-2235 operator : +2236-2242 builtin number +2242-2243 punctuation ) +2243-2244 operator : +2245-2251 builtin number +2252-2253 punctuation { +2255-2261 special_keyword return +2264-2265 operator + +2267-2268 punctuation ; +2269-2270 punctuation } +2272-2278 special_keyword export +2279-2284 keyword const +2285-2289 function_variable plus +2290-2291 operator = +2292-2293 punctuation ( +2294-2295 operator : +2296-2299 builtin any +2299-2300 punctuation , +2302-2303 operator : +2304-2307 builtin any +2307-2308 punctuation ) +2308-2309 operator : +2310-2313 builtin any +2314-2316 operator => +2319-2320 operator + +2322-2323 punctuation ; +2325-2347 comment // boundary test cases +2348-2354 special_keyword export +2355-2360 keyword const +2379-2380 operator = +2381-2410 string 'const class function string' +2410-2411 punctuation ; +2412-2418 special_keyword export +2419-2424 keyword const +2442-2443 operator = +2444-2470 string '// this is not a comment' +2470-2471 punctuation ; +2472-2478 special_keyword export +2479-2484 keyword const +2504-2505 operator = +2506-2523 template_string `Value: ${1 + 2}` +2506-2507 template_punctuation ` +2507-2514 string Value: +2514-2522 interpolation ${1 + 2} +2514-2516 interpolation_punctuation ${ +2516-2517 number 1 +2518-2519 operator + +2520-2521 number 2 +2521-2522 interpolation_punctuation } +2522-2523 template_punctuation ` +2523-2524 punctuation ; +2526-2558 comment // regex that looks like comment +2559-2565 special_keyword export +2566-2571 keyword const +2578-2579 operator = +2580-2589 regex /\/\/.*/g +2580-2581 regex_delimiter / +2581-2587 regex_source \/\/.* +2587-2588 regex_delimiter / +2588-2589 regex_flags g +2589-2590 punctuation ; +2591-2597 special_keyword export +2598-2603 keyword const +2618-2619 operator = +2620-2652 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ +2620-2621 regex_delimiter / +2621-2651 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +2651-2652 regex_delimiter / +2652-2653 punctuation ; +2655-2711 comment // string in comment should not be highlighted as string +2712-2763 comment // const commented = "this string is in a comment"; === STATS === -Total tokens: 549 -Sample length: 2737 characters +Total tokens: 557 +Sample length: 2764 characters Token types: - punctuation: 216 - operator: 74 + punctuation: 221 + operator: 75 keyword: 52 special_keyword: 44 builtin: 33 function: 26 - string: 23 + string: 24 number: 14 comment: 11 class_name: 10 interpolation_punctuation: 8 template_punctuation: 6 constant: 5 + boolean: 4 interpolation: 4 regex_delimiter: 4 - boolean: 3 decorator: 3 at: 3 template_string: 3 diff --git a/src/lib/grammar_ts.ts b/src/lib/grammar_ts.ts index a3632d67..80ec72ea 100644 --- a/src/lib/grammar_ts.ts +++ b/src/lib/grammar_ts.ts @@ -54,7 +54,10 @@ export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { pattern: /^@/, alias: 'operator', }, - function: /^[\s\S]+/, + function: { + pattern: /^[\s\S]+/, + alias: 'decorator_name', + }, }, }, generic_function: { diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index fa5b5566..29552acd 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -118,7 +118,7 @@ class D extends Base { // implementation } - @method_decorator + @method_decorator('example', {option: true}) class_method(): string { return \`Hello, \${this.d1}\`; } diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index 1247bcb2..a8e3ee59 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -30,7 +30,7 @@ class D extends Base { // implementation } - @method_decorator + @method_decorator('example', {option: true}) class_method(): string { return `Hello, ${this.d1}`; } diff --git a/src/lib/theme.css b/src/lib/theme.css index d1de6d39..4cf112d3 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -18,11 +18,6 @@ color: var(--color_d_5); } -.token.property, -::highlight(property) { - color: var(--color_i_5); -} - .token.tag, ::highlight(tag), .token.constant, @@ -92,6 +87,15 @@ color: var(--color_e_5); } +.token.property, +::highlight(property), +.token.decorator, +::highlight(decorator), +.token.decorator_name, +::highlight(decorator_name) { + color: var(--color_i_5); +} + .token.atrule, ::highlight(atrule), .token.attr_name, From 51d7cc2450f31f36d57c62d8a5557671c9d1c957 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 12:18:24 -0400 Subject: [PATCH 16/49] wip --- fixtures/generated/ts/ts_complex.json | 11 ++++++----- fixtures/generated/ts/ts_complex.txt | 15 ++++++++------- src/lib/grammar_js.ts | 4 ++-- src/lib/grammar_ts.ts | 7 ++++++- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/fixtures/generated/ts/ts_complex.json b/fixtures/generated/ts/ts_complex.json index cb94de63..33b12683 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/fixtures/generated/ts/ts_complex.json @@ -219,7 +219,7 @@ {"type": "punctuation", "start": 927, "end": 928}, {"type": "special_keyword", "start": 933, "end": 938}, {"type": "punctuation", "start": 938, "end": 939}, - {"type": "keyword", "start": 943, "end": 950}, + {"type": "special_keyword", "start": 943, "end": 950}, {"type": "operator", "start": 950, "end": 951}, {"type": "builtin", "start": 956, "end": 963}, {"type": "punctuation", "start": 963, "end": 964}, @@ -295,10 +295,10 @@ {"type": "punctuation", "start": 1251, "end": 1252}, {"type": "punctuation", "start": 1252, "end": 1253}, {"type": "punctuation", "start": 1254, "end": 1255}, - {"type": "keyword", "start": 1258, "end": 1263}, + {"type": "special_keyword", "start": 1258, "end": 1263}, {"type": "number", "start": 1264, "end": 1265}, {"type": "punctuation", "start": 1265, "end": 1266}, - {"type": "keyword", "start": 1269, "end": 1274}, + {"type": "special_keyword", "start": 1269, "end": 1274}, {"type": "operator", "start": 1274, "end": 1275}, {"type": "punctuation", "start": 1276, "end": 1277}, {"type": "number", "start": 1277, "end": 1278}, @@ -312,7 +312,7 @@ {"type": "punctuation", "start": 1311, "end": 1312}, {"type": "punctuation", "start": 1312, "end": 1313}, {"type": "punctuation", "start": 1314, "end": 1315}, - {"type": "keyword", "start": 1318, "end": 1323}, + {"type": "special_keyword", "start": 1318, "end": 1323}, {"type": "special_keyword", "start": 1324, "end": 1329}, {"type": "builtin", "start": 1330, "end": 1337}, {"type": "punctuation", "start": 1337, "end": 1338}, @@ -461,6 +461,7 @@ {"type": "special_keyword", "start": 2040, "end": 2042}, {"type": "builtin", "start": 2043, "end": 2046}, {"type": "special_keyword", "start": 2047, "end": 2049}, + {"type": "keyword", "start": 2062, "end": 2071}, {"type": "punctuation", "start": 2083, "end": 2084}, {"type": "special_keyword", "start": 2086, "end": 2092}, {"type": "keyword", "start": 2093, "end": 2102}, @@ -564,5 +565,5 @@ {"type": "comment", "start": 2655, "end": 2711}, {"type": "comment", "start": 2712, "end": 2763} ], - "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/fixtures/generated/ts/ts_complex.txt index 8863b917..02fa07d1 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/fixtures/generated/ts/ts_complex.txt @@ -212,7 +212,7 @@ 927-928 punctuation ; 933-938 special_keyword break 938-939 punctuation ; - 943-950 keyword default + 943-950 special_keyword default 950-951 operator : 956-963 builtin console 963-964 punctuation . @@ -288,10 +288,10 @@ 1251-1252 punctuation ( 1252-1253 punctuation ) 1254-1255 punctuation { -1258-1263 keyword yield +1258-1263 special_keyword yield 1264-1265 number 1 1265-1266 punctuation ; -1269-1274 keyword yield +1269-1274 special_keyword yield 1274-1275 operator * 1276-1277 punctuation [ 1277-1278 number 2 @@ -305,7 +305,7 @@ 1311-1312 punctuation ( 1312-1313 punctuation ) 1314-1315 punctuation { -1318-1323 keyword yield +1318-1323 special_keyword yield 1324-1329 special_keyword await 1330-1337 builtin Promise 1337-1338 punctuation . @@ -454,6 +454,7 @@ 2040-2042 special_keyword as 2043-2046 builtin any 2047-2049 special_keyword as +2062-2071 keyword satisfies 2083-2084 punctuation ; 2086-2092 special_keyword export 2093-2102 keyword interface @@ -558,14 +559,14 @@ 2712-2763 comment // const commented = "this string is in a comment"; === STATS === -Total tokens: 557 +Total tokens: 558 Sample length: 2764 characters Token types: punctuation: 221 operator: 75 - keyword: 52 - special_keyword: 44 + keyword: 49 + special_keyword: 48 builtin: 33 function: 26 string: 24 diff --git a/src/lib/grammar_js.ts b/src/lib/grammar_js.ts index 9a2808a3..71371047 100644 --- a/src/lib/grammar_js.ts +++ b/src/lib/grammar_js.ts @@ -24,7 +24,7 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { keyword: [ { pattern: - /(^|[^.]|\.\.\.\s*)\b(?:assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|class|const|debugger|default|delete|enum|extends|function|(?:get|set)(?=\s*(?:[#[$\w\xA0-\uFFFF]|$))|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with|yield)\b/, + /(^|[^.]|\.\.\.\s*)\b(?:assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|class|const|debugger|delete|enum|extends|function|(?:get|set)(?=\s*(?:[#[$\w\xA0-\uFFFF]|$))|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with)\b/, lookbehind: true, }, ], @@ -67,7 +67,7 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { syntax_styler.grammar_insert_before('js', 'function', { special_keyword: - /\b(?:as|await|break|case|catch|continue|do|else|export|finally|for|from|if|import|return|switch|throw|try|while)\b/, + /\b(?:as|await|break|case|catch|continue|default|do|else|export|finally|for|from|if|import|return|switch|throw|try|while|yield)\b/, }); syntax_styler.grammar_insert_before('js', 'keyword', { diff --git a/src/lib/grammar_ts.ts b/src/lib/grammar_ts.ts index 80ec72ea..05f8ef81 100644 --- a/src/lib/grammar_ts.ts +++ b/src/lib/grammar_ts.ts @@ -29,7 +29,7 @@ export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { // The keywords TypeScript adds to JS (grammar_ts.keyword as any).push( - /\b(?:abstract|declare|is|keyof|readonly|require)\b/, + /\b(?:abstract|declare|is|keyof|readonly|require|satisfies)\b/, // keywords that have to be followed by an identifier /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/, // This is for `import type *, {}` @@ -47,6 +47,11 @@ export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { (grammar_ts.class_name as Syntax_Grammar_Token).inside = type_inside; syntax_styler.grammar_insert_before('ts', 'function', { + import_type_keyword: { + pattern: /(\b(?:import|export)\s+)type\b|(\b(?:import|export)\s*\{[^}]*,\s*)type\b/, + lookbehind: true, + alias: 'special_keyword', + }, decorator: { pattern: /@[$\w\xA0-\uFFFF]+/, inside: { From d72c147bf64f6e1afeff5ece806c1c8e74f06139 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 12:52:53 -0400 Subject: [PATCH 17/49] wip --- CLAUDE.md | 4 +- fixtures/generated/svelte/svelte_complex.json | 23 +- fixtures/generated/svelte/svelte_complex.txt | 29 +- fixtures/generated/ts/ts_complex.json | 1115 ++++++++-------- fixtures/generated/ts/ts_complex.txt | 1187 +++++++++-------- src/lib/grammar_ts.ts | 20 +- src/lib/samples/all.ts | 9 +- src/lib/samples/sample_complex.ts | 9 +- 8 files changed, 1288 insertions(+), 1108 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b0e46c0e..906316bb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,7 +12,7 @@ See [README.md](./README.md). ```bash gro test # Run all tests gro test src/fixtures/check.test.ts # Verify fixture generation -npm run update-generated-fixtures # Regenerate fixtures +gro src/fixtures/update # Regenerate fixtures npm run benchmark # Run performance benchmarks npm run benchmark-compare # Compare performance with Prism and Shiki ``` @@ -168,7 +168,7 @@ Generated fixtures in `src/fixtures/{lang}/`: ### Workflow 1. Edit samples in `src/lib/samples/` -2. Run `npm run update-generated-fixtures` to regenerate +2. Run `gro src/fixtures/update` to regenerate 3. Run `gro test src/fixtures/check.test.ts` to verify 4. Review changes with `git diff src/fixtures/` diff --git a/fixtures/generated/svelte/svelte_complex.json b/fixtures/generated/svelte/svelte_complex.json index d77b7e9c..534150d4 100644 --- a/fixtures/generated/svelte/svelte_complex.json +++ b/fixtures/generated/svelte/svelte_complex.json @@ -102,7 +102,9 @@ {"type": "string", "start": 413, "end": 416}, {"type": "punctuation", "start": 416, "end": 417}, {"type": "keyword", "start": 420, "end": 423}, - {"type": "operator", "start": 425, "end": 426}, + {"type": "type_annotation", "start": 425, "end": 435}, + {"type": ":", "start": 425, "end": 426}, + {"type": "type", "start": 426, "end": 435}, {"type": "builtin", "start": 427, "end": 434}, {"type": "operator", "start": 435, "end": 436}, {"type": "function", "start": 437, "end": 443}, @@ -113,6 +115,7 @@ {"type": "special_keyword", "start": 453, "end": 459}, {"type": "keyword", "start": 460, "end": 464}, {"type": "class_name", "start": 465, "end": 474}, + {"type": "type_name", "start": 465, "end": 474}, {"type": "operator", "start": 475, "end": 476}, {"type": "number", "start": 477, "end": 478}, {"type": "operator", "start": 479, "end": 480}, @@ -124,7 +127,9 @@ {"type": "class_name", "start": 501, "end": 502}, {"type": "constant", "start": 501, "end": 502}, {"type": "punctuation", "start": 503, "end": 504}, - {"type": "operator", "start": 509, "end": 510}, + {"type": "type_annotation", "start": 509, "end": 518}, + {"type": ":", "start": 509, "end": 510}, + {"type": "type", "start": 510, "end": 518}, {"type": "builtin", "start": 511, "end": 517}, {"type": "operator", "start": 518, "end": 519}, {"type": "string", "start": 520, "end": 523}, @@ -190,6 +195,7 @@ {"type": "special_keyword", "start": 784, "end": 789}, {"type": "keyword", "start": 790, "end": 793}, {"type": "class_name", "start": 794, "end": 799}, + {"type": "type_name", "start": 794, "end": 799}, {"type": "punctuation", "start": 799, "end": 800}, {"type": "template_string", "start": 800, "end": 816}, {"type": "template_punctuation", "start": 800, "end": 801}, @@ -214,6 +220,7 @@ {"type": "punctuation", "start": 871, "end": 872}, {"type": "keyword", "start": 872, "end": 875}, {"type": "class_name", "start": 876, "end": 880}, + {"type": "type_name", "start": 876, "end": 880}, {"type": "punctuation", "start": 880, "end": 881}, {"type": "number", "start": 881, "end": 884}, {"type": "punctuation", "start": 884, "end": 885}, @@ -228,6 +235,7 @@ {"type": "special_keyword", "start": 1022, "end": 1028}, {"type": "keyword", "start": 1029, "end": 1038}, {"type": "class_name", "start": 1039, "end": 1045}, + {"type": "type_name", "start": 1039, "end": 1045}, {"type": "punctuation", "start": 1046, "end": 1047}, {"type": "operator", "start": 1054, "end": 1055}, {"type": "builtin", "start": 1056, "end": 1062}, @@ -238,7 +246,10 @@ {"type": "punctuation", "start": 1080, "end": 1081}, {"type": "special_keyword", "start": 1084, "end": 1090}, {"type": "keyword", "start": 1091, "end": 1096}, - {"type": "operator", "start": 1103, "end": 1104}, + {"type": "type_annotation", "start": 1103, "end": 1112}, + {"type": ":", "start": 1103, "end": 1104}, + {"type": "type", "start": 1104, "end": 1112}, + {"type": "type_name", "start": 1105, "end": 1111}, {"type": "operator", "start": 1112, "end": 1113}, {"type": "punctuation", "start": 1114, "end": 1115}, {"type": "operator", "start": 1119, "end": 1120}, @@ -276,7 +287,9 @@ {"type": "operator", "start": 1246, "end": 1247}, {"type": "builtin", "start": 1248, "end": 1251}, {"type": "punctuation", "start": 1251, "end": 1252}, - {"type": "operator", "start": 1252, "end": 1253}, + {"type": "type_annotation", "start": 1252, "end": 1258}, + {"type": ":", "start": 1252, "end": 1253}, + {"type": "type", "start": 1253, "end": 1258}, {"type": "builtin", "start": 1254, "end": 1257}, {"type": "operator", "start": 1258, "end": 1260}, {"type": "operator", "start": 1263, "end": 1264}, @@ -584,5 +597,5 @@ {"type": "punctuation", "start": 2324, "end": 2326}, {"type": "punctuation", "start": 2331, "end": 2332} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/fixtures/generated/svelte/svelte_complex.txt b/fixtures/generated/svelte/svelte_complex.txt index 0f0f3108..7eee969a 100644 --- a/fixtures/generated/svelte/svelte_complex.txt +++ b/fixtures/generated/svelte/svelte_complex.txt @@ -95,7 +95,9 @@ 413-416 string 'b' 416-417 punctuation ; 420-423 keyword let - 425-426 operator : + 425-435 type_annotation : boolean + 425-426 : : + 426-435 type boolean 427-434 builtin boolean 435-436 operator = 437-443 function $state @@ -106,6 +108,7 @@ 453-459 special_keyword export 460-464 keyword type 465-474 class_name Some_Type + 465-474 type_name Some_Type 475-476 operator = 477-478 number 1 479-480 operator | @@ -117,7 +120,9 @@ 501-502 class_name D 501-502 constant D 503-504 punctuation { - 509-510 operator : + 509-518 type_annotation : string + 509-510 : : + 510-518 type string 511-517 builtin string 518-519 operator = 520-523 string 'd' @@ -183,6 +188,7 @@ 784-789 special_keyword throw 790-793 keyword new 794-799 class_name Error + 794-799 type_name Error 799-800 punctuation ( 800-816 template_string `${this.d1} etc` 800-801 template_punctuation ` @@ -207,6 +213,7 @@ 871-872 punctuation ( 872-875 keyword new 876-880 class_name Date + 876-880 type_name Date 880-881 punctuation ( 881-884 number 123 884-885 punctuation ) @@ -221,6 +228,7 @@ 1022-1028 special_keyword export 1029-1038 keyword interface 1039-1045 class_name Some_E +1039-1045 type_name Some_E 1046-1047 punctuation { 1054-1055 operator : 1056-1062 builtin string @@ -231,7 +239,10 @@ 1080-1081 punctuation } 1084-1090 special_keyword export 1091-1096 keyword const -1103-1104 operator : +1103-1112 type_annotation : Some_E +1103-1104 : : +1104-1112 type Some_E +1105-1111 type_name Some_E 1112-1113 operator = 1114-1115 punctuation { 1119-1120 operator : @@ -269,7 +280,9 @@ 1246-1247 operator : 1248-1251 builtin any 1251-1252 punctuation ) -1252-1253 operator : +1252-1258 type_annotation : any +1252-1253 : : +1253-1258 type any 1254-1257 builtin any 1258-1260 operator => 1263-1264 operator + @@ -578,13 +591,13 @@ 2331-2332 punctuation > === STATS === -Total tokens: 577 +Total tokens: 590 Sample length: 2333 characters Token types: punctuation: 270 tag: 60 - operator: 49 + operator: 45 keyword: 24 lang_ts: 19 builtin: 17 @@ -598,8 +611,12 @@ Token types: selector: 7 number: 6 class_name: 5 + type_name: 5 constant: 4 boolean: 4 + type_annotation: 4 + :: 4 + type: 4 template_punctuation: 4 interpolation_punctuation: 4 script: 2 diff --git a/fixtures/generated/ts/ts_complex.json b/fixtures/generated/ts/ts_complex.json index 33b12683..39fcf31a 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/fixtures/generated/ts/ts_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "ts", "variant": "complex", - "content": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", + "content": "const a = 1;\n\nconst b: string = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n\tt?: T;\n}\n\nconst e: {name: string; age: number} = {name: 'A. H.', age: 100};\nconst v = [['', e]] as const;\nexport const some_e: Map = new Map(v);\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", "filepath": "src/lib/samples/sample_complex.ts" }, "tokens": [ @@ -11,559 +11,620 @@ {"type": "number", "start": 10, "end": 11}, {"type": "punctuation", "start": 11, "end": 12}, {"type": "keyword", "start": 14, "end": 19}, - {"type": "operator", "start": 22, "end": 23}, - {"type": "string", "start": 24, "end": 27}, - {"type": "punctuation", "start": 27, "end": 28}, - {"type": "keyword", "start": 30, "end": 35}, - {"type": "operator", "start": 38, "end": 39}, - {"type": "boolean", "start": 40, "end": 44}, - {"type": "punctuation", "start": 44, "end": 45}, - {"type": "special_keyword", "start": 47, "end": 53}, - {"type": "keyword", "start": 54, "end": 58}, - {"type": "class_name", "start": 59, "end": 68}, - {"type": "operator", "start": 69, "end": 70}, - {"type": "number", "start": 71, "end": 72}, - {"type": "operator", "start": 73, "end": 74}, - {"type": "string", "start": 75, "end": 78}, - {"type": "operator", "start": 79, "end": 80}, - {"type": "boolean", "start": 81, "end": 85}, - {"type": "punctuation", "start": 85, "end": 86}, - {"type": "keyword", "start": 88, "end": 95}, - {"type": "keyword", "start": 96, "end": 101}, - {"type": "operator", "start": 117, "end": 118}, - {"type": "builtin", "start": 119, "end": 122}, - {"type": "punctuation", "start": 122, "end": 123}, - {"type": "operator", "start": 142, "end": 143}, - {"type": "builtin", "start": 144, "end": 147}, - {"type": "punctuation", "start": 147, "end": 148}, - {"type": "operator", "start": 165, "end": 166}, - {"type": "builtin", "start": 167, "end": 170}, - {"type": "punctuation", "start": 170, "end": 171}, - {"type": "keyword", "start": 173, "end": 181}, - {"type": "keyword", "start": 182, "end": 187}, - {"type": "class_name", "start": 188, "end": 192}, - {"type": "punctuation", "start": 193, "end": 194}, - {"type": "keyword", "start": 196, "end": 204}, - {"type": "function", "start": 205, "end": 220}, - {"type": "punctuation", "start": 220, "end": 221}, - {"type": "punctuation", "start": 221, "end": 222}, - {"type": "operator", "start": 222, "end": 223}, - {"type": "keyword", "start": 224, "end": 228}, + {"type": "type_annotation", "start": 21, "end": 30}, + {"type": ":", "start": 21, "end": 22}, + {"type": "type", "start": 22, "end": 30}, + {"type": "builtin", "start": 23, "end": 29}, + {"type": "operator", "start": 30, "end": 31}, + {"type": "string", "start": 32, "end": 35}, + {"type": "punctuation", "start": 35, "end": 36}, + {"type": "keyword", "start": 38, "end": 43}, + {"type": "operator", "start": 46, "end": 47}, + {"type": "boolean", "start": 48, "end": 52}, + {"type": "punctuation", "start": 52, "end": 53}, + {"type": "special_keyword", "start": 55, "end": 61}, + {"type": "keyword", "start": 62, "end": 66}, + {"type": "class_name", "start": 67, "end": 76}, + {"type": "type_name", "start": 67, "end": 76}, + {"type": "operator", "start": 77, "end": 78}, + {"type": "number", "start": 79, "end": 80}, + {"type": "operator", "start": 81, "end": 82}, + {"type": "string", "start": 83, "end": 86}, + {"type": "operator", "start": 87, "end": 88}, + {"type": "boolean", "start": 89, "end": 93}, + {"type": "punctuation", "start": 93, "end": 94}, + {"type": "keyword", "start": 96, "end": 103}, + {"type": "keyword", "start": 104, "end": 109}, + {"type": "operator", "start": 125, "end": 126}, + {"type": "builtin", "start": 127, "end": 130}, + {"type": "punctuation", "start": 130, "end": 131}, + {"type": "operator", "start": 150, "end": 151}, + {"type": "builtin", "start": 152, "end": 155}, + {"type": "punctuation", "start": 155, "end": 156}, + {"type": "operator", "start": 173, "end": 174}, + {"type": "builtin", "start": 175, "end": 178}, + {"type": "punctuation", "start": 178, "end": 179}, + {"type": "keyword", "start": 181, "end": 189}, + {"type": "keyword", "start": 190, "end": 195}, + {"type": "class_name", "start": 196, "end": 200}, + {"type": "type_name", "start": 196, "end": 200}, + {"type": "punctuation", "start": 201, "end": 202}, + {"type": "keyword", "start": 204, "end": 212}, + {"type": "function", "start": 213, "end": 228}, {"type": "punctuation", "start": 228, "end": 229}, - {"type": "punctuation", "start": 230, "end": 231}, - {"type": "decorator", "start": 233, "end": 249}, - {"type": "at", "start": 233, "end": 234}, - {"type": "function", "start": 234, "end": 249}, - {"type": "keyword", "start": 250, "end": 255}, - {"type": "class_name", "start": 256, "end": 257}, - {"type": "constant", "start": 256, "end": 257}, - {"type": "keyword", "start": 258, "end": 265}, - {"type": "class_name", "start": 266, "end": 270}, - {"type": "punctuation", "start": 271, "end": 272}, - {"type": "keyword", "start": 274, "end": 282}, - {"type": "operator", "start": 285, "end": 286}, - {"type": "builtin", "start": 287, "end": 293}, - {"type": "operator", "start": 294, "end": 295}, - {"type": "string", "start": 296, "end": 299}, - {"type": "punctuation", "start": 299, "end": 300}, - {"type": "operator", "start": 304, "end": 305}, - {"type": "builtin", "start": 306, "end": 312}, - {"type": "punctuation", "start": 312, "end": 313}, - {"type": "operator", "start": 318, "end": 319}, - {"type": "function", "start": 320, "end": 326}, - {"type": "punctuation", "start": 326, "end": 327}, - {"type": "keyword", "start": 327, "end": 331}, - {"type": "punctuation", "start": 331, "end": 332}, - {"type": "punctuation", "start": 332, "end": 333}, - {"type": "decorator", "start": 336, "end": 355}, - {"type": "at", "start": 336, "end": 337}, - {"type": "function", "start": 337, "end": 355}, - {"type": "operator", "start": 367, "end": 368}, - {"type": "boolean", "start": 369, "end": 373}, - {"type": "punctuation", "start": 373, "end": 374}, - {"type": "function", "start": 377, "end": 388}, - {"type": "punctuation", "start": 388, "end": 389}, - {"type": "operator", "start": 391, "end": 392}, - {"type": "builtin", "start": 393, "end": 399}, - {"type": "punctuation", "start": 399, "end": 400}, - {"type": "punctuation", "start": 401, "end": 402}, - {"type": "keyword", "start": 405, "end": 410}, - {"type": "punctuation", "start": 410, "end": 411}, - {"type": "punctuation", "start": 411, "end": 412}, - {"type": "punctuation", "start": 412, "end": 413}, - {"type": "keyword", "start": 416, "end": 420}, + {"type": "punctuation", "start": 229, "end": 230}, + {"type": "operator", "start": 230, "end": 231}, + {"type": "keyword", "start": 232, "end": 236}, + {"type": "punctuation", "start": 236, "end": 237}, + {"type": "punctuation", "start": 238, "end": 239}, + {"type": "decorator", "start": 241, "end": 257}, + {"type": "at", "start": 241, "end": 242}, + {"type": "function", "start": 242, "end": 257}, + {"type": "keyword", "start": 258, "end": 263}, + {"type": "class_name", "start": 264, "end": 265}, + {"type": "constant", "start": 264, "end": 265}, + {"type": "keyword", "start": 266, "end": 273}, + {"type": "class_name", "start": 274, "end": 278}, + {"type": "type_name", "start": 274, "end": 278}, + {"type": "punctuation", "start": 279, "end": 280}, + {"type": "keyword", "start": 282, "end": 290}, + {"type": "type_annotation", "start": 293, "end": 302}, + {"type": ":", "start": 293, "end": 294}, + {"type": "type", "start": 294, "end": 302}, + {"type": "builtin", "start": 295, "end": 301}, + {"type": "operator", "start": 302, "end": 303}, + {"type": "string", "start": 304, "end": 307}, + {"type": "punctuation", "start": 307, "end": 308}, + {"type": "operator", "start": 312, "end": 313}, + {"type": "builtin", "start": 314, "end": 320}, + {"type": "punctuation", "start": 320, "end": 321}, + {"type": "operator", "start": 326, "end": 327}, + {"type": "function", "start": 328, "end": 334}, + {"type": "punctuation", "start": 334, "end": 335}, + {"type": "keyword", "start": 335, "end": 339}, + {"type": "punctuation", "start": 339, "end": 340}, + {"type": "punctuation", "start": 340, "end": 341}, + {"type": "decorator", "start": 344, "end": 363}, + {"type": "at", "start": 344, "end": 345}, + {"type": "function", "start": 345, "end": 363}, + {"type": "operator", "start": 375, "end": 376}, + {"type": "boolean", "start": 377, "end": 381}, + {"type": "punctuation", "start": 381, "end": 382}, + {"type": "function", "start": 385, "end": 396}, + {"type": "punctuation", "start": 396, "end": 397}, + {"type": "operator", "start": 399, "end": 400}, + {"type": "builtin", "start": 401, "end": 407}, + {"type": "punctuation", "start": 407, "end": 408}, + {"type": "punctuation", "start": 409, "end": 410}, + {"type": "keyword", "start": 413, "end": 418}, + {"type": "punctuation", "start": 418, "end": 419}, + {"type": "punctuation", "start": 419, "end": 420}, {"type": "punctuation", "start": 420, "end": 421}, - {"type": "operator", "start": 424, "end": 425}, + {"type": "keyword", "start": 424, "end": 428}, {"type": "punctuation", "start": 428, "end": 429}, - {"type": "punctuation", "start": 431, "end": 432}, - {"type": "function", "start": 435, "end": 450}, - {"type": "punctuation", "start": 450, "end": 451}, - {"type": "punctuation", "start": 451, "end": 452}, - {"type": "operator", "start": 452, "end": 453}, - {"type": "keyword", "start": 454, "end": 458}, + {"type": "operator", "start": 432, "end": 433}, + {"type": "punctuation", "start": 436, "end": 437}, + {"type": "punctuation", "start": 439, "end": 440}, + {"type": "function", "start": 443, "end": 458}, + {"type": "punctuation", "start": 458, "end": 459}, {"type": "punctuation", "start": 459, "end": 460}, - {"type": "comment", "start": 463, "end": 480}, - {"type": "punctuation", "start": 482, "end": 483}, - {"type": "decorator", "start": 486, "end": 503}, - {"type": "at", "start": 486, "end": 487}, - {"type": "function", "start": 487, "end": 503}, - {"type": "punctuation", "start": 503, "end": 504}, - {"type": "string", "start": 504, "end": 513}, - {"type": "punctuation", "start": 513, "end": 514}, - {"type": "punctuation", "start": 515, "end": 516}, - {"type": "operator", "start": 522, "end": 523}, - {"type": "boolean", "start": 524, "end": 528}, - {"type": "punctuation", "start": 528, "end": 529}, - {"type": "punctuation", "start": 529, "end": 530}, - {"type": "function", "start": 532, "end": 544}, - {"type": "punctuation", "start": 544, "end": 545}, - {"type": "punctuation", "start": 545, "end": 546}, - {"type": "operator", "start": 546, "end": 547}, - {"type": "builtin", "start": 548, "end": 554}, - {"type": "punctuation", "start": 555, "end": 556}, - {"type": "special_keyword", "start": 559, "end": 565}, - {"type": "template_string", "start": 566, "end": 585}, - {"type": "template_punctuation", "start": 566, "end": 567}, - {"type": "string", "start": 567, "end": 574}, - {"type": "interpolation", "start": 574, "end": 584}, - {"type": "interpolation_punctuation", "start": 574, "end": 576}, - {"type": "keyword", "start": 576, "end": 580}, - {"type": "punctuation", "start": 580, "end": 581}, - {"type": "interpolation_punctuation", "start": 583, "end": 584}, - {"type": "template_punctuation", "start": 584, "end": 585}, - {"type": "punctuation", "start": 585, "end": 586}, + {"type": "operator", "start": 460, "end": 461}, + {"type": "keyword", "start": 462, "end": 466}, + {"type": "punctuation", "start": 467, "end": 468}, + {"type": "comment", "start": 471, "end": 488}, + {"type": "punctuation", "start": 490, "end": 491}, + {"type": "decorator", "start": 494, "end": 511}, + {"type": "at", "start": 494, "end": 495}, + {"type": "function", "start": 495, "end": 511}, + {"type": "punctuation", "start": 511, "end": 512}, + {"type": "string", "start": 512, "end": 521}, + {"type": "punctuation", "start": 521, "end": 522}, + {"type": "punctuation", "start": 523, "end": 524}, + {"type": "operator", "start": 530, "end": 531}, + {"type": "boolean", "start": 532, "end": 536}, + {"type": "punctuation", "start": 536, "end": 537}, + {"type": "punctuation", "start": 537, "end": 538}, + {"type": "function", "start": 540, "end": 552}, + {"type": "punctuation", "start": 552, "end": 553}, + {"type": "punctuation", "start": 553, "end": 554}, + {"type": "operator", "start": 554, "end": 555}, + {"type": "builtin", "start": 556, "end": 562}, + {"type": "punctuation", "start": 563, "end": 564}, + {"type": "special_keyword", "start": 567, "end": 573}, + {"type": "template_string", "start": 574, "end": 593}, + {"type": "template_punctuation", "start": 574, "end": 575}, + {"type": "string", "start": 575, "end": 582}, + {"type": "interpolation", "start": 582, "end": 592}, + {"type": "interpolation_punctuation", "start": 582, "end": 584}, + {"type": "keyword", "start": 584, "end": 588}, {"type": "punctuation", "start": 588, "end": 589}, - {"type": "function_variable", "start": 592, "end": 607}, - {"type": "operator", "start": 608, "end": 609}, - {"type": "punctuation", "start": 610, "end": 611}, - {"type": "punctuation", "start": 611, "end": 612}, - {"type": "operator", "start": 612, "end": 613}, - {"type": "keyword", "start": 614, "end": 618}, - {"type": "operator", "start": 619, "end": 621}, - {"type": "punctuation", "start": 622, "end": 623}, - {"type": "comment", "start": 626, "end": 635}, - {"type": "keyword", "start": 638, "end": 641}, - {"type": "operator", "start": 644, "end": 645}, - {"type": "number", "start": 646, "end": 647}, - {"type": "punctuation", "start": 647, "end": 648}, - {"type": "special_keyword", "start": 651, "end": 653}, - {"type": "punctuation", "start": 654, "end": 655}, - {"type": "operator", "start": 660, "end": 662}, + {"type": "interpolation_punctuation", "start": 591, "end": 592}, + {"type": "template_punctuation", "start": 592, "end": 593}, + {"type": "punctuation", "start": 593, "end": 594}, + {"type": "punctuation", "start": 596, "end": 597}, + {"type": "function_variable", "start": 600, "end": 615}, + {"type": "operator", "start": 616, "end": 617}, + {"type": "punctuation", "start": 618, "end": 619}, + {"type": "punctuation", "start": 619, "end": 620}, + {"type": "type_annotation", "start": 620, "end": 627}, + {"type": ":", "start": 620, "end": 621}, + {"type": "type", "start": 621, "end": 627}, + {"type": "keyword", "start": 622, "end": 626}, + {"type": "operator", "start": 627, "end": 629}, + {"type": "punctuation", "start": 630, "end": 631}, + {"type": "comment", "start": 634, "end": 643}, + {"type": "keyword", "start": 646, "end": 649}, + {"type": "operator", "start": 652, "end": 653}, + {"type": "number", "start": 654, "end": 655}, + {"type": "punctuation", "start": 655, "end": 656}, + {"type": "special_keyword", "start": 659, "end": 661}, {"type": "punctuation", "start": 662, "end": 663}, - {"type": "punctuation", "start": 666, "end": 667}, - {"type": "special_keyword", "start": 668, "end": 673}, + {"type": "operator", "start": 668, "end": 670}, + {"type": "punctuation", "start": 670, "end": 671}, {"type": "punctuation", "start": 674, "end": 675}, - {"type": "operator", "start": 677, "end": 678}, - {"type": "number", "start": 679, "end": 680}, - {"type": "punctuation", "start": 680, "end": 681}, - {"type": "punctuation", "start": 681, "end": 682}, - {"type": "special_keyword", "start": 686, "end": 689}, - {"type": "punctuation", "start": 690, "end": 691}, - {"type": "keyword", "start": 691, "end": 696}, - {"type": "keyword", "start": 700, "end": 702}, - {"type": "keyword", "start": 703, "end": 707}, - {"type": "punctuation", "start": 707, "end": 708}, - {"type": "punctuation", "start": 710, "end": 711}, - {"type": "punctuation", "start": 712, "end": 713}, - {"type": "special_keyword", "start": 717, "end": 719}, + {"type": "special_keyword", "start": 676, "end": 681}, + {"type": "punctuation", "start": 682, "end": 683}, + {"type": "operator", "start": 685, "end": 686}, + {"type": "number", "start": 687, "end": 688}, + {"type": "punctuation", "start": 688, "end": 689}, + {"type": "punctuation", "start": 689, "end": 690}, + {"type": "special_keyword", "start": 694, "end": 697}, + {"type": "punctuation", "start": 698, "end": 699}, + {"type": "keyword", "start": 699, "end": 704}, + {"type": "keyword", "start": 708, "end": 710}, + {"type": "keyword", "start": 711, "end": 715}, + {"type": "punctuation", "start": 715, "end": 716}, + {"type": "punctuation", "start": 718, "end": 719}, {"type": "punctuation", "start": 720, "end": 721}, - {"type": "operator", "start": 724, "end": 727}, - {"type": "string", "start": 728, "end": 731}, - {"type": "punctuation", "start": 731, "end": 732}, - {"type": "special_keyword", "start": 733, "end": 741}, - {"type": "punctuation", "start": 741, "end": 742}, - {"type": "special_keyword", "start": 746, "end": 748}, + {"type": "special_keyword", "start": 725, "end": 727}, + {"type": "punctuation", "start": 728, "end": 729}, + {"type": "operator", "start": 732, "end": 735}, + {"type": "string", "start": 736, "end": 739}, + {"type": "punctuation", "start": 739, "end": 740}, + {"type": "special_keyword", "start": 741, "end": 749}, {"type": "punctuation", "start": 749, "end": 750}, - {"type": "operator", "start": 750, "end": 751}, - {"type": "punctuation", "start": 753, "end": 754}, - {"type": "special_keyword", "start": 755, "end": 760}, - {"type": "punctuation", "start": 760, "end": 761}, - {"type": "keyword", "start": 765, "end": 769}, - {"type": "punctuation", "start": 769, "end": 770}, - {"type": "function", "start": 770, "end": 785}, - {"type": "punctuation", "start": 785, "end": 786}, - {"type": "punctuation", "start": 787, "end": 788}, - {"type": "punctuation", "start": 791, "end": 792}, - {"type": "punctuation", "start": 792, "end": 793}, - {"type": "punctuation", "start": 796, "end": 797}, - {"type": "special_keyword", "start": 801, "end": 807}, - {"type": "punctuation", "start": 808, "end": 809}, - {"type": "keyword", "start": 809, "end": 813}, - {"type": "punctuation", "start": 813, "end": 814}, + {"type": "special_keyword", "start": 754, "end": 756}, + {"type": "punctuation", "start": 757, "end": 758}, + {"type": "operator", "start": 758, "end": 759}, + {"type": "punctuation", "start": 761, "end": 762}, + {"type": "special_keyword", "start": 763, "end": 768}, + {"type": "punctuation", "start": 768, "end": 769}, + {"type": "keyword", "start": 773, "end": 777}, + {"type": "punctuation", "start": 777, "end": 778}, + {"type": "function", "start": 778, "end": 793}, + {"type": "punctuation", "start": 793, "end": 794}, + {"type": "punctuation", "start": 795, "end": 796}, + {"type": "punctuation", "start": 799, "end": 800}, + {"type": "punctuation", "start": 800, "end": 801}, + {"type": "punctuation", "start": 804, "end": 805}, + {"type": "special_keyword", "start": 809, "end": 815}, {"type": "punctuation", "start": 816, "end": 817}, - {"type": "punctuation", "start": 818, "end": 819}, - {"type": "special_keyword", "start": 823, "end": 827}, - {"type": "string", "start": 828, "end": 831}, - {"type": "operator", "start": 831, "end": 832}, - {"type": "builtin", "start": 837, "end": 844}, - {"type": "punctuation", "start": 844, "end": 845}, - {"type": "function", "start": 845, "end": 848}, - {"type": "punctuation", "start": 848, "end": 849}, - {"type": "string", "start": 849, "end": 857}, - {"type": "punctuation", "start": 857, "end": 858}, - {"type": "punctuation", "start": 858, "end": 859}, - {"type": "special_keyword", "start": 864, "end": 869}, - {"type": "punctuation", "start": 869, "end": 870}, - {"type": "special_keyword", "start": 874, "end": 878}, - {"type": "string", "start": 879, "end": 882}, - {"type": "operator", "start": 882, "end": 883}, - {"type": "special_keyword", "start": 887, "end": 891}, - {"type": "string", "start": 892, "end": 895}, - {"type": "operator", "start": 895, "end": 896}, - {"type": "builtin", "start": 901, "end": 908}, - {"type": "punctuation", "start": 908, "end": 909}, - {"type": "function", "start": 909, "end": 912}, - {"type": "punctuation", "start": 912, "end": 913}, - {"type": "string", "start": 913, "end": 926}, - {"type": "punctuation", "start": 926, "end": 927}, - {"type": "punctuation", "start": 927, "end": 928}, - {"type": "special_keyword", "start": 933, "end": 938}, - {"type": "punctuation", "start": 938, "end": 939}, - {"type": "special_keyword", "start": 943, "end": 950}, - {"type": "operator", "start": 950, "end": 951}, - {"type": "builtin", "start": 956, "end": 963}, - {"type": "punctuation", "start": 963, "end": 964}, - {"type": "function", "start": 964, "end": 967}, - {"type": "punctuation", "start": 967, "end": 968}, - {"type": "string", "start": 968, "end": 977}, - {"type": "punctuation", "start": 977, "end": 978}, - {"type": "punctuation", "start": 978, "end": 979}, - {"type": "punctuation", "start": 982, "end": 983}, - {"type": "keyword", "start": 987, "end": 992}, - {"type": "operator", "start": 996, "end": 997}, - {"type": "punctuation", "start": 998, "end": 999}, - {"type": "operator", "start": 1005, "end": 1006}, - {"type": "operator", "start": 1006, "end": 1007}, - {"type": "builtin", "start": 1008, "end": 1015}, - {"type": "punctuation", "start": 1015, "end": 1016}, - {"type": "operator", "start": 1021, "end": 1022}, - {"type": "builtin", "start": 1023, "end": 1030}, - {"type": "punctuation", "start": 1030, "end": 1031}, - {"type": "operator", "start": 1032, "end": 1033}, - {"type": "punctuation", "start": 1034, "end": 1035}, - {"type": "operator", "start": 1045, "end": 1046}, - {"type": "string", "start": 1047, "end": 1051}, - {"type": "keyword", "start": 1052, "end": 1054}, - {"type": "keyword", "start": 1055, "end": 1059}, - {"type": "punctuation", "start": 1059, "end": 1060}, - {"type": "operator", "start": 1068, "end": 1069}, - {"type": "keyword", "start": 1070, "end": 1074}, - {"type": "keyword", "start": 1075, "end": 1085}, - {"type": "class_name", "start": 1086, "end": 1087}, - {"type": "constant", "start": 1086, "end": 1087}, - {"type": "punctuation", "start": 1087, "end": 1088}, - {"type": "punctuation", "start": 1091, "end": 1092}, - {"type": "punctuation", "start": 1092, "end": 1093}, - {"type": "keyword", "start": 1096, "end": 1102}, - {"type": "punctuation", "start": 1106, "end": 1107}, - {"type": "punctuation", "start": 1113, "end": 1114}, - {"type": "comment", "start": 1117, "end": 1123}, - {"type": "punctuation", "start": 1125, "end": 1126}, - {"type": "punctuation", "start": 1126, "end": 1127}, - {"type": "function", "start": 1130, "end": 1145}, - {"type": "punctuation", "start": 1145, "end": 1146}, - {"type": "operator", "start": 1148, "end": 1149}, - {"type": "builtin", "start": 1150, "end": 1156}, - {"type": "punctuation", "start": 1156, "end": 1157}, - {"type": "operator", "start": 1160, "end": 1161}, - {"type": "builtin", "start": 1162, "end": 1165}, - {"type": "punctuation", "start": 1165, "end": 1166}, - {"type": "punctuation", "start": 1167, "end": 1168}, - {"type": "special_keyword", "start": 1171, "end": 1176}, - {"type": "keyword", "start": 1177, "end": 1180}, - {"type": "class_name", "start": 1181, "end": 1186}, - {"type": "punctuation", "start": 1186, "end": 1187}, - {"type": "template_string", "start": 1187, "end": 1233}, - {"type": "template_punctuation", "start": 1187, "end": 1188}, - {"type": "interpolation", "start": 1188, "end": 1198}, - {"type": "interpolation_punctuation", "start": 1188, "end": 1190}, - {"type": "keyword", "start": 1190, "end": 1194}, + {"type": "keyword", "start": 817, "end": 821}, + {"type": "punctuation", "start": 821, "end": 822}, + {"type": "punctuation", "start": 824, "end": 825}, + {"type": "punctuation", "start": 826, "end": 827}, + {"type": "special_keyword", "start": 831, "end": 835}, + {"type": "string", "start": 836, "end": 839}, + {"type": "operator", "start": 839, "end": 840}, + {"type": "builtin", "start": 845, "end": 852}, + {"type": "punctuation", "start": 852, "end": 853}, + {"type": "function", "start": 853, "end": 856}, + {"type": "punctuation", "start": 856, "end": 857}, + {"type": "string", "start": 857, "end": 865}, + {"type": "punctuation", "start": 865, "end": 866}, + {"type": "punctuation", "start": 866, "end": 867}, + {"type": "special_keyword", "start": 872, "end": 877}, + {"type": "punctuation", "start": 877, "end": 878}, + {"type": "special_keyword", "start": 882, "end": 886}, + {"type": "string", "start": 887, "end": 890}, + {"type": "operator", "start": 890, "end": 891}, + {"type": "special_keyword", "start": 895, "end": 899}, + {"type": "string", "start": 900, "end": 903}, + {"type": "operator", "start": 903, "end": 904}, + {"type": "builtin", "start": 909, "end": 916}, + {"type": "punctuation", "start": 916, "end": 917}, + {"type": "function", "start": 917, "end": 920}, + {"type": "punctuation", "start": 920, "end": 921}, + {"type": "string", "start": 921, "end": 934}, + {"type": "punctuation", "start": 934, "end": 935}, + {"type": "punctuation", "start": 935, "end": 936}, + {"type": "special_keyword", "start": 941, "end": 946}, + {"type": "punctuation", "start": 946, "end": 947}, + {"type": "special_keyword", "start": 951, "end": 958}, + {"type": "operator", "start": 958, "end": 959}, + {"type": "builtin", "start": 964, "end": 971}, + {"type": "punctuation", "start": 971, "end": 972}, + {"type": "function", "start": 972, "end": 975}, + {"type": "punctuation", "start": 975, "end": 976}, + {"type": "string", "start": 976, "end": 985}, + {"type": "punctuation", "start": 985, "end": 986}, + {"type": "punctuation", "start": 986, "end": 987}, + {"type": "punctuation", "start": 990, "end": 991}, + {"type": "keyword", "start": 995, "end": 1000}, + {"type": "operator", "start": 1004, "end": 1005}, + {"type": "punctuation", "start": 1006, "end": 1007}, + {"type": "operator", "start": 1013, "end": 1014}, + {"type": "operator", "start": 1014, "end": 1015}, + {"type": "builtin", "start": 1016, "end": 1023}, + {"type": "punctuation", "start": 1023, "end": 1024}, + {"type": "operator", "start": 1029, "end": 1030}, + {"type": "builtin", "start": 1031, "end": 1038}, + {"type": "punctuation", "start": 1038, "end": 1039}, + {"type": "operator", "start": 1040, "end": 1041}, + {"type": "punctuation", "start": 1042, "end": 1043}, + {"type": "operator", "start": 1053, "end": 1054}, + {"type": "string", "start": 1055, "end": 1059}, + {"type": "keyword", "start": 1060, "end": 1062}, + {"type": "keyword", "start": 1063, "end": 1067}, + {"type": "punctuation", "start": 1067, "end": 1068}, + {"type": "operator", "start": 1076, "end": 1077}, + {"type": "keyword", "start": 1078, "end": 1082}, + {"type": "keyword", "start": 1083, "end": 1093}, + {"type": "class_name", "start": 1094, "end": 1095}, + {"type": "constant", "start": 1094, "end": 1095}, + {"type": "punctuation", "start": 1095, "end": 1096}, + {"type": "punctuation", "start": 1099, "end": 1100}, + {"type": "punctuation", "start": 1100, "end": 1101}, + {"type": "keyword", "start": 1104, "end": 1110}, + {"type": "punctuation", "start": 1114, "end": 1115}, + {"type": "punctuation", "start": 1121, "end": 1122}, + {"type": "comment", "start": 1125, "end": 1131}, + {"type": "punctuation", "start": 1133, "end": 1134}, + {"type": "punctuation", "start": 1134, "end": 1135}, + {"type": "function", "start": 1138, "end": 1153}, + {"type": "punctuation", "start": 1153, "end": 1154}, + {"type": "operator", "start": 1156, "end": 1157}, + {"type": "builtin", "start": 1158, "end": 1164}, + {"type": "punctuation", "start": 1164, "end": 1165}, + {"type": "operator", "start": 1168, "end": 1169}, + {"type": "builtin", "start": 1170, "end": 1173}, + {"type": "punctuation", "start": 1173, "end": 1174}, + {"type": "punctuation", "start": 1175, "end": 1176}, + {"type": "special_keyword", "start": 1179, "end": 1184}, + {"type": "keyword", "start": 1185, "end": 1188}, + {"type": "class_name", "start": 1189, "end": 1194}, + {"type": "type_name", "start": 1189, "end": 1194}, {"type": "punctuation", "start": 1194, "end": 1195}, - {"type": "interpolation_punctuation", "start": 1197, "end": 1198}, - {"type": "string", "start": 1198, "end": 1219}, - {"type": "interpolation", "start": 1219, "end": 1229}, - {"type": "interpolation_punctuation", "start": 1219, "end": 1221}, - {"type": "operator", "start": 1224, "end": 1225}, - {"type": "interpolation_punctuation", "start": 1228, "end": 1229}, - {"type": "string", "start": 1229, "end": 1232}, - {"type": "template_punctuation", "start": 1232, "end": 1233}, - {"type": "punctuation", "start": 1233, "end": 1234}, - {"type": "punctuation", "start": 1234, "end": 1235}, - {"type": "punctuation", "start": 1237, "end": 1238}, - {"type": "operator", "start": 1241, "end": 1242}, - {"type": "function", "start": 1242, "end": 1251}, - {"type": "punctuation", "start": 1251, "end": 1252}, - {"type": "punctuation", "start": 1252, "end": 1253}, - {"type": "punctuation", "start": 1254, "end": 1255}, - {"type": "special_keyword", "start": 1258, "end": 1263}, - {"type": "number", "start": 1264, "end": 1265}, - {"type": "punctuation", "start": 1265, "end": 1266}, - {"type": "special_keyword", "start": 1269, "end": 1274}, - {"type": "operator", "start": 1274, "end": 1275}, - {"type": "punctuation", "start": 1276, "end": 1277}, - {"type": "number", "start": 1277, "end": 1278}, - {"type": "punctuation", "start": 1278, "end": 1279}, - {"type": "number", "start": 1280, "end": 1281}, - {"type": "punctuation", "start": 1281, "end": 1282}, - {"type": "punctuation", "start": 1282, "end": 1283}, - {"type": "punctuation", "start": 1285, "end": 1286}, - {"type": "operator", "start": 1295, "end": 1296}, - {"type": "function", "start": 1296, "end": 1311}, - {"type": "punctuation", "start": 1311, "end": 1312}, - {"type": "punctuation", "start": 1312, "end": 1313}, - {"type": "punctuation", "start": 1314, "end": 1315}, - {"type": "special_keyword", "start": 1318, "end": 1323}, - {"type": "special_keyword", "start": 1324, "end": 1329}, - {"type": "builtin", "start": 1330, "end": 1337}, - {"type": "punctuation", "start": 1337, "end": 1338}, - {"type": "function", "start": 1338, "end": 1345}, + {"type": "template_string", "start": 1195, "end": 1241}, + {"type": "template_punctuation", "start": 1195, "end": 1196}, + {"type": "interpolation", "start": 1196, "end": 1206}, + {"type": "interpolation_punctuation", "start": 1196, "end": 1198}, + {"type": "keyword", "start": 1198, "end": 1202}, + {"type": "punctuation", "start": 1202, "end": 1203}, + {"type": "interpolation_punctuation", "start": 1205, "end": 1206}, + {"type": "string", "start": 1206, "end": 1227}, + {"type": "interpolation", "start": 1227, "end": 1237}, + {"type": "interpolation_punctuation", "start": 1227, "end": 1229}, + {"type": "operator", "start": 1232, "end": 1233}, + {"type": "interpolation_punctuation", "start": 1236, "end": 1237}, + {"type": "string", "start": 1237, "end": 1240}, + {"type": "template_punctuation", "start": 1240, "end": 1241}, + {"type": "punctuation", "start": 1241, "end": 1242}, + {"type": "punctuation", "start": 1242, "end": 1243}, + {"type": "punctuation", "start": 1245, "end": 1246}, + {"type": "operator", "start": 1249, "end": 1250}, + {"type": "function", "start": 1250, "end": 1259}, + {"type": "punctuation", "start": 1259, "end": 1260}, + {"type": "punctuation", "start": 1260, "end": 1261}, + {"type": "punctuation", "start": 1262, "end": 1263}, + {"type": "special_keyword", "start": 1266, "end": 1271}, + {"type": "number", "start": 1272, "end": 1273}, + {"type": "punctuation", "start": 1273, "end": 1274}, + {"type": "special_keyword", "start": 1277, "end": 1282}, + {"type": "operator", "start": 1282, "end": 1283}, + {"type": "punctuation", "start": 1284, "end": 1285}, + {"type": "number", "start": 1285, "end": 1286}, + {"type": "punctuation", "start": 1286, "end": 1287}, + {"type": "number", "start": 1288, "end": 1289}, + {"type": "punctuation", "start": 1289, "end": 1290}, + {"type": "punctuation", "start": 1290, "end": 1291}, + {"type": "punctuation", "start": 1293, "end": 1294}, + {"type": "operator", "start": 1303, "end": 1304}, + {"type": "function", "start": 1304, "end": 1319}, + {"type": "punctuation", "start": 1319, "end": 1320}, + {"type": "punctuation", "start": 1320, "end": 1321}, + {"type": "punctuation", "start": 1322, "end": 1323}, + {"type": "special_keyword", "start": 1326, "end": 1331}, + {"type": "special_keyword", "start": 1332, "end": 1337}, + {"type": "builtin", "start": 1338, "end": 1345}, {"type": "punctuation", "start": 1345, "end": 1346}, - {"type": "number", "start": 1346, "end": 1347}, - {"type": "punctuation", "start": 1347, "end": 1348}, - {"type": "punctuation", "start": 1348, "end": 1349}, - {"type": "punctuation", "start": 1351, "end": 1352}, - {"type": "keyword", "start": 1355, "end": 1364}, - {"type": "keyword", "start": 1365, "end": 1370}, - {"type": "function", "start": 1371, "end": 1387}, - {"type": "punctuation", "start": 1387, "end": 1388}, - {"type": "punctuation", "start": 1388, "end": 1389}, - {"type": "operator", "start": 1389, "end": 1390}, - {"type": "builtin", "start": 1391, "end": 1398}, - {"type": "operator", "start": 1398, "end": 1399}, - {"type": "keyword", "start": 1399, "end": 1403}, - {"type": "operator", "start": 1403, "end": 1404}, - {"type": "punctuation", "start": 1405, "end": 1406}, - {"type": "special_keyword", "start": 1409, "end": 1412}, + {"type": "function", "start": 1346, "end": 1353}, + {"type": "punctuation", "start": 1353, "end": 1354}, + {"type": "number", "start": 1354, "end": 1355}, + {"type": "punctuation", "start": 1355, "end": 1356}, + {"type": "punctuation", "start": 1356, "end": 1357}, + {"type": "punctuation", "start": 1359, "end": 1360}, + {"type": "keyword", "start": 1363, "end": 1372}, + {"type": "keyword", "start": 1373, "end": 1378}, + {"type": "function", "start": 1379, "end": 1395}, + {"type": "punctuation", "start": 1395, "end": 1396}, + {"type": "punctuation", "start": 1396, "end": 1397}, + {"type": "operator", "start": 1397, "end": 1398}, + {"type": "builtin", "start": 1399, "end": 1406}, + {"type": "operator", "start": 1406, "end": 1407}, + {"type": "keyword", "start": 1407, "end": 1411}, + {"type": "operator", "start": 1411, "end": 1412}, {"type": "punctuation", "start": 1413, "end": 1414}, - {"type": "special_keyword", "start": 1418, "end": 1423}, - {"type": "keyword", "start": 1424, "end": 1427}, - {"type": "class_name", "start": 1428, "end": 1435}, - {"type": "builtin", "start": 1428, "end": 1435}, - {"type": "punctuation", "start": 1435, "end": 1436}, - {"type": "punctuation", "start": 1436, "end": 1437}, + {"type": "special_keyword", "start": 1417, "end": 1420}, + {"type": "punctuation", "start": 1421, "end": 1422}, + {"type": "special_keyword", "start": 1426, "end": 1431}, + {"type": "keyword", "start": 1432, "end": 1435}, + {"type": "class_name", "start": 1436, "end": 1443}, + {"type": "builtin", "start": 1436, "end": 1443}, + {"type": "punctuation", "start": 1443, "end": 1444}, {"type": "punctuation", "start": 1444, "end": 1445}, - {"type": "operator", "start": 1446, "end": 1448}, - {"type": "function", "start": 1449, "end": 1459}, - {"type": "punctuation", "start": 1459, "end": 1460}, + {"type": "punctuation", "start": 1452, "end": 1453}, + {"type": "operator", "start": 1454, "end": 1456}, + {"type": "function", "start": 1457, "end": 1467}, {"type": "punctuation", "start": 1467, "end": 1468}, - {"type": "number", "start": 1469, "end": 1472}, - {"type": "punctuation", "start": 1472, "end": 1473}, - {"type": "punctuation", "start": 1473, "end": 1474}, - {"type": "punctuation", "start": 1474, "end": 1475}, - {"type": "special_keyword", "start": 1479, "end": 1481}, + {"type": "punctuation", "start": 1475, "end": 1476}, + {"type": "number", "start": 1477, "end": 1480}, + {"type": "punctuation", "start": 1480, "end": 1481}, + {"type": "punctuation", "start": 1481, "end": 1482}, {"type": "punctuation", "start": 1482, "end": 1483}, - {"type": "punctuation", "start": 1487, "end": 1488}, - {"type": "function", "start": 1488, "end": 1494}, - {"type": "punctuation", "start": 1494, "end": 1495}, + {"type": "special_keyword", "start": 1487, "end": 1489}, + {"type": "punctuation", "start": 1490, "end": 1491}, {"type": "punctuation", "start": 1495, "end": 1496}, - {"type": "operator", "start": 1497, "end": 1498}, - {"type": "number", "start": 1499, "end": 1502}, + {"type": "function", "start": 1496, "end": 1502}, {"type": "punctuation", "start": 1502, "end": 1503}, - {"type": "punctuation", "start": 1504, "end": 1505}, - {"type": "builtin", "start": 1510, "end": 1517}, - {"type": "punctuation", "start": 1517, "end": 1518}, - {"type": "function", "start": 1518, "end": 1521}, - {"type": "punctuation", "start": 1521, "end": 1522}, - {"type": "keyword", "start": 1522, "end": 1525}, - {"type": "class_name", "start": 1526, "end": 1530}, - {"type": "punctuation", "start": 1530, "end": 1531}, - {"type": "punctuation", "start": 1531, "end": 1532}, - {"type": "punctuation", "start": 1532, "end": 1533}, - {"type": "punctuation", "start": 1533, "end": 1534}, - {"type": "comment", "start": 1535, "end": 1568}, - {"type": "punctuation", "start": 1572, "end": 1573}, - {"type": "special_keyword", "start": 1574, "end": 1578}, - {"type": "special_keyword", "start": 1579, "end": 1581}, - {"type": "punctuation", "start": 1582, "end": 1583}, - {"type": "punctuation", "start": 1587, "end": 1588}, - {"type": "function", "start": 1588, "end": 1594}, - {"type": "punctuation", "start": 1594, "end": 1595}, + {"type": "punctuation", "start": 1503, "end": 1504}, + {"type": "operator", "start": 1505, "end": 1506}, + {"type": "number", "start": 1507, "end": 1510}, + {"type": "punctuation", "start": 1510, "end": 1511}, + {"type": "punctuation", "start": 1512, "end": 1513}, + {"type": "builtin", "start": 1518, "end": 1525}, + {"type": "punctuation", "start": 1525, "end": 1526}, + {"type": "function", "start": 1526, "end": 1529}, + {"type": "punctuation", "start": 1529, "end": 1530}, + {"type": "keyword", "start": 1530, "end": 1533}, + {"type": "class_name", "start": 1534, "end": 1538}, + {"type": "type_name", "start": 1534, "end": 1538}, + {"type": "punctuation", "start": 1538, "end": 1539}, + {"type": "punctuation", "start": 1539, "end": 1540}, + {"type": "punctuation", "start": 1540, "end": 1541}, + {"type": "punctuation", "start": 1541, "end": 1542}, + {"type": "comment", "start": 1543, "end": 1576}, + {"type": "punctuation", "start": 1580, "end": 1581}, + {"type": "special_keyword", "start": 1582, "end": 1586}, + {"type": "special_keyword", "start": 1587, "end": 1589}, + {"type": "punctuation", "start": 1590, "end": 1591}, {"type": "punctuation", "start": 1595, "end": 1596}, - {"type": "operator", "start": 1597, "end": 1598}, - {"type": "number", "start": 1599, "end": 1602}, + {"type": "function", "start": 1596, "end": 1602}, {"type": "punctuation", "start": 1602, "end": 1603}, - {"type": "punctuation", "start": 1604, "end": 1605}, - {"type": "builtin", "start": 1610, "end": 1617}, - {"type": "punctuation", "start": 1617, "end": 1618}, - {"type": "function", "start": 1618, "end": 1621}, - {"type": "punctuation", "start": 1621, "end": 1622}, - {"type": "string", "start": 1622, "end": 1638}, - {"type": "punctuation", "start": 1638, "end": 1639}, - {"type": "punctuation", "start": 1639, "end": 1640}, - {"type": "punctuation", "start": 1644, "end": 1645}, - {"type": "special_keyword", "start": 1646, "end": 1650}, - {"type": "punctuation", "start": 1651, "end": 1652}, - {"type": "builtin", "start": 1657, "end": 1664}, - {"type": "punctuation", "start": 1664, "end": 1665}, - {"type": "function", "start": 1665, "end": 1668}, - {"type": "punctuation", "start": 1668, "end": 1669}, - {"type": "string", "start": 1669, "end": 1682}, - {"type": "punctuation", "start": 1682, "end": 1683}, - {"type": "punctuation", "start": 1683, "end": 1684}, - {"type": "punctuation", "start": 1688, "end": 1689}, - {"type": "punctuation", "start": 1692, "end": 1693}, - {"type": "special_keyword", "start": 1694, "end": 1699}, + {"type": "punctuation", "start": 1603, "end": 1604}, + {"type": "operator", "start": 1605, "end": 1606}, + {"type": "number", "start": 1607, "end": 1610}, + {"type": "punctuation", "start": 1610, "end": 1611}, + {"type": "punctuation", "start": 1612, "end": 1613}, + {"type": "builtin", "start": 1618, "end": 1625}, + {"type": "punctuation", "start": 1625, "end": 1626}, + {"type": "function", "start": 1626, "end": 1629}, + {"type": "punctuation", "start": 1629, "end": 1630}, + {"type": "string", "start": 1630, "end": 1646}, + {"type": "punctuation", "start": 1646, "end": 1647}, + {"type": "punctuation", "start": 1647, "end": 1648}, + {"type": "punctuation", "start": 1652, "end": 1653}, + {"type": "special_keyword", "start": 1654, "end": 1658}, + {"type": "punctuation", "start": 1659, "end": 1660}, + {"type": "builtin", "start": 1665, "end": 1672}, + {"type": "punctuation", "start": 1672, "end": 1673}, + {"type": "function", "start": 1673, "end": 1676}, + {"type": "punctuation", "start": 1676, "end": 1677}, + {"type": "string", "start": 1677, "end": 1690}, + {"type": "punctuation", "start": 1690, "end": 1691}, + {"type": "punctuation", "start": 1691, "end": 1692}, + {"type": "punctuation", "start": 1696, "end": 1697}, {"type": "punctuation", "start": 1700, "end": 1701}, - {"type": "operator", "start": 1706, "end": 1707}, - {"type": "builtin", "start": 1708, "end": 1715}, - {"type": "punctuation", "start": 1715, "end": 1716}, - {"type": "punctuation", "start": 1717, "end": 1718}, - {"type": "builtin", "start": 1722, "end": 1729}, - {"type": "punctuation", "start": 1729, "end": 1730}, - {"type": "function", "start": 1730, "end": 1735}, - {"type": "punctuation", "start": 1735, "end": 1736}, - {"type": "punctuation", "start": 1741, "end": 1742}, - {"type": "punctuation", "start": 1742, "end": 1743}, - {"type": "punctuation", "start": 1746, "end": 1747}, - {"type": "special_keyword", "start": 1748, "end": 1755}, - {"type": "punctuation", "start": 1756, "end": 1757}, - {"type": "builtin", "start": 1761, "end": 1768}, - {"type": "punctuation", "start": 1768, "end": 1769}, - {"type": "function", "start": 1769, "end": 1772}, - {"type": "punctuation", "start": 1772, "end": 1773}, - {"type": "string", "start": 1773, "end": 1788}, - {"type": "punctuation", "start": 1788, "end": 1789}, - {"type": "punctuation", "start": 1789, "end": 1790}, - {"type": "punctuation", "start": 1793, "end": 1794}, + {"type": "special_keyword", "start": 1702, "end": 1707}, + {"type": "punctuation", "start": 1708, "end": 1709}, + {"type": "operator", "start": 1714, "end": 1715}, + {"type": "builtin", "start": 1716, "end": 1723}, + {"type": "punctuation", "start": 1723, "end": 1724}, + {"type": "punctuation", "start": 1725, "end": 1726}, + {"type": "builtin", "start": 1730, "end": 1737}, + {"type": "punctuation", "start": 1737, "end": 1738}, + {"type": "function", "start": 1738, "end": 1743}, + {"type": "punctuation", "start": 1743, "end": 1744}, + {"type": "punctuation", "start": 1749, "end": 1750}, + {"type": "punctuation", "start": 1750, "end": 1751}, + {"type": "punctuation", "start": 1754, "end": 1755}, + {"type": "special_keyword", "start": 1756, "end": 1763}, + {"type": "punctuation", "start": 1764, "end": 1765}, + {"type": "builtin", "start": 1769, "end": 1776}, + {"type": "punctuation", "start": 1776, "end": 1777}, + {"type": "function", "start": 1777, "end": 1780}, + {"type": "punctuation", "start": 1780, "end": 1781}, + {"type": "string", "start": 1781, "end": 1796}, {"type": "punctuation", "start": 1796, "end": 1797}, - {"type": "punctuation", "start": 1798, "end": 1799}, - {"type": "comment", "start": 1801, "end": 1811}, - {"type": "comment", "start": 1813, "end": 1856}, - {"type": "comment", "start": 1858, "end": 1882}, - {"type": "special_keyword", "start": 1884, "end": 1890}, - {"type": "punctuation", "start": 1891, "end": 1892}, - {"type": "punctuation", "start": 1904, "end": 1905}, - {"type": "keyword", "start": 1906, "end": 1910}, - {"type": "class_name", "start": 1911, "end": 1922}, - {"type": "punctuation", "start": 1922, "end": 1923}, - {"type": "special_keyword", "start": 1924, "end": 1928}, - {"type": "string", "start": 1929, "end": 1948}, - {"type": "punctuation", "start": 1948, "end": 1949}, - {"type": "special_keyword", "start": 1950, "end": 1956}, - {"type": "operator", "start": 1957, "end": 1958}, - {"type": "special_keyword", "start": 1959, "end": 1961}, - {"type": "constant", "start": 1962, "end": 1963}, - {"type": "special_keyword", "start": 1964, "end": 1968}, - {"type": "string", "start": 1969, "end": 1988}, - {"type": "punctuation", "start": 1988, "end": 1989}, - {"type": "special_keyword", "start": 1991, "end": 1997}, - {"type": "punctuation", "start": 1998, "end": 1999}, - {"type": "punctuation", "start": 2000, "end": 2001}, - {"type": "constant", "start": 2002, "end": 2003}, - {"type": "punctuation", "start": 2003, "end": 2004}, + {"type": "punctuation", "start": 1797, "end": 1798}, + {"type": "punctuation", "start": 1801, "end": 1802}, + {"type": "punctuation", "start": 1804, "end": 1805}, + {"type": "punctuation", "start": 1806, "end": 1807}, + {"type": "comment", "start": 1809, "end": 1819}, + {"type": "comment", "start": 1821, "end": 1864}, + {"type": "comment", "start": 1866, "end": 1890}, + {"type": "special_keyword", "start": 1892, "end": 1898}, + {"type": "punctuation", "start": 1899, "end": 1900}, + {"type": "punctuation", "start": 1912, "end": 1913}, + {"type": "keyword", "start": 1914, "end": 1918}, + {"type": "class_name", "start": 1919, "end": 1930}, + {"type": "type_name", "start": 1919, "end": 1930}, + {"type": "punctuation", "start": 1930, "end": 1931}, + {"type": "special_keyword", "start": 1932, "end": 1936}, + {"type": "string", "start": 1937, "end": 1956}, + {"type": "punctuation", "start": 1956, "end": 1957}, + {"type": "special_keyword", "start": 1958, "end": 1964}, + {"type": "operator", "start": 1965, "end": 1966}, + {"type": "special_keyword", "start": 1967, "end": 1969}, + {"type": "constant", "start": 1970, "end": 1971}, + {"type": "special_keyword", "start": 1972, "end": 1976}, + {"type": "string", "start": 1977, "end": 1996}, + {"type": "punctuation", "start": 1996, "end": 1997}, + {"type": "special_keyword", "start": 1999, "end": 2005}, {"type": "punctuation", "start": 2006, "end": 2007}, - {"type": "punctuation", "start": 2009, "end": 2010}, - {"type": "constant", "start": 2011, "end": 2012}, - {"type": "punctuation", "start": 2012, "end": 2013}, - {"type": "punctuation", "start": 2013, "end": 2014}, - {"type": "special_keyword", "start": 2029, "end": 2031}, - {"type": "builtin", "start": 2032, "end": 2039}, - {"type": "special_keyword", "start": 2040, "end": 2042}, - {"type": "builtin", "start": 2043, "end": 2046}, - {"type": "special_keyword", "start": 2047, "end": 2049}, - {"type": "keyword", "start": 2062, "end": 2071}, - {"type": "punctuation", "start": 2083, "end": 2084}, - {"type": "special_keyword", "start": 2086, "end": 2092}, - {"type": "keyword", "start": 2093, "end": 2102}, - {"type": "class_name", "start": 2103, "end": 2109}, - {"type": "punctuation", "start": 2110, "end": 2111}, + {"type": "punctuation", "start": 2008, "end": 2009}, + {"type": "constant", "start": 2010, "end": 2011}, + {"type": "punctuation", "start": 2011, "end": 2012}, + {"type": "punctuation", "start": 2014, "end": 2015}, + {"type": "punctuation", "start": 2017, "end": 2018}, + {"type": "constant", "start": 2019, "end": 2020}, + {"type": "punctuation", "start": 2020, "end": 2021}, + {"type": "punctuation", "start": 2021, "end": 2022}, + {"type": "special_keyword", "start": 2037, "end": 2039}, + {"type": "builtin", "start": 2040, "end": 2047}, + {"type": "special_keyword", "start": 2048, "end": 2050}, + {"type": "builtin", "start": 2051, "end": 2054}, + {"type": "special_keyword", "start": 2055, "end": 2057}, + {"type": "keyword", "start": 2070, "end": 2079}, + {"type": "punctuation", "start": 2091, "end": 2092}, + {"type": "special_keyword", "start": 2094, "end": 2100}, + {"type": "keyword", "start": 2101, "end": 2110}, + {"type": "class_name", "start": 2111, "end": 2132}, + {"type": "type_name", "start": 2111, "end": 2117}, {"type": "operator", "start": 2117, "end": 2118}, - {"type": "builtin", "start": 2119, "end": 2125}, - {"type": "punctuation", "start": 2125, "end": 2126}, + {"type": "constant", "start": 2118, "end": 2119}, + {"type": "operator", "start": 2120, "end": 2121}, + {"type": "keyword", "start": 2122, "end": 2131}, {"type": "operator", "start": 2131, "end": 2132}, - {"type": "builtin", "start": 2133, "end": 2139}, - {"type": "punctuation", "start": 2139, "end": 2140}, - {"type": "punctuation", "start": 2141, "end": 2142}, - {"type": "special_keyword", "start": 2144, "end": 2150}, - {"type": "keyword", "start": 2151, "end": 2156}, - {"type": "operator", "start": 2163, "end": 2164}, - {"type": "operator", "start": 2172, "end": 2173}, - {"type": "punctuation", "start": 2174, "end": 2175}, - {"type": "operator", "start": 2179, "end": 2180}, - {"type": "string", "start": 2181, "end": 2188}, - {"type": "punctuation", "start": 2188, "end": 2189}, - {"type": "operator", "start": 2193, "end": 2194}, - {"type": "number", "start": 2195, "end": 2198}, - {"type": "punctuation", "start": 2198, "end": 2199}, - {"type": "punctuation", "start": 2199, "end": 2200}, - {"type": "special_keyword", "start": 2202, "end": 2208}, - {"type": "keyword", "start": 2209, "end": 2217}, - {"type": "function", "start": 2218, "end": 2221}, - {"type": "punctuation", "start": 2221, "end": 2222}, - {"type": "operator", "start": 2223, "end": 2224}, - {"type": "builtin", "start": 2225, "end": 2231}, - {"type": "punctuation", "start": 2231, "end": 2232}, - {"type": "operator", "start": 2234, "end": 2235}, - {"type": "builtin", "start": 2236, "end": 2242}, - {"type": "punctuation", "start": 2242, "end": 2243}, - {"type": "operator", "start": 2243, "end": 2244}, - {"type": "builtin", "start": 2245, "end": 2251}, + {"type": "punctuation", "start": 2133, "end": 2134}, + {"type": "operator", "start": 2140, "end": 2141}, + {"type": "builtin", "start": 2142, "end": 2148}, + {"type": "punctuation", "start": 2148, "end": 2149}, + {"type": "operator", "start": 2154, "end": 2155}, + {"type": "builtin", "start": 2156, "end": 2162}, + {"type": "punctuation", "start": 2162, "end": 2163}, + {"type": "operator", "start": 2166, "end": 2167}, + {"type": "operator", "start": 2167, "end": 2168}, + {"type": "constant", "start": 2169, "end": 2170}, + {"type": "punctuation", "start": 2170, "end": 2171}, + {"type": "punctuation", "start": 2172, "end": 2173}, + {"type": "keyword", "start": 2175, "end": 2180}, + {"type": "operator", "start": 2182, "end": 2183}, + {"type": "punctuation", "start": 2184, "end": 2185}, + {"type": "operator", "start": 2189, "end": 2190}, + {"type": "builtin", "start": 2191, "end": 2197}, + {"type": "punctuation", "start": 2197, "end": 2198}, + {"type": "operator", "start": 2202, "end": 2203}, + {"type": "builtin", "start": 2204, "end": 2210}, + {"type": "punctuation", "start": 2210, "end": 2211}, + {"type": "operator", "start": 2212, "end": 2213}, + {"type": "punctuation", "start": 2214, "end": 2215}, + {"type": "operator", "start": 2219, "end": 2220}, + {"type": "string", "start": 2221, "end": 2228}, + {"type": "punctuation", "start": 2228, "end": 2229}, + {"type": "operator", "start": 2233, "end": 2234}, + {"type": "number", "start": 2235, "end": 2238}, + {"type": "punctuation", "start": 2238, "end": 2239}, + {"type": "punctuation", "start": 2239, "end": 2240}, + {"type": "keyword", "start": 2241, "end": 2246}, + {"type": "operator", "start": 2249, "end": 2250}, + {"type": "punctuation", "start": 2251, "end": 2252}, {"type": "punctuation", "start": 2252, "end": 2253}, - {"type": "special_keyword", "start": 2255, "end": 2261}, - {"type": "operator", "start": 2264, "end": 2265}, - {"type": "punctuation", "start": 2267, "end": 2268}, + {"type": "string", "start": 2253, "end": 2255}, + {"type": "punctuation", "start": 2255, "end": 2256}, + {"type": "punctuation", "start": 2258, "end": 2259}, + {"type": "punctuation", "start": 2259, "end": 2260}, + {"type": "special_keyword", "start": 2261, "end": 2263}, + {"type": "keyword", "start": 2264, "end": 2269}, {"type": "punctuation", "start": 2269, "end": 2270}, - {"type": "special_keyword", "start": 2272, "end": 2278}, - {"type": "keyword", "start": 2279, "end": 2284}, - {"type": "function_variable", "start": 2285, "end": 2289}, - {"type": "operator", "start": 2290, "end": 2291}, - {"type": "punctuation", "start": 2292, "end": 2293}, - {"type": "operator", "start": 2294, "end": 2295}, - {"type": "builtin", "start": 2296, "end": 2299}, - {"type": "punctuation", "start": 2299, "end": 2300}, - {"type": "operator", "start": 2302, "end": 2303}, - {"type": "builtin", "start": 2304, "end": 2307}, - {"type": "punctuation", "start": 2307, "end": 2308}, - {"type": "operator", "start": 2308, "end": 2309}, - {"type": "builtin", "start": 2310, "end": 2313}, - {"type": "operator", "start": 2314, "end": 2316}, - {"type": "operator", "start": 2319, "end": 2320}, - {"type": "punctuation", "start": 2322, "end": 2323}, - {"type": "comment", "start": 2325, "end": 2347}, - {"type": "special_keyword", "start": 2348, "end": 2354}, - {"type": "keyword", "start": 2355, "end": 2360}, - {"type": "operator", "start": 2379, "end": 2380}, - {"type": "string", "start": 2381, "end": 2410}, - {"type": "punctuation", "start": 2410, "end": 2411}, - {"type": "special_keyword", "start": 2412, "end": 2418}, - {"type": "keyword", "start": 2419, "end": 2424}, - {"type": "operator", "start": 2442, "end": 2443}, - {"type": "string", "start": 2444, "end": 2470}, - {"type": "punctuation", "start": 2470, "end": 2471}, - {"type": "special_keyword", "start": 2472, "end": 2478}, - {"type": "keyword", "start": 2479, "end": 2484}, + {"type": "special_keyword", "start": 2271, "end": 2277}, + {"type": "keyword", "start": 2278, "end": 2283}, + {"type": "type_annotation", "start": 2290, "end": 2312}, + {"type": ":", "start": 2290, "end": 2291}, + {"type": "type", "start": 2291, "end": 2312}, + {"type": "type_name", "start": 2292, "end": 2295}, + {"type": "operator", "start": 2295, "end": 2296}, + {"type": "builtin", "start": 2296, "end": 2302}, + {"type": "punctuation", "start": 2302, "end": 2303}, + {"type": "type_name", "start": 2304, "end": 2310}, + {"type": "operator", "start": 2310, "end": 2311}, + {"type": "operator", "start": 2312, "end": 2313}, + {"type": "keyword", "start": 2314, "end": 2317}, + {"type": "class_name", "start": 2318, "end": 2321}, + {"type": "type_name", "start": 2318, "end": 2321}, + {"type": "punctuation", "start": 2321, "end": 2322}, + {"type": "punctuation", "start": 2323, "end": 2324}, + {"type": "punctuation", "start": 2324, "end": 2325}, + {"type": "special_keyword", "start": 2327, "end": 2333}, + {"type": "keyword", "start": 2334, "end": 2342}, + {"type": "function", "start": 2343, "end": 2346}, + {"type": "punctuation", "start": 2346, "end": 2347}, + {"type": "operator", "start": 2348, "end": 2349}, + {"type": "builtin", "start": 2350, "end": 2356}, + {"type": "punctuation", "start": 2356, "end": 2357}, + {"type": "operator", "start": 2359, "end": 2360}, + {"type": "builtin", "start": 2361, "end": 2367}, + {"type": "punctuation", "start": 2367, "end": 2368}, + {"type": "operator", "start": 2368, "end": 2369}, + {"type": "builtin", "start": 2370, "end": 2376}, + {"type": "punctuation", "start": 2377, "end": 2378}, + {"type": "special_keyword", "start": 2380, "end": 2386}, + {"type": "operator", "start": 2389, "end": 2390}, + {"type": "punctuation", "start": 2392, "end": 2393}, + {"type": "punctuation", "start": 2394, "end": 2395}, + {"type": "special_keyword", "start": 2397, "end": 2403}, + {"type": "keyword", "start": 2404, "end": 2409}, + {"type": "function_variable", "start": 2410, "end": 2414}, + {"type": "operator", "start": 2415, "end": 2416}, + {"type": "punctuation", "start": 2417, "end": 2418}, + {"type": "operator", "start": 2419, "end": 2420}, + {"type": "builtin", "start": 2421, "end": 2424}, + {"type": "punctuation", "start": 2424, "end": 2425}, + {"type": "operator", "start": 2427, "end": 2428}, + {"type": "builtin", "start": 2429, "end": 2432}, + {"type": "punctuation", "start": 2432, "end": 2433}, + {"type": "type_annotation", "start": 2433, "end": 2439}, + {"type": ":", "start": 2433, "end": 2434}, + {"type": "type", "start": 2434, "end": 2439}, + {"type": "builtin", "start": 2435, "end": 2438}, + {"type": "operator", "start": 2439, "end": 2441}, + {"type": "operator", "start": 2444, "end": 2445}, + {"type": "punctuation", "start": 2447, "end": 2448}, + {"type": "comment", "start": 2450, "end": 2472}, + {"type": "special_keyword", "start": 2473, "end": 2479}, + {"type": "keyword", "start": 2480, "end": 2485}, {"type": "operator", "start": 2504, "end": 2505}, - {"type": "template_string", "start": 2506, "end": 2523}, - {"type": "template_punctuation", "start": 2506, "end": 2507}, - {"type": "string", "start": 2507, "end": 2514}, - {"type": "interpolation", "start": 2514, "end": 2522}, - {"type": "interpolation_punctuation", "start": 2514, "end": 2516}, - {"type": "number", "start": 2516, "end": 2517}, - {"type": "operator", "start": 2518, "end": 2519}, - {"type": "number", "start": 2520, "end": 2521}, - {"type": "interpolation_punctuation", "start": 2521, "end": 2522}, - {"type": "template_punctuation", "start": 2522, "end": 2523}, - {"type": "punctuation", "start": 2523, "end": 2524}, - {"type": "comment", "start": 2526, "end": 2558}, - {"type": "special_keyword", "start": 2559, "end": 2565}, - {"type": "keyword", "start": 2566, "end": 2571}, - {"type": "operator", "start": 2578, "end": 2579}, - {"type": "regex", "start": 2580, "end": 2589}, - {"type": "regex_delimiter", "start": 2580, "end": 2581}, - {"type": "regex_source", "start": 2581, "end": 2587}, - {"type": "regex_delimiter", "start": 2587, "end": 2588}, - {"type": "regex_flags", "start": 2588, "end": 2589}, - {"type": "punctuation", "start": 2589, "end": 2590}, - {"type": "special_keyword", "start": 2591, "end": 2597}, - {"type": "keyword", "start": 2598, "end": 2603}, - {"type": "operator", "start": 2618, "end": 2619}, - {"type": "regex", "start": 2620, "end": 2652}, - {"type": "regex_delimiter", "start": 2620, "end": 2621}, - {"type": "regex_source", "start": 2621, "end": 2651}, - {"type": "regex_delimiter", "start": 2651, "end": 2652}, - {"type": "punctuation", "start": 2652, "end": 2653}, - {"type": "comment", "start": 2655, "end": 2711}, - {"type": "comment", "start": 2712, "end": 2763} + {"type": "string", "start": 2506, "end": 2535}, + {"type": "punctuation", "start": 2535, "end": 2536}, + {"type": "special_keyword", "start": 2537, "end": 2543}, + {"type": "keyword", "start": 2544, "end": 2549}, + {"type": "operator", "start": 2567, "end": 2568}, + {"type": "string", "start": 2569, "end": 2595}, + {"type": "punctuation", "start": 2595, "end": 2596}, + {"type": "special_keyword", "start": 2597, "end": 2603}, + {"type": "keyword", "start": 2604, "end": 2609}, + {"type": "operator", "start": 2629, "end": 2630}, + {"type": "template_string", "start": 2631, "end": 2648}, + {"type": "template_punctuation", "start": 2631, "end": 2632}, + {"type": "string", "start": 2632, "end": 2639}, + {"type": "interpolation", "start": 2639, "end": 2647}, + {"type": "interpolation_punctuation", "start": 2639, "end": 2641}, + {"type": "number", "start": 2641, "end": 2642}, + {"type": "operator", "start": 2643, "end": 2644}, + {"type": "number", "start": 2645, "end": 2646}, + {"type": "interpolation_punctuation", "start": 2646, "end": 2647}, + {"type": "template_punctuation", "start": 2647, "end": 2648}, + {"type": "punctuation", "start": 2648, "end": 2649}, + {"type": "comment", "start": 2651, "end": 2683}, + {"type": "special_keyword", "start": 2684, "end": 2690}, + {"type": "keyword", "start": 2691, "end": 2696}, + {"type": "operator", "start": 2703, "end": 2704}, + {"type": "regex", "start": 2705, "end": 2714}, + {"type": "regex_delimiter", "start": 2705, "end": 2706}, + {"type": "regex_source", "start": 2706, "end": 2712}, + {"type": "regex_delimiter", "start": 2712, "end": 2713}, + {"type": "regex_flags", "start": 2713, "end": 2714}, + {"type": "punctuation", "start": 2714, "end": 2715}, + {"type": "special_keyword", "start": 2716, "end": 2722}, + {"type": "keyword", "start": 2723, "end": 2728}, + {"type": "operator", "start": 2743, "end": 2744}, + {"type": "regex", "start": 2745, "end": 2777}, + {"type": "regex_delimiter", "start": 2745, "end": 2746}, + {"type": "regex_source", "start": 2746, "end": 2776}, + {"type": "regex_delimiter", "start": 2776, "end": 2777}, + {"type": "punctuation", "start": 2777, "end": 2778}, + {"type": "comment", "start": 2780, "end": 2836}, + {"type": "comment", "start": 2837, "end": 2888} ], - "html": "const a = 1;\n\nconst b = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n}\n\nexport const some_e: Some_E = {name: 'A. H.', age: 100};\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b: string = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E<T = undefined> {\n\tname: string;\n\tage: number;\n\tt?: T;\n}\n\nconst e: {name: string; age: number} = {name: 'A. H.', age: 100};\nconst v = [['', e]] as const;\nexport const some_e: Map<string, Some_E> = new Map(v);\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/fixtures/generated/ts/ts_complex.txt index 02fa07d1..e39a2eed 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/fixtures/generated/ts/ts_complex.txt @@ -4,578 +4,643 @@ 10-11 number 1 11-12 punctuation ; 14-19 keyword const - 22-23 operator = - 24-27 string 'b' - 27-28 punctuation ; - 30-35 keyword const - 38-39 operator = - 40-44 boolean true - 44-45 punctuation ; - 47-53 special_keyword export - 54-58 keyword type - 59-68 class_name Some_Type - 69-70 operator = - 71-72 number 1 - 73-74 operator | - 75-78 string 'b' - 79-80 operator | - 81-85 boolean true - 85-86 punctuation ; - 88-95 keyword declare - 96-101 keyword const - 117-118 operator : - 119-122 builtin any - 122-123 punctuation , - 142-143 operator : - 144-147 builtin any - 147-148 punctuation , - 165-166 operator : - 167-170 builtin any - 170-171 punctuation ; - 173-181 keyword abstract - 182-187 keyword class - 188-192 class_name Base - 193-194 punctuation { - 196-204 keyword abstract - 205-220 function abstract_method - 220-221 punctuation ( - 221-222 punctuation ) - 222-223 operator : - 224-228 keyword void - 228-229 punctuation ; - 230-231 punctuation } - 233-249 decorator @class_decorator - 233-234 at @ - 234-249 function class_decorator - 250-255 keyword class - 256-257 class_name D - 256-257 constant D - 258-265 keyword extends - 266-270 class_name Base - 271-272 punctuation { - 274-282 keyword readonly - 285-286 operator : - 287-293 builtin string - 294-295 operator = - 296-299 string 'd' - 299-300 punctuation ; - 304-305 operator : - 306-312 builtin number - 312-313 punctuation ; - 318-319 operator = - 320-326 function $state - 326-327 punctuation ( - 327-331 keyword null - 331-332 punctuation ) - 332-333 punctuation ; - 336-355 decorator @property_decorator - 336-337 at @ - 337-355 function property_decorator - 367-368 operator = - 369-373 boolean true - 373-374 punctuation ; - 377-388 function constructor - 388-389 punctuation ( - 391-392 operator : - 393-399 builtin number - 399-400 punctuation ) - 401-402 punctuation { - 405-410 keyword super - 410-411 punctuation ( - 411-412 punctuation ) - 412-413 punctuation ; - 416-420 keyword this - 420-421 punctuation . - 424-425 operator = - 428-429 punctuation ; - 431-432 punctuation } - 435-450 function abstract_method - 450-451 punctuation ( - 451-452 punctuation ) - 452-453 operator : - 454-458 keyword void - 459-460 punctuation { - 463-480 comment // implementation - 482-483 punctuation } - 486-503 decorator @method_decorator - 486-487 at @ - 487-503 function method_decorator - 503-504 punctuation ( - 504-513 string 'example' - 513-514 punctuation , - 515-516 punctuation { - 522-523 operator : - 524-528 boolean true - 528-529 punctuation } - 529-530 punctuation ) - 532-544 function class_method - 544-545 punctuation ( - 545-546 punctuation ) - 546-547 operator : - 548-554 builtin string - 555-556 punctuation { - 559-565 special_keyword return - 566-585 template_string `Hello, ${this.d1}` - 566-567 template_punctuation ` - 567-574 string Hello, - 574-584 interpolation ${this.d1} - 574-576 interpolation_punctuation ${ - 576-580 keyword this - 580-581 punctuation . - 583-584 interpolation_punctuation } - 584-585 template_punctuation ` - 585-586 punctuation ; - 588-589 punctuation } - 592-607 function_variable instance_method - 608-609 operator = - 610-611 punctuation ( - 611-612 punctuation ) - 612-613 operator : - 614-618 keyword void - 619-621 operator => - 622-623 punctuation { - 626-635 comment /* ... */ - 638-641 keyword let - 644-645 operator = - 646-647 number 0 - 647-648 punctuation ; - 651-653 special_keyword do - 654-655 punctuation { - 660-662 operator ++ - 662-663 punctuation ; - 666-667 punctuation } - 668-673 special_keyword while - 674-675 punctuation ( - 677-678 operator < - 679-680 number 3 - 680-681 punctuation ) - 681-682 punctuation ; - 686-689 special_keyword for - 690-691 punctuation ( - 691-696 keyword const - 700-702 keyword of - 703-707 keyword this - 707-708 punctuation . - 710-711 punctuation ) - 712-713 punctuation { - 717-719 special_keyword if - 720-721 punctuation ( - 724-727 operator === - 728-731 string 'd' - 731-732 punctuation ) - 733-741 special_keyword continue - 741-742 punctuation ; - 746-748 special_keyword if - 749-750 punctuation ( - 750-751 operator ! - 753-754 punctuation ) - 755-760 special_keyword break - 760-761 punctuation ; - 765-769 keyword this - 769-770 punctuation . - 770-785 function #private_method - 785-786 punctuation ( - 787-788 punctuation , - 791-792 punctuation ) - 792-793 punctuation ; - 796-797 punctuation } - 801-807 special_keyword switch - 808-809 punctuation ( - 809-813 keyword this - 813-814 punctuation . - 816-817 punctuation ) - 818-819 punctuation { - 823-827 special_keyword case - 828-831 string 'a' - 831-832 operator : - 837-844 builtin console - 844-845 punctuation . - 845-848 function log - 848-849 punctuation ( - 849-857 string 'case a' - 857-858 punctuation ) - 858-859 punctuation ; - 864-869 special_keyword break - 869-870 punctuation ; - 874-878 special_keyword case - 879-882 string 'b' - 882-883 operator : - 887-891 special_keyword case - 892-895 string 'c' - 895-896 operator : - 901-908 builtin console - 908-909 punctuation . - 909-912 function log - 912-913 punctuation ( - 913-926 string 'case b or c' - 926-927 punctuation ) - 927-928 punctuation ; - 933-938 special_keyword break - 938-939 punctuation ; - 943-950 special_keyword default - 950-951 operator : - 956-963 builtin console - 963-964 punctuation . - 964-967 function log - 967-968 punctuation ( - 968-977 string 'default' - 977-978 punctuation ) - 978-979 punctuation ; - 982-983 punctuation } - 987-992 keyword const - 996-997 operator : - 998-999 punctuation { -1005-1006 operator ? -1006-1007 operator : -1008-1015 builtin boolean -1015-1016 punctuation ; -1021-1022 operator : -1023-1030 builtin boolean -1030-1031 punctuation } -1032-1033 operator = -1034-1035 punctuation { -1045-1046 operator : -1047-1051 string 'd1' -1052-1054 keyword in -1055-1059 keyword this -1059-1060 punctuation , -1068-1069 operator : -1070-1074 keyword this -1075-1085 keyword instanceof -1086-1087 class_name D -1086-1087 constant D -1087-1088 punctuation , -1091-1092 punctuation } -1092-1093 punctuation ; -1096-1102 keyword delete -1106-1107 punctuation . -1113-1114 punctuation ; -1117-1123 comment // foo -1125-1126 punctuation } -1126-1127 punctuation ; -1130-1145 function #private_method -1145-1146 punctuation ( -1148-1149 operator : -1150-1156 builtin number -1156-1157 punctuation , -1160-1161 operator : -1162-1165 builtin any -1165-1166 punctuation ) -1167-1168 punctuation { -1171-1176 special_keyword throw -1177-1180 keyword new -1181-1186 class_name Error -1186-1187 punctuation ( -1187-1233 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` -1187-1188 template_punctuation ` -1188-1198 interpolation ${this.d1} -1188-1190 interpolation_punctuation ${ -1190-1194 keyword this -1194-1195 punctuation . -1197-1198 interpolation_punctuation } -1198-1219 string \n\t\t\tmultiline\n\t\t\tetc -1219-1229 interpolation ${a2 + c2} -1219-1221 interpolation_punctuation ${ -1224-1225 operator + -1228-1229 interpolation_punctuation } -1229-1232 string \n\t\t -1232-1233 template_punctuation ` -1233-1234 punctuation ) -1234-1235 punctuation ; -1237-1238 punctuation } -1241-1242 operator * -1242-1251 function generator -1251-1252 punctuation ( -1252-1253 punctuation ) -1254-1255 punctuation { -1258-1263 special_keyword yield -1264-1265 number 1 -1265-1266 punctuation ; -1269-1274 special_keyword yield -1274-1275 operator * -1276-1277 punctuation [ -1277-1278 number 2 -1278-1279 punctuation , -1280-1281 number 3 -1281-1282 punctuation ] -1282-1283 punctuation ; -1285-1286 punctuation } -1295-1296 operator * -1296-1311 function async_generator -1311-1312 punctuation ( -1312-1313 punctuation ) -1314-1315 punctuation { -1318-1323 special_keyword yield -1324-1329 special_keyword await -1330-1337 builtin Promise -1337-1338 punctuation . -1338-1345 function resolve -1345-1346 punctuation ( -1346-1347 number 4 -1347-1348 punctuation ) -1348-1349 punctuation ; -1351-1352 punctuation } -1355-1364 keyword protected -1365-1370 keyword async -1371-1387 function protected_method -1387-1388 punctuation ( -1388-1389 punctuation ) -1389-1390 operator : -1391-1398 builtin Promise -1398-1399 operator < -1399-1403 keyword void -1403-1404 operator > -1405-1406 punctuation { -1409-1412 special_keyword try + 21-30 type_annotation : string + 21-22 : : + 22-30 type string + 23-29 builtin string + 30-31 operator = + 32-35 string 'b' + 35-36 punctuation ; + 38-43 keyword const + 46-47 operator = + 48-52 boolean true + 52-53 punctuation ; + 55-61 special_keyword export + 62-66 keyword type + 67-76 class_name Some_Type + 67-76 type_name Some_Type + 77-78 operator = + 79-80 number 1 + 81-82 operator | + 83-86 string 'b' + 87-88 operator | + 89-93 boolean true + 93-94 punctuation ; + 96-103 keyword declare + 104-109 keyword const + 125-126 operator : + 127-130 builtin any + 130-131 punctuation , + 150-151 operator : + 152-155 builtin any + 155-156 punctuation , + 173-174 operator : + 175-178 builtin any + 178-179 punctuation ; + 181-189 keyword abstract + 190-195 keyword class + 196-200 class_name Base + 196-200 type_name Base + 201-202 punctuation { + 204-212 keyword abstract + 213-228 function abstract_method + 228-229 punctuation ( + 229-230 punctuation ) + 230-231 operator : + 232-236 keyword void + 236-237 punctuation ; + 238-239 punctuation } + 241-257 decorator @class_decorator + 241-242 at @ + 242-257 function class_decorator + 258-263 keyword class + 264-265 class_name D + 264-265 constant D + 266-273 keyword extends + 274-278 class_name Base + 274-278 type_name Base + 279-280 punctuation { + 282-290 keyword readonly + 293-302 type_annotation : string + 293-294 : : + 294-302 type string + 295-301 builtin string + 302-303 operator = + 304-307 string 'd' + 307-308 punctuation ; + 312-313 operator : + 314-320 builtin number + 320-321 punctuation ; + 326-327 operator = + 328-334 function $state + 334-335 punctuation ( + 335-339 keyword null + 339-340 punctuation ) + 340-341 punctuation ; + 344-363 decorator @property_decorator + 344-345 at @ + 345-363 function property_decorator + 375-376 operator = + 377-381 boolean true + 381-382 punctuation ; + 385-396 function constructor + 396-397 punctuation ( + 399-400 operator : + 401-407 builtin number + 407-408 punctuation ) + 409-410 punctuation { + 413-418 keyword super + 418-419 punctuation ( + 419-420 punctuation ) + 420-421 punctuation ; + 424-428 keyword this + 428-429 punctuation . + 432-433 operator = + 436-437 punctuation ; + 439-440 punctuation } + 443-458 function abstract_method + 458-459 punctuation ( + 459-460 punctuation ) + 460-461 operator : + 462-466 keyword void + 467-468 punctuation { + 471-488 comment // implementation + 490-491 punctuation } + 494-511 decorator @method_decorator + 494-495 at @ + 495-511 function method_decorator + 511-512 punctuation ( + 512-521 string 'example' + 521-522 punctuation , + 523-524 punctuation { + 530-531 operator : + 532-536 boolean true + 536-537 punctuation } + 537-538 punctuation ) + 540-552 function class_method + 552-553 punctuation ( + 553-554 punctuation ) + 554-555 operator : + 556-562 builtin string + 563-564 punctuation { + 567-573 special_keyword return + 574-593 template_string `Hello, ${this.d1}` + 574-575 template_punctuation ` + 575-582 string Hello, + 582-592 interpolation ${this.d1} + 582-584 interpolation_punctuation ${ + 584-588 keyword this + 588-589 punctuation . + 591-592 interpolation_punctuation } + 592-593 template_punctuation ` + 593-594 punctuation ; + 596-597 punctuation } + 600-615 function_variable instance_method + 616-617 operator = + 618-619 punctuation ( + 619-620 punctuation ) + 620-627 type_annotation : void + 620-621 : : + 621-627 type void + 622-626 keyword void + 627-629 operator => + 630-631 punctuation { + 634-643 comment /* ... */ + 646-649 keyword let + 652-653 operator = + 654-655 number 0 + 655-656 punctuation ; + 659-661 special_keyword do + 662-663 punctuation { + 668-670 operator ++ + 670-671 punctuation ; + 674-675 punctuation } + 676-681 special_keyword while + 682-683 punctuation ( + 685-686 operator < + 687-688 number 3 + 688-689 punctuation ) + 689-690 punctuation ; + 694-697 special_keyword for + 698-699 punctuation ( + 699-704 keyword const + 708-710 keyword of + 711-715 keyword this + 715-716 punctuation . + 718-719 punctuation ) + 720-721 punctuation { + 725-727 special_keyword if + 728-729 punctuation ( + 732-735 operator === + 736-739 string 'd' + 739-740 punctuation ) + 741-749 special_keyword continue + 749-750 punctuation ; + 754-756 special_keyword if + 757-758 punctuation ( + 758-759 operator ! + 761-762 punctuation ) + 763-768 special_keyword break + 768-769 punctuation ; + 773-777 keyword this + 777-778 punctuation . + 778-793 function #private_method + 793-794 punctuation ( + 795-796 punctuation , + 799-800 punctuation ) + 800-801 punctuation ; + 804-805 punctuation } + 809-815 special_keyword switch + 816-817 punctuation ( + 817-821 keyword this + 821-822 punctuation . + 824-825 punctuation ) + 826-827 punctuation { + 831-835 special_keyword case + 836-839 string 'a' + 839-840 operator : + 845-852 builtin console + 852-853 punctuation . + 853-856 function log + 856-857 punctuation ( + 857-865 string 'case a' + 865-866 punctuation ) + 866-867 punctuation ; + 872-877 special_keyword break + 877-878 punctuation ; + 882-886 special_keyword case + 887-890 string 'b' + 890-891 operator : + 895-899 special_keyword case + 900-903 string 'c' + 903-904 operator : + 909-916 builtin console + 916-917 punctuation . + 917-920 function log + 920-921 punctuation ( + 921-934 string 'case b or c' + 934-935 punctuation ) + 935-936 punctuation ; + 941-946 special_keyword break + 946-947 punctuation ; + 951-958 special_keyword default + 958-959 operator : + 964-971 builtin console + 971-972 punctuation . + 972-975 function log + 975-976 punctuation ( + 976-985 string 'default' + 985-986 punctuation ) + 986-987 punctuation ; + 990-991 punctuation } + 995-1000 keyword const +1004-1005 operator : +1006-1007 punctuation { +1013-1014 operator ? +1014-1015 operator : +1016-1023 builtin boolean +1023-1024 punctuation ; +1029-1030 operator : +1031-1038 builtin boolean +1038-1039 punctuation } +1040-1041 operator = +1042-1043 punctuation { +1053-1054 operator : +1055-1059 string 'd1' +1060-1062 keyword in +1063-1067 keyword this +1067-1068 punctuation , +1076-1077 operator : +1078-1082 keyword this +1083-1093 keyword instanceof +1094-1095 class_name D +1094-1095 constant D +1095-1096 punctuation , +1099-1100 punctuation } +1100-1101 punctuation ; +1104-1110 keyword delete +1114-1115 punctuation . +1121-1122 punctuation ; +1125-1131 comment // foo +1133-1134 punctuation } +1134-1135 punctuation ; +1138-1153 function #private_method +1153-1154 punctuation ( +1156-1157 operator : +1158-1164 builtin number +1164-1165 punctuation , +1168-1169 operator : +1170-1173 builtin any +1173-1174 punctuation ) +1175-1176 punctuation { +1179-1184 special_keyword throw +1185-1188 keyword new +1189-1194 class_name Error +1189-1194 type_name Error +1194-1195 punctuation ( +1195-1241 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` +1195-1196 template_punctuation ` +1196-1206 interpolation ${this.d1} +1196-1198 interpolation_punctuation ${ +1198-1202 keyword this +1202-1203 punctuation . +1205-1206 interpolation_punctuation } +1206-1227 string \n\t\t\tmultiline\n\t\t\tetc +1227-1237 interpolation ${a2 + c2} +1227-1229 interpolation_punctuation ${ +1232-1233 operator + +1236-1237 interpolation_punctuation } +1237-1240 string \n\t\t +1240-1241 template_punctuation ` +1241-1242 punctuation ) +1242-1243 punctuation ; +1245-1246 punctuation } +1249-1250 operator * +1250-1259 function generator +1259-1260 punctuation ( +1260-1261 punctuation ) +1262-1263 punctuation { +1266-1271 special_keyword yield +1272-1273 number 1 +1273-1274 punctuation ; +1277-1282 special_keyword yield +1282-1283 operator * +1284-1285 punctuation [ +1285-1286 number 2 +1286-1287 punctuation , +1288-1289 number 3 +1289-1290 punctuation ] +1290-1291 punctuation ; +1293-1294 punctuation } +1303-1304 operator * +1304-1319 function async_generator +1319-1320 punctuation ( +1320-1321 punctuation ) +1322-1323 punctuation { +1326-1331 special_keyword yield +1332-1337 special_keyword await +1338-1345 builtin Promise +1345-1346 punctuation . +1346-1353 function resolve +1353-1354 punctuation ( +1354-1355 number 4 +1355-1356 punctuation ) +1356-1357 punctuation ; +1359-1360 punctuation } +1363-1372 keyword protected +1373-1378 keyword async +1379-1395 function protected_method +1395-1396 punctuation ( +1396-1397 punctuation ) +1397-1398 operator : +1399-1406 builtin Promise +1406-1407 operator < +1407-1411 keyword void +1411-1412 operator > 1413-1414 punctuation { -1418-1423 special_keyword await -1424-1427 keyword new -1428-1435 class_name Promise -1428-1435 builtin Promise -1435-1436 punctuation ( -1436-1437 punctuation ( -1444-1445 punctuation ) -1446-1448 operator => -1449-1459 function setTimeout -1459-1460 punctuation ( -1467-1468 punctuation , -1469-1472 number 100 -1472-1473 punctuation ) -1473-1474 punctuation ) -1474-1475 punctuation ; -1479-1481 special_keyword if -1482-1483 punctuation ( -1487-1488 punctuation . -1488-1494 function random -1494-1495 punctuation ( -1495-1496 punctuation ) -1497-1498 operator > -1499-1502 number 0.5 -1502-1503 punctuation ) -1504-1505 punctuation { -1510-1517 builtin console -1517-1518 punctuation . -1518-1521 function log -1521-1522 punctuation ( -1522-1525 keyword new -1526-1530 class_name Date -1530-1531 punctuation ( -1531-1532 punctuation ) -1532-1533 punctuation ) -1533-1534 punctuation ; -1535-1568 comment // eslint-disable-line no-console -1572-1573 punctuation } -1574-1578 special_keyword else -1579-1581 special_keyword if -1582-1583 punctuation ( -1587-1588 punctuation . -1588-1594 function random -1594-1595 punctuation ( -1595-1596 punctuation ) -1597-1598 operator > -1599-1602 number 0.2 -1602-1603 punctuation ) -1604-1605 punctuation { -1610-1617 builtin console -1617-1618 punctuation . -1618-1621 function log -1621-1622 punctuation ( -1622-1638 string 'else if branch' -1638-1639 punctuation ) -1639-1640 punctuation ; -1644-1645 punctuation } -1646-1650 special_keyword else -1651-1652 punctuation { -1657-1664 builtin console -1664-1665 punctuation . -1665-1668 function log -1668-1669 punctuation ( -1669-1682 string 'else branch' -1682-1683 punctuation ) -1683-1684 punctuation ; -1688-1689 punctuation } -1692-1693 punctuation } -1694-1699 special_keyword catch -1700-1701 punctuation ( -1706-1707 operator : -1708-1715 builtin unknown -1715-1716 punctuation ) -1717-1718 punctuation { -1722-1729 builtin console -1729-1730 punctuation . -1730-1735 function error -1735-1736 punctuation ( -1741-1742 punctuation ) -1742-1743 punctuation ; -1746-1747 punctuation } -1748-1755 special_keyword finally -1756-1757 punctuation { -1761-1768 builtin console -1768-1769 punctuation . -1769-1772 function log -1772-1773 punctuation ( -1773-1788 string 'finally block' -1788-1789 punctuation ) -1789-1790 punctuation ; -1793-1794 punctuation } -1796-1797 punctuation } -1798-1799 punctuation } -1801-1811 comment // comment -1813-1856 comment /*\nother comment\n\nconst comment = false;\n*/ -1858-1882 comment /**\n * JSDoc comment\n */ -1884-1890 special_keyword import -1891-1892 punctuation { -1904-1905 punctuation , -1906-1910 keyword type -1911-1922 class_name Sample_Lang -1922-1923 punctuation } -1924-1928 special_keyword from -1929-1948 string '../code_sample.js' -1948-1949 punctuation ; -1950-1956 special_keyword import -1957-1958 operator * -1959-1961 special_keyword as -1962-1963 constant A -1964-1968 special_keyword from -1969-1988 string '../code_sample.js' -1988-1989 punctuation ; -1991-1997 special_keyword export -1998-1999 punctuation { -2000-2001 punctuation , -2002-2003 constant A -2003-2004 punctuation , -2006-2007 punctuation , -2009-2010 punctuation , -2011-2012 constant D -2012-2013 punctuation } -2013-2014 punctuation ; -2029-2031 special_keyword as -2032-2039 builtin unknown -2040-2042 special_keyword as -2043-2046 builtin any -2047-2049 special_keyword as -2062-2071 keyword satisfies -2083-2084 punctuation ; -2086-2092 special_keyword export -2093-2102 keyword interface -2103-2109 class_name Some_E -2110-2111 punctuation { -2117-2118 operator : -2119-2125 builtin string -2125-2126 punctuation ; -2131-2132 operator : -2133-2139 builtin number -2139-2140 punctuation ; -2141-2142 punctuation } -2144-2150 special_keyword export -2151-2156 keyword const -2163-2164 operator : -2172-2173 operator = -2174-2175 punctuation { -2179-2180 operator : -2181-2188 string 'A. H.' -2188-2189 punctuation , -2193-2194 operator : -2195-2198 number 100 -2198-2199 punctuation } -2199-2200 punctuation ; -2202-2208 special_keyword export -2209-2217 keyword function -2218-2221 function add -2221-2222 punctuation ( -2223-2224 operator : -2225-2231 builtin number -2231-2232 punctuation , -2234-2235 operator : -2236-2242 builtin number -2242-2243 punctuation ) -2243-2244 operator : -2245-2251 builtin number -2252-2253 punctuation { -2255-2261 special_keyword return -2264-2265 operator + -2267-2268 punctuation ; -2269-2270 punctuation } -2272-2278 special_keyword export -2279-2284 keyword const -2285-2289 function_variable plus -2290-2291 operator = -2292-2293 punctuation ( -2294-2295 operator : -2296-2299 builtin any -2299-2300 punctuation , -2302-2303 operator : -2304-2307 builtin any -2307-2308 punctuation ) -2308-2309 operator : -2310-2313 builtin any -2314-2316 operator => -2319-2320 operator + -2322-2323 punctuation ; -2325-2347 comment // boundary test cases -2348-2354 special_keyword export -2355-2360 keyword const -2379-2380 operator = -2381-2410 string 'const class function string' -2410-2411 punctuation ; -2412-2418 special_keyword export -2419-2424 keyword const -2442-2443 operator = -2444-2470 string '// this is not a comment' -2470-2471 punctuation ; -2472-2478 special_keyword export -2479-2484 keyword const +1417-1420 special_keyword try +1421-1422 punctuation { +1426-1431 special_keyword await +1432-1435 keyword new +1436-1443 class_name Promise +1436-1443 builtin Promise +1443-1444 punctuation ( +1444-1445 punctuation ( +1452-1453 punctuation ) +1454-1456 operator => +1457-1467 function setTimeout +1467-1468 punctuation ( +1475-1476 punctuation , +1477-1480 number 100 +1480-1481 punctuation ) +1481-1482 punctuation ) +1482-1483 punctuation ; +1487-1489 special_keyword if +1490-1491 punctuation ( +1495-1496 punctuation . +1496-1502 function random +1502-1503 punctuation ( +1503-1504 punctuation ) +1505-1506 operator > +1507-1510 number 0.5 +1510-1511 punctuation ) +1512-1513 punctuation { +1518-1525 builtin console +1525-1526 punctuation . +1526-1529 function log +1529-1530 punctuation ( +1530-1533 keyword new +1534-1538 class_name Date +1534-1538 type_name Date +1538-1539 punctuation ( +1539-1540 punctuation ) +1540-1541 punctuation ) +1541-1542 punctuation ; +1543-1576 comment // eslint-disable-line no-console +1580-1581 punctuation } +1582-1586 special_keyword else +1587-1589 special_keyword if +1590-1591 punctuation ( +1595-1596 punctuation . +1596-1602 function random +1602-1603 punctuation ( +1603-1604 punctuation ) +1605-1606 operator > +1607-1610 number 0.2 +1610-1611 punctuation ) +1612-1613 punctuation { +1618-1625 builtin console +1625-1626 punctuation . +1626-1629 function log +1629-1630 punctuation ( +1630-1646 string 'else if branch' +1646-1647 punctuation ) +1647-1648 punctuation ; +1652-1653 punctuation } +1654-1658 special_keyword else +1659-1660 punctuation { +1665-1672 builtin console +1672-1673 punctuation . +1673-1676 function log +1676-1677 punctuation ( +1677-1690 string 'else branch' +1690-1691 punctuation ) +1691-1692 punctuation ; +1696-1697 punctuation } +1700-1701 punctuation } +1702-1707 special_keyword catch +1708-1709 punctuation ( +1714-1715 operator : +1716-1723 builtin unknown +1723-1724 punctuation ) +1725-1726 punctuation { +1730-1737 builtin console +1737-1738 punctuation . +1738-1743 function error +1743-1744 punctuation ( +1749-1750 punctuation ) +1750-1751 punctuation ; +1754-1755 punctuation } +1756-1763 special_keyword finally +1764-1765 punctuation { +1769-1776 builtin console +1776-1777 punctuation . +1777-1780 function log +1780-1781 punctuation ( +1781-1796 string 'finally block' +1796-1797 punctuation ) +1797-1798 punctuation ; +1801-1802 punctuation } +1804-1805 punctuation } +1806-1807 punctuation } +1809-1819 comment // comment +1821-1864 comment /*\nother comment\n\nconst comment = false;\n*/ +1866-1890 comment /**\n * JSDoc comment\n */ +1892-1898 special_keyword import +1899-1900 punctuation { +1912-1913 punctuation , +1914-1918 keyword type +1919-1930 class_name Sample_Lang +1919-1930 type_name Sample_Lang +1930-1931 punctuation } +1932-1936 special_keyword from +1937-1956 string '../code_sample.js' +1956-1957 punctuation ; +1958-1964 special_keyword import +1965-1966 operator * +1967-1969 special_keyword as +1970-1971 constant A +1972-1976 special_keyword from +1977-1996 string '../code_sample.js' +1996-1997 punctuation ; +1999-2005 special_keyword export +2006-2007 punctuation { +2008-2009 punctuation , +2010-2011 constant A +2011-2012 punctuation , +2014-2015 punctuation , +2017-2018 punctuation , +2019-2020 constant D +2020-2021 punctuation } +2021-2022 punctuation ; +2037-2039 special_keyword as +2040-2047 builtin unknown +2048-2050 special_keyword as +2051-2054 builtin any +2055-2057 special_keyword as +2070-2079 keyword satisfies +2091-2092 punctuation ; +2094-2100 special_keyword export +2101-2110 keyword interface +2111-2132 class_name Some_E +2111-2117 type_name Some_E +2117-2118 operator < +2118-2119 constant T +2120-2121 operator = +2122-2131 keyword undefined +2131-2132 operator > +2133-2134 punctuation { +2140-2141 operator : +2142-2148 builtin string +2148-2149 punctuation ; +2154-2155 operator : +2156-2162 builtin number +2162-2163 punctuation ; +2166-2167 operator ? +2167-2168 operator : +2169-2170 constant T +2170-2171 punctuation ; +2172-2173 punctuation } +2175-2180 keyword const +2182-2183 operator : +2184-2185 punctuation { +2189-2190 operator : +2191-2197 builtin string +2197-2198 punctuation ; +2202-2203 operator : +2204-2210 builtin number +2210-2211 punctuation } +2212-2213 operator = +2214-2215 punctuation { +2219-2220 operator : +2221-2228 string 'A. H.' +2228-2229 punctuation , +2233-2234 operator : +2235-2238 number 100 +2238-2239 punctuation } +2239-2240 punctuation ; +2241-2246 keyword const +2249-2250 operator = +2251-2252 punctuation [ +2252-2253 punctuation [ +2253-2255 string '' +2255-2256 punctuation , +2258-2259 punctuation ] +2259-2260 punctuation ] +2261-2263 special_keyword as +2264-2269 keyword const +2269-2270 punctuation ; +2271-2277 special_keyword export +2278-2283 keyword const +2290-2312 type_annotation : Map +2290-2291 : : +2291-2312 type Map +2292-2295 type_name Map +2295-2296 operator < +2296-2302 builtin string +2302-2303 punctuation , +2304-2310 type_name Some_E +2310-2311 operator > +2312-2313 operator = +2314-2317 keyword new +2318-2321 class_name Map +2318-2321 type_name Map +2321-2322 punctuation ( +2323-2324 punctuation ) +2324-2325 punctuation ; +2327-2333 special_keyword export +2334-2342 keyword function +2343-2346 function add +2346-2347 punctuation ( +2348-2349 operator : +2350-2356 builtin number +2356-2357 punctuation , +2359-2360 operator : +2361-2367 builtin number +2367-2368 punctuation ) +2368-2369 operator : +2370-2376 builtin number +2377-2378 punctuation { +2380-2386 special_keyword return +2389-2390 operator + +2392-2393 punctuation ; +2394-2395 punctuation } +2397-2403 special_keyword export +2404-2409 keyword const +2410-2414 function_variable plus +2415-2416 operator = +2417-2418 punctuation ( +2419-2420 operator : +2421-2424 builtin any +2424-2425 punctuation , +2427-2428 operator : +2429-2432 builtin any +2432-2433 punctuation ) +2433-2439 type_annotation : any +2433-2434 : : +2434-2439 type any +2435-2438 builtin any +2439-2441 operator => +2444-2445 operator + +2447-2448 punctuation ; +2450-2472 comment // boundary test cases +2473-2479 special_keyword export +2480-2485 keyword const 2504-2505 operator = -2506-2523 template_string `Value: ${1 + 2}` -2506-2507 template_punctuation ` -2507-2514 string Value: -2514-2522 interpolation ${1 + 2} -2514-2516 interpolation_punctuation ${ -2516-2517 number 1 -2518-2519 operator + -2520-2521 number 2 -2521-2522 interpolation_punctuation } -2522-2523 template_punctuation ` -2523-2524 punctuation ; -2526-2558 comment // regex that looks like comment -2559-2565 special_keyword export -2566-2571 keyword const -2578-2579 operator = -2580-2589 regex /\/\/.*/g -2580-2581 regex_delimiter / -2581-2587 regex_source \/\/.* -2587-2588 regex_delimiter / -2588-2589 regex_flags g -2589-2590 punctuation ; -2591-2597 special_keyword export -2598-2603 keyword const -2618-2619 operator = -2620-2652 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ -2620-2621 regex_delimiter / -2621-2651 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ -2651-2652 regex_delimiter / -2652-2653 punctuation ; -2655-2711 comment // string in comment should not be highlighted as string -2712-2763 comment // const commented = "this string is in a comment"; +2506-2535 string 'const class function string' +2535-2536 punctuation ; +2537-2543 special_keyword export +2544-2549 keyword const +2567-2568 operator = +2569-2595 string '// this is not a comment' +2595-2596 punctuation ; +2597-2603 special_keyword export +2604-2609 keyword const +2629-2630 operator = +2631-2648 template_string `Value: ${1 + 2}` +2631-2632 template_punctuation ` +2632-2639 string Value: +2639-2647 interpolation ${1 + 2} +2639-2641 interpolation_punctuation ${ +2641-2642 number 1 +2643-2644 operator + +2645-2646 number 2 +2646-2647 interpolation_punctuation } +2647-2648 template_punctuation ` +2648-2649 punctuation ; +2651-2683 comment // regex that looks like comment +2684-2690 special_keyword export +2691-2696 keyword const +2703-2704 operator = +2705-2714 regex /\/\/.*/g +2705-2706 regex_delimiter / +2706-2712 regex_source \/\/.* +2712-2713 regex_delimiter / +2713-2714 regex_flags g +2714-2715 punctuation ; +2716-2722 special_keyword export +2723-2728 keyword const +2743-2744 operator = +2745-2777 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ +2745-2746 regex_delimiter / +2746-2776 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +2776-2777 regex_delimiter / +2777-2778 punctuation ; +2780-2836 comment // string in comment should not be highlighted as string +2837-2888 comment // const commented = "this string is in a comment"; === STATS === -Total tokens: 558 -Sample length: 2764 characters +Total tokens: 619 +Sample length: 2889 characters Token types: - punctuation: 221 - operator: 75 - keyword: 49 - special_keyword: 48 - builtin: 33 + punctuation: 235 + operator: 83 + keyword: 54 + special_keyword: 49 + builtin: 37 function: 26 - string: 24 + string: 25 number: 14 + class_name: 11 comment: 11 - class_name: 10 + type_name: 10 interpolation_punctuation: 8 + constant: 7 template_punctuation: 6 - constant: 5 + type_annotation: 5 + :: 5 + type: 5 boolean: 4 interpolation: 4 regex_delimiter: 4 diff --git a/src/lib/grammar_ts.ts b/src/lib/grammar_ts.ts index 05f8ef81..017b2d29 100644 --- a/src/lib/grammar_ts.ts +++ b/src/lib/grammar_ts.ts @@ -41,7 +41,14 @@ export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { delete grammar_ts.literal_property; // a version of TS specifically for styling types - var type_inside = syntax_styler.extend_grammar('ts', {}); + var type_inside = syntax_styler.extend_grammar('ts', { + // Recognize type names in type contexts + type_name: { + pattern: /\b[A-Z]\w*/, + alias: 'class_name', + }, + }); + // Prevent double-wrapping of class names (type_inside as any).class_name = undefined; (grammar_ts.class_name as Syntax_Grammar_Token).inside = type_inside; @@ -52,6 +59,17 @@ export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { lookbehind: true, alias: 'special_keyword', }, + type_annotation: { + pattern: /:(?:\s*)((?:[^<>=;,)}\s]|<[^>]*>|\[[^\]]*\]|\s)+)(?=\s*=)/, + greedy: true, + inside: { + ':': /^:/, + type: { + pattern: /.+/, + inside: type_inside, + }, + }, + }, decorator: { pattern: /@[$\w\xA0-\uFFFF]+/, inside: { diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 29552acd..250852fa 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -88,7 +88,7 @@ div > p { lang: 'ts', content: `const a = 1; -const b = 'b'; +const b: string = 'b'; const c = true; @@ -209,12 +209,15 @@ export {a, A, b, c, D}; sample_langs as unknown as any as Sample_Lang satisfies Sample_Lang; -export interface Some_E { +export interface Some_E { name: string; age: number; + t?: T; } -export const some_e: Some_E = {name: 'A. H.', age: 100}; +const e: {name: string; age: number} = {name: 'A. H.', age: 100}; +const v = [['', e]] as const; +export const some_e: Map = new Map(v); export function add(x: number, y: number): number { return x + y; diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index a8e3ee59..55f4ea4e 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -1,6 +1,6 @@ const a = 1; -const b = 'b'; +const b: string = 'b'; const c = true; @@ -121,12 +121,15 @@ export {a, A, b, c, D}; sample_langs as unknown as any as Sample_Lang satisfies Sample_Lang; -export interface Some_E { +export interface Some_E { name: string; age: number; + t?: T; } -export const some_e: Some_E = {name: 'A. H.', age: 100}; +const e: {name: string; age: number} = {name: 'A. H.', age: 100}; +const v = [['', e]] as const; +export const some_e: Map = new Map(v); export function add(x: number, y: number): number { return x + y; From 42c299c607ab5a701a504ba5379cb86299b1adb5 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 13:03:51 -0400 Subject: [PATCH 18/49] wip --- .../fixtures}/generated/css/css_complex.json | 0 .../fixtures}/generated/css/css_complex.txt | 0 .../generated/html/html_complex.json | 0 .../fixtures}/generated/html/html_complex.txt | 0 .../generated/json/json_complex.json | 0 .../fixtures}/generated/json/json_complex.txt | 0 .../generated/svelte/svelte_complex.json | 0 .../generated/svelte/svelte_complex.txt | 0 .../fixtures}/generated/ts/ts_complex.json | 288 +++++++++--------- .../fixtures}/generated/ts/ts_complex.txt | 286 ++++++++--------- src/fixtures/helpers.ts | 2 +- src/fixtures/update.task.ts | 8 +- src/lib/samples/all.ts | 2 +- src/lib/samples/sample_complex.ts | 2 +- 14 files changed, 295 insertions(+), 293 deletions(-) rename {fixtures => src/fixtures}/generated/css/css_complex.json (100%) rename {fixtures => src/fixtures}/generated/css/css_complex.txt (100%) rename {fixtures => src/fixtures}/generated/html/html_complex.json (100%) rename {fixtures => src/fixtures}/generated/html/html_complex.txt (100%) rename {fixtures => src/fixtures}/generated/json/json_complex.json (100%) rename {fixtures => src/fixtures}/generated/json/json_complex.txt (100%) rename {fixtures => src/fixtures}/generated/svelte/svelte_complex.json (100%) rename {fixtures => src/fixtures}/generated/svelte/svelte_complex.txt (100%) rename {fixtures => src/fixtures}/generated/ts/ts_complex.json (76%) rename {fixtures => src/fixtures}/generated/ts/ts_complex.txt (77%) diff --git a/fixtures/generated/css/css_complex.json b/src/fixtures/generated/css/css_complex.json similarity index 100% rename from fixtures/generated/css/css_complex.json rename to src/fixtures/generated/css/css_complex.json diff --git a/fixtures/generated/css/css_complex.txt b/src/fixtures/generated/css/css_complex.txt similarity index 100% rename from fixtures/generated/css/css_complex.txt rename to src/fixtures/generated/css/css_complex.txt diff --git a/fixtures/generated/html/html_complex.json b/src/fixtures/generated/html/html_complex.json similarity index 100% rename from fixtures/generated/html/html_complex.json rename to src/fixtures/generated/html/html_complex.json diff --git a/fixtures/generated/html/html_complex.txt b/src/fixtures/generated/html/html_complex.txt similarity index 100% rename from fixtures/generated/html/html_complex.txt rename to src/fixtures/generated/html/html_complex.txt diff --git a/fixtures/generated/json/json_complex.json b/src/fixtures/generated/json/json_complex.json similarity index 100% rename from fixtures/generated/json/json_complex.json rename to src/fixtures/generated/json/json_complex.json diff --git a/fixtures/generated/json/json_complex.txt b/src/fixtures/generated/json/json_complex.txt similarity index 100% rename from fixtures/generated/json/json_complex.txt rename to src/fixtures/generated/json/json_complex.txt diff --git a/fixtures/generated/svelte/svelte_complex.json b/src/fixtures/generated/svelte/svelte_complex.json similarity index 100% rename from fixtures/generated/svelte/svelte_complex.json rename to src/fixtures/generated/svelte/svelte_complex.json diff --git a/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt similarity index 100% rename from fixtures/generated/svelte/svelte_complex.txt rename to src/fixtures/generated/svelte/svelte_complex.txt diff --git a/fixtures/generated/ts/ts_complex.json b/src/fixtures/generated/ts/ts_complex.json similarity index 76% rename from fixtures/generated/ts/ts_complex.json rename to src/fixtures/generated/ts/ts_complex.json index 39fcf31a..79f2f155 100644 --- a/fixtures/generated/ts/ts_complex.json +++ b/src/fixtures/generated/ts/ts_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "ts", "variant": "complex", - "content": "const a = 1;\n\nconst b: string = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n\tt?: T;\n}\n\nconst e: {name: string; age: number} = {name: 'A. H.', age: 100};\nconst v = [['', e]] as const;\nexport const some_e: Map = new Map(v);\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", + "content": "const a = 1;\n\nconst b: string = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E {\n\tname: string;\n\tage: number;\n\tt?: T;\n}\n\nconst e: {name: string; age: number} = {name: 'A. H.', age: 100};\nconst v = [['', e]] as const;\nexport const some_e: Map = new Map(v);\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n", "filepath": "src/lib/samples/sample_complex.ts" }, "tokens": [ @@ -479,152 +479,152 @@ {"type": "punctuation", "start": 2091, "end": 2092}, {"type": "special_keyword", "start": 2094, "end": 2100}, {"type": "keyword", "start": 2101, "end": 2110}, - {"type": "class_name", "start": 2111, "end": 2132}, + {"type": "class_name", "start": 2111, "end": 2127}, {"type": "type_name", "start": 2111, "end": 2117}, {"type": "operator", "start": 2117, "end": 2118}, {"type": "constant", "start": 2118, "end": 2119}, {"type": "operator", "start": 2120, "end": 2121}, - {"type": "keyword", "start": 2122, "end": 2131}, - {"type": "operator", "start": 2131, "end": 2132}, - {"type": "punctuation", "start": 2133, "end": 2134}, - {"type": "operator", "start": 2140, "end": 2141}, - {"type": "builtin", "start": 2142, "end": 2148}, - {"type": "punctuation", "start": 2148, "end": 2149}, - {"type": "operator", "start": 2154, "end": 2155}, - {"type": "builtin", "start": 2156, "end": 2162}, - {"type": "punctuation", "start": 2162, "end": 2163}, - {"type": "operator", "start": 2166, "end": 2167}, - {"type": "operator", "start": 2167, "end": 2168}, - {"type": "constant", "start": 2169, "end": 2170}, - {"type": "punctuation", "start": 2170, "end": 2171}, - {"type": "punctuation", "start": 2172, "end": 2173}, - {"type": "keyword", "start": 2175, "end": 2180}, - {"type": "operator", "start": 2182, "end": 2183}, - {"type": "punctuation", "start": 2184, "end": 2185}, - {"type": "operator", "start": 2189, "end": 2190}, - {"type": "builtin", "start": 2191, "end": 2197}, - {"type": "punctuation", "start": 2197, "end": 2198}, - {"type": "operator", "start": 2202, "end": 2203}, - {"type": "builtin", "start": 2204, "end": 2210}, - {"type": "punctuation", "start": 2210, "end": 2211}, - {"type": "operator", "start": 2212, "end": 2213}, - {"type": "punctuation", "start": 2214, "end": 2215}, - {"type": "operator", "start": 2219, "end": 2220}, - {"type": "string", "start": 2221, "end": 2228}, - {"type": "punctuation", "start": 2228, "end": 2229}, - {"type": "operator", "start": 2233, "end": 2234}, - {"type": "number", "start": 2235, "end": 2238}, - {"type": "punctuation", "start": 2238, "end": 2239}, - {"type": "punctuation", "start": 2239, "end": 2240}, - {"type": "keyword", "start": 2241, "end": 2246}, - {"type": "operator", "start": 2249, "end": 2250}, - {"type": "punctuation", "start": 2251, "end": 2252}, - {"type": "punctuation", "start": 2252, "end": 2253}, - {"type": "string", "start": 2253, "end": 2255}, - {"type": "punctuation", "start": 2255, "end": 2256}, - {"type": "punctuation", "start": 2258, "end": 2259}, - {"type": "punctuation", "start": 2259, "end": 2260}, - {"type": "special_keyword", "start": 2261, "end": 2263}, - {"type": "keyword", "start": 2264, "end": 2269}, - {"type": "punctuation", "start": 2269, "end": 2270}, - {"type": "special_keyword", "start": 2271, "end": 2277}, - {"type": "keyword", "start": 2278, "end": 2283}, - {"type": "type_annotation", "start": 2290, "end": 2312}, - {"type": ":", "start": 2290, "end": 2291}, - {"type": "type", "start": 2291, "end": 2312}, - {"type": "type_name", "start": 2292, "end": 2295}, - {"type": "operator", "start": 2295, "end": 2296}, - {"type": "builtin", "start": 2296, "end": 2302}, - {"type": "punctuation", "start": 2302, "end": 2303}, - {"type": "type_name", "start": 2304, "end": 2310}, - {"type": "operator", "start": 2310, "end": 2311}, - {"type": "operator", "start": 2312, "end": 2313}, - {"type": "keyword", "start": 2314, "end": 2317}, - {"type": "class_name", "start": 2318, "end": 2321}, - {"type": "type_name", "start": 2318, "end": 2321}, - {"type": "punctuation", "start": 2321, "end": 2322}, - {"type": "punctuation", "start": 2323, "end": 2324}, - {"type": "punctuation", "start": 2324, "end": 2325}, - {"type": "special_keyword", "start": 2327, "end": 2333}, - {"type": "keyword", "start": 2334, "end": 2342}, - {"type": "function", "start": 2343, "end": 2346}, - {"type": "punctuation", "start": 2346, "end": 2347}, - {"type": "operator", "start": 2348, "end": 2349}, - {"type": "builtin", "start": 2350, "end": 2356}, - {"type": "punctuation", "start": 2356, "end": 2357}, - {"type": "operator", "start": 2359, "end": 2360}, - {"type": "builtin", "start": 2361, "end": 2367}, - {"type": "punctuation", "start": 2367, "end": 2368}, - {"type": "operator", "start": 2368, "end": 2369}, - {"type": "builtin", "start": 2370, "end": 2376}, - {"type": "punctuation", "start": 2377, "end": 2378}, - {"type": "special_keyword", "start": 2380, "end": 2386}, - {"type": "operator", "start": 2389, "end": 2390}, - {"type": "punctuation", "start": 2392, "end": 2393}, - {"type": "punctuation", "start": 2394, "end": 2395}, - {"type": "special_keyword", "start": 2397, "end": 2403}, - {"type": "keyword", "start": 2404, "end": 2409}, - {"type": "function_variable", "start": 2410, "end": 2414}, - {"type": "operator", "start": 2415, "end": 2416}, - {"type": "punctuation", "start": 2417, "end": 2418}, - {"type": "operator", "start": 2419, "end": 2420}, - {"type": "builtin", "start": 2421, "end": 2424}, - {"type": "punctuation", "start": 2424, "end": 2425}, - {"type": "operator", "start": 2427, "end": 2428}, - {"type": "builtin", "start": 2429, "end": 2432}, - {"type": "punctuation", "start": 2432, "end": 2433}, - {"type": "type_annotation", "start": 2433, "end": 2439}, - {"type": ":", "start": 2433, "end": 2434}, - {"type": "type", "start": 2434, "end": 2439}, - {"type": "builtin", "start": 2435, "end": 2438}, - {"type": "operator", "start": 2439, "end": 2441}, - {"type": "operator", "start": 2444, "end": 2445}, - {"type": "punctuation", "start": 2447, "end": 2448}, - {"type": "comment", "start": 2450, "end": 2472}, - {"type": "special_keyword", "start": 2473, "end": 2479}, - {"type": "keyword", "start": 2480, "end": 2485}, - {"type": "operator", "start": 2504, "end": 2505}, - {"type": "string", "start": 2506, "end": 2535}, - {"type": "punctuation", "start": 2535, "end": 2536}, - {"type": "special_keyword", "start": 2537, "end": 2543}, - {"type": "keyword", "start": 2544, "end": 2549}, - {"type": "operator", "start": 2567, "end": 2568}, - {"type": "string", "start": 2569, "end": 2595}, - {"type": "punctuation", "start": 2595, "end": 2596}, - {"type": "special_keyword", "start": 2597, "end": 2603}, - {"type": "keyword", "start": 2604, "end": 2609}, - {"type": "operator", "start": 2629, "end": 2630}, - {"type": "template_string", "start": 2631, "end": 2648}, - {"type": "template_punctuation", "start": 2631, "end": 2632}, - {"type": "string", "start": 2632, "end": 2639}, - {"type": "interpolation", "start": 2639, "end": 2647}, - {"type": "interpolation_punctuation", "start": 2639, "end": 2641}, - {"type": "number", "start": 2641, "end": 2642}, - {"type": "operator", "start": 2643, "end": 2644}, - {"type": "number", "start": 2645, "end": 2646}, - {"type": "interpolation_punctuation", "start": 2646, "end": 2647}, - {"type": "template_punctuation", "start": 2647, "end": 2648}, - {"type": "punctuation", "start": 2648, "end": 2649}, - {"type": "comment", "start": 2651, "end": 2683}, - {"type": "special_keyword", "start": 2684, "end": 2690}, - {"type": "keyword", "start": 2691, "end": 2696}, - {"type": "operator", "start": 2703, "end": 2704}, - {"type": "regex", "start": 2705, "end": 2714}, - {"type": "regex_delimiter", "start": 2705, "end": 2706}, - {"type": "regex_source", "start": 2706, "end": 2712}, - {"type": "regex_delimiter", "start": 2712, "end": 2713}, - {"type": "regex_flags", "start": 2713, "end": 2714}, - {"type": "punctuation", "start": 2714, "end": 2715}, - {"type": "special_keyword", "start": 2716, "end": 2722}, - {"type": "keyword", "start": 2723, "end": 2728}, - {"type": "operator", "start": 2743, "end": 2744}, - {"type": "regex", "start": 2745, "end": 2777}, - {"type": "regex_delimiter", "start": 2745, "end": 2746}, - {"type": "regex_source", "start": 2746, "end": 2776}, - {"type": "regex_delimiter", "start": 2776, "end": 2777}, - {"type": "punctuation", "start": 2777, "end": 2778}, - {"type": "comment", "start": 2780, "end": 2836}, - {"type": "comment", "start": 2837, "end": 2888} + {"type": "keyword", "start": 2122, "end": 2126}, + {"type": "operator", "start": 2126, "end": 2127}, + {"type": "punctuation", "start": 2128, "end": 2129}, + {"type": "operator", "start": 2135, "end": 2136}, + {"type": "builtin", "start": 2137, "end": 2143}, + {"type": "punctuation", "start": 2143, "end": 2144}, + {"type": "operator", "start": 2149, "end": 2150}, + {"type": "builtin", "start": 2151, "end": 2157}, + {"type": "punctuation", "start": 2157, "end": 2158}, + {"type": "operator", "start": 2161, "end": 2162}, + {"type": "operator", "start": 2162, "end": 2163}, + {"type": "constant", "start": 2164, "end": 2165}, + {"type": "punctuation", "start": 2165, "end": 2166}, + {"type": "punctuation", "start": 2167, "end": 2168}, + {"type": "keyword", "start": 2170, "end": 2175}, + {"type": "operator", "start": 2177, "end": 2178}, + {"type": "punctuation", "start": 2179, "end": 2180}, + {"type": "operator", "start": 2184, "end": 2185}, + {"type": "builtin", "start": 2186, "end": 2192}, + {"type": "punctuation", "start": 2192, "end": 2193}, + {"type": "operator", "start": 2197, "end": 2198}, + {"type": "builtin", "start": 2199, "end": 2205}, + {"type": "punctuation", "start": 2205, "end": 2206}, + {"type": "operator", "start": 2207, "end": 2208}, + {"type": "punctuation", "start": 2209, "end": 2210}, + {"type": "operator", "start": 2214, "end": 2215}, + {"type": "string", "start": 2216, "end": 2223}, + {"type": "punctuation", "start": 2223, "end": 2224}, + {"type": "operator", "start": 2228, "end": 2229}, + {"type": "number", "start": 2230, "end": 2233}, + {"type": "punctuation", "start": 2233, "end": 2234}, + {"type": "punctuation", "start": 2234, "end": 2235}, + {"type": "keyword", "start": 2236, "end": 2241}, + {"type": "operator", "start": 2244, "end": 2245}, + {"type": "punctuation", "start": 2246, "end": 2247}, + {"type": "punctuation", "start": 2247, "end": 2248}, + {"type": "string", "start": 2248, "end": 2250}, + {"type": "punctuation", "start": 2250, "end": 2251}, + {"type": "punctuation", "start": 2253, "end": 2254}, + {"type": "punctuation", "start": 2254, "end": 2255}, + {"type": "special_keyword", "start": 2256, "end": 2258}, + {"type": "keyword", "start": 2259, "end": 2264}, + {"type": "punctuation", "start": 2264, "end": 2265}, + {"type": "special_keyword", "start": 2266, "end": 2272}, + {"type": "keyword", "start": 2273, "end": 2278}, + {"type": "type_annotation", "start": 2285, "end": 2307}, + {"type": ":", "start": 2285, "end": 2286}, + {"type": "type", "start": 2286, "end": 2307}, + {"type": "type_name", "start": 2287, "end": 2290}, + {"type": "operator", "start": 2290, "end": 2291}, + {"type": "builtin", "start": 2291, "end": 2297}, + {"type": "punctuation", "start": 2297, "end": 2298}, + {"type": "type_name", "start": 2299, "end": 2305}, + {"type": "operator", "start": 2305, "end": 2306}, + {"type": "operator", "start": 2307, "end": 2308}, + {"type": "keyword", "start": 2309, "end": 2312}, + {"type": "class_name", "start": 2313, "end": 2316}, + {"type": "type_name", "start": 2313, "end": 2316}, + {"type": "punctuation", "start": 2316, "end": 2317}, + {"type": "punctuation", "start": 2318, "end": 2319}, + {"type": "punctuation", "start": 2319, "end": 2320}, + {"type": "special_keyword", "start": 2322, "end": 2328}, + {"type": "keyword", "start": 2329, "end": 2337}, + {"type": "function", "start": 2338, "end": 2341}, + {"type": "punctuation", "start": 2341, "end": 2342}, + {"type": "operator", "start": 2343, "end": 2344}, + {"type": "builtin", "start": 2345, "end": 2351}, + {"type": "punctuation", "start": 2351, "end": 2352}, + {"type": "operator", "start": 2354, "end": 2355}, + {"type": "builtin", "start": 2356, "end": 2362}, + {"type": "punctuation", "start": 2362, "end": 2363}, + {"type": "operator", "start": 2363, "end": 2364}, + {"type": "builtin", "start": 2365, "end": 2371}, + {"type": "punctuation", "start": 2372, "end": 2373}, + {"type": "special_keyword", "start": 2375, "end": 2381}, + {"type": "operator", "start": 2384, "end": 2385}, + {"type": "punctuation", "start": 2387, "end": 2388}, + {"type": "punctuation", "start": 2389, "end": 2390}, + {"type": "special_keyword", "start": 2392, "end": 2398}, + {"type": "keyword", "start": 2399, "end": 2404}, + {"type": "function_variable", "start": 2405, "end": 2409}, + {"type": "operator", "start": 2410, "end": 2411}, + {"type": "punctuation", "start": 2412, "end": 2413}, + {"type": "operator", "start": 2414, "end": 2415}, + {"type": "builtin", "start": 2416, "end": 2419}, + {"type": "punctuation", "start": 2419, "end": 2420}, + {"type": "operator", "start": 2422, "end": 2423}, + {"type": "builtin", "start": 2424, "end": 2427}, + {"type": "punctuation", "start": 2427, "end": 2428}, + {"type": "type_annotation", "start": 2428, "end": 2434}, + {"type": ":", "start": 2428, "end": 2429}, + {"type": "type", "start": 2429, "end": 2434}, + {"type": "builtin", "start": 2430, "end": 2433}, + {"type": "operator", "start": 2434, "end": 2436}, + {"type": "operator", "start": 2439, "end": 2440}, + {"type": "punctuation", "start": 2442, "end": 2443}, + {"type": "comment", "start": 2445, "end": 2467}, + {"type": "special_keyword", "start": 2468, "end": 2474}, + {"type": "keyword", "start": 2475, "end": 2480}, + {"type": "operator", "start": 2499, "end": 2500}, + {"type": "string", "start": 2501, "end": 2530}, + {"type": "punctuation", "start": 2530, "end": 2531}, + {"type": "special_keyword", "start": 2532, "end": 2538}, + {"type": "keyword", "start": 2539, "end": 2544}, + {"type": "operator", "start": 2562, "end": 2563}, + {"type": "string", "start": 2564, "end": 2590}, + {"type": "punctuation", "start": 2590, "end": 2591}, + {"type": "special_keyword", "start": 2592, "end": 2598}, + {"type": "keyword", "start": 2599, "end": 2604}, + {"type": "operator", "start": 2624, "end": 2625}, + {"type": "template_string", "start": 2626, "end": 2643}, + {"type": "template_punctuation", "start": 2626, "end": 2627}, + {"type": "string", "start": 2627, "end": 2634}, + {"type": "interpolation", "start": 2634, "end": 2642}, + {"type": "interpolation_punctuation", "start": 2634, "end": 2636}, + {"type": "number", "start": 2636, "end": 2637}, + {"type": "operator", "start": 2638, "end": 2639}, + {"type": "number", "start": 2640, "end": 2641}, + {"type": "interpolation_punctuation", "start": 2641, "end": 2642}, + {"type": "template_punctuation", "start": 2642, "end": 2643}, + {"type": "punctuation", "start": 2643, "end": 2644}, + {"type": "comment", "start": 2646, "end": 2678}, + {"type": "special_keyword", "start": 2679, "end": 2685}, + {"type": "keyword", "start": 2686, "end": 2691}, + {"type": "operator", "start": 2698, "end": 2699}, + {"type": "regex", "start": 2700, "end": 2709}, + {"type": "regex_delimiter", "start": 2700, "end": 2701}, + {"type": "regex_source", "start": 2701, "end": 2707}, + {"type": "regex_delimiter", "start": 2707, "end": 2708}, + {"type": "regex_flags", "start": 2708, "end": 2709}, + {"type": "punctuation", "start": 2709, "end": 2710}, + {"type": "special_keyword", "start": 2711, "end": 2717}, + {"type": "keyword", "start": 2718, "end": 2723}, + {"type": "operator", "start": 2738, "end": 2739}, + {"type": "regex", "start": 2740, "end": 2772}, + {"type": "regex_delimiter", "start": 2740, "end": 2741}, + {"type": "regex_source", "start": 2741, "end": 2771}, + {"type": "regex_delimiter", "start": 2771, "end": 2772}, + {"type": "punctuation", "start": 2772, "end": 2773}, + {"type": "comment", "start": 2775, "end": 2831}, + {"type": "comment", "start": 2832, "end": 2883} ], - "html": "const a = 1;\n\nconst b: string = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E<T = undefined> {\n\tname: string;\n\tage: number;\n\tt?: T;\n}\n\nconst e: {name: string; age: number} = {name: 'A. H.', age: 100};\nconst v = [['', e]] as const;\nexport const some_e: Map<string, Some_E> = new Map(v);\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" + "html": "const a = 1;\n\nconst b: string = 'b';\n\nconst c = true;\n\nexport type Some_Type = 1 | 'b' | true;\n\ndeclare const class_decorator: any, property_decorator: any, method_decorator: any;\n\nabstract class Base {\n\tabstract abstract_method(): void;\n}\n\n@class_decorator\nclass D extends Base {\n\treadonly d1: string = 'd';\n\td2: number;\n\td3 = $state(null);\n\n\t@property_decorator\n\tdecorated = true;\n\n\tconstructor(d2: number) {\n\t\tsuper();\n\t\tthis.d2 = d2;\n\t}\n\n\tabstract_method(): void {\n\t\t// implementation\n\t}\n\n\t@method_decorator('example', {option: true})\n\tclass_method(): string {\n\t\treturn `Hello, ${this.d1}`;\n\t}\n\n\tinstance_method = (): void => {\n\t\t/* ... */\n\t\tlet i = 0;\n\t\tdo {\n\t\t\ti++;\n\t\t} while (i < 3);\n\n\t\tfor (const c2 of this.d1) {\n\t\t\tif (c2 === 'd') continue;\n\t\t\tif (!c2) break;\n\t\t\tthis.#private_method(a, c2);\n\t\t}\n\n\t\tswitch (this.d1) {\n\t\t\tcase 'a':\n\t\t\t\tconsole.log('case a');\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\tcase 'c':\n\t\t\t\tconsole.log('case b or c');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tconsole.log('default');\n\t\t}\n\n\t\tconst obj: {has_d1?: boolean; is_d: boolean} = {\n\t\t\thas_d1: 'd1' in this,\n\t\t\tis_d: this instanceof D,\n\t\t};\n\t\tdelete obj.has_d1;\n\t\t// foo\n\t};\n\n\t#private_method(a2: number, c2: any) {\n\t\tthrow new Error(`${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t`);\n\t}\n\n\t*generator() {\n\t\tyield 1;\n\t\tyield* [2, 3];\n\t}\n\n\tasync *async_generator() {\n\t\tyield await Promise.resolve(4);\n\t}\n\n\tprotected async protected_method(): Promise<void> {\n\t\ttry {\n\t\t\tawait new Promise((resolve) => setTimeout(resolve, 100));\n\t\t\tif (Math.random() > 0.5) {\n\t\t\t\tconsole.log(new Date()); // eslint-disable-line no-console\n\t\t\t} else if (Math.random() > 0.2) {\n\t\t\t\tconsole.log('else if branch');\n\t\t\t} else {\n\t\t\t\tconsole.log('else branch');\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconsole.error(error);\n\t\t} finally {\n\t\t\tconsole.log('finally block');\n\t\t}\n\t}\n}\n\n// comment\n\n/*\nother comment\n\nconst comment = false;\n*/\n\n/**\n * JSDoc comment\n */\n\nimport {sample_langs, type Sample_Lang} from '../code_sample.js';\nimport * as A from '../code_sample.js';\n\nexport {a, A, b, c, D};\n\nsample_langs as unknown as any as Sample_Lang satisfies Sample_Lang;\n\nexport interface Some_E<T = null> {\n\tname: string;\n\tage: number;\n\tt?: T;\n}\n\nconst e: {name: string; age: number} = {name: 'A. H.', age: 100};\nconst v = [['', e]] as const;\nexport const some_e: Map<string, Some_E> = new Map(v);\n\nexport function add(x: number, y: number): number {\n\treturn x + y;\n}\n\nexport const plus = (a: any, b: any): any => a + b;\n\n// boundary test cases\nexport const str_with_keywords = 'const class function string';\nexport const str_with_comment = '// this is not a comment';\nexport const template_with_expr = `Value: ${1 + 2}`;\n\n// regex that looks like comment\nexport const regex = /\\/\\/.*/g;\nexport const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;\n\n// string in comment should not be highlighted as string\n// const commented = \"this string is in a comment\";\n" } diff --git a/fixtures/generated/ts/ts_complex.txt b/src/fixtures/generated/ts/ts_complex.txt similarity index 77% rename from fixtures/generated/ts/ts_complex.txt rename to src/fixtures/generated/ts/ts_complex.txt index e39a2eed..60cf95b4 100644 --- a/fixtures/generated/ts/ts_complex.txt +++ b/src/fixtures/generated/ts/ts_complex.txt @@ -472,156 +472,156 @@ 2091-2092 punctuation ; 2094-2100 special_keyword export 2101-2110 keyword interface -2111-2132 class_name Some_E +2111-2127 class_name Some_E 2111-2117 type_name Some_E 2117-2118 operator < 2118-2119 constant T 2120-2121 operator = -2122-2131 keyword undefined -2131-2132 operator > -2133-2134 punctuation { -2140-2141 operator : -2142-2148 builtin string -2148-2149 punctuation ; -2154-2155 operator : -2156-2162 builtin number -2162-2163 punctuation ; -2166-2167 operator ? -2167-2168 operator : -2169-2170 constant T -2170-2171 punctuation ; -2172-2173 punctuation } -2175-2180 keyword const -2182-2183 operator : -2184-2185 punctuation { -2189-2190 operator : -2191-2197 builtin string -2197-2198 punctuation ; -2202-2203 operator : -2204-2210 builtin number -2210-2211 punctuation } -2212-2213 operator = -2214-2215 punctuation { -2219-2220 operator : -2221-2228 string 'A. H.' -2228-2229 punctuation , -2233-2234 operator : -2235-2238 number 100 -2238-2239 punctuation } -2239-2240 punctuation ; -2241-2246 keyword const -2249-2250 operator = -2251-2252 punctuation [ -2252-2253 punctuation [ -2253-2255 string '' -2255-2256 punctuation , -2258-2259 punctuation ] -2259-2260 punctuation ] -2261-2263 special_keyword as -2264-2269 keyword const -2269-2270 punctuation ; -2271-2277 special_keyword export -2278-2283 keyword const -2290-2312 type_annotation : Map -2290-2291 : : -2291-2312 type Map -2292-2295 type_name Map -2295-2296 operator < -2296-2302 builtin string -2302-2303 punctuation , -2304-2310 type_name Some_E -2310-2311 operator > -2312-2313 operator = -2314-2317 keyword new -2318-2321 class_name Map -2318-2321 type_name Map -2321-2322 punctuation ( -2323-2324 punctuation ) -2324-2325 punctuation ; -2327-2333 special_keyword export -2334-2342 keyword function -2343-2346 function add -2346-2347 punctuation ( -2348-2349 operator : -2350-2356 builtin number -2356-2357 punctuation , -2359-2360 operator : -2361-2367 builtin number -2367-2368 punctuation ) -2368-2369 operator : -2370-2376 builtin number -2377-2378 punctuation { -2380-2386 special_keyword return -2389-2390 operator + -2392-2393 punctuation ; -2394-2395 punctuation } -2397-2403 special_keyword export -2404-2409 keyword const -2410-2414 function_variable plus -2415-2416 operator = -2417-2418 punctuation ( -2419-2420 operator : -2421-2424 builtin any -2424-2425 punctuation , -2427-2428 operator : -2429-2432 builtin any -2432-2433 punctuation ) -2433-2439 type_annotation : any -2433-2434 : : -2434-2439 type any -2435-2438 builtin any -2439-2441 operator => -2444-2445 operator + -2447-2448 punctuation ; -2450-2472 comment // boundary test cases -2473-2479 special_keyword export -2480-2485 keyword const -2504-2505 operator = -2506-2535 string 'const class function string' -2535-2536 punctuation ; -2537-2543 special_keyword export -2544-2549 keyword const -2567-2568 operator = -2569-2595 string '// this is not a comment' -2595-2596 punctuation ; -2597-2603 special_keyword export -2604-2609 keyword const -2629-2630 operator = -2631-2648 template_string `Value: ${1 + 2}` -2631-2632 template_punctuation ` -2632-2639 string Value: -2639-2647 interpolation ${1 + 2} -2639-2641 interpolation_punctuation ${ -2641-2642 number 1 -2643-2644 operator + -2645-2646 number 2 -2646-2647 interpolation_punctuation } -2647-2648 template_punctuation ` -2648-2649 punctuation ; -2651-2683 comment // regex that looks like comment -2684-2690 special_keyword export -2691-2696 keyword const -2703-2704 operator = -2705-2714 regex /\/\/.*/g -2705-2706 regex_delimiter / -2706-2712 regex_source \/\/.* -2712-2713 regex_delimiter / -2713-2714 regex_flags g -2714-2715 punctuation ; -2716-2722 special_keyword export -2723-2728 keyword const -2743-2744 operator = -2745-2777 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ -2745-2746 regex_delimiter / -2746-2776 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ -2776-2777 regex_delimiter / -2777-2778 punctuation ; -2780-2836 comment // string in comment should not be highlighted as string -2837-2888 comment // const commented = "this string is in a comment"; +2122-2126 keyword null +2126-2127 operator > +2128-2129 punctuation { +2135-2136 operator : +2137-2143 builtin string +2143-2144 punctuation ; +2149-2150 operator : +2151-2157 builtin number +2157-2158 punctuation ; +2161-2162 operator ? +2162-2163 operator : +2164-2165 constant T +2165-2166 punctuation ; +2167-2168 punctuation } +2170-2175 keyword const +2177-2178 operator : +2179-2180 punctuation { +2184-2185 operator : +2186-2192 builtin string +2192-2193 punctuation ; +2197-2198 operator : +2199-2205 builtin number +2205-2206 punctuation } +2207-2208 operator = +2209-2210 punctuation { +2214-2215 operator : +2216-2223 string 'A. H.' +2223-2224 punctuation , +2228-2229 operator : +2230-2233 number 100 +2233-2234 punctuation } +2234-2235 punctuation ; +2236-2241 keyword const +2244-2245 operator = +2246-2247 punctuation [ +2247-2248 punctuation [ +2248-2250 string '' +2250-2251 punctuation , +2253-2254 punctuation ] +2254-2255 punctuation ] +2256-2258 special_keyword as +2259-2264 keyword const +2264-2265 punctuation ; +2266-2272 special_keyword export +2273-2278 keyword const +2285-2307 type_annotation : Map +2285-2286 : : +2286-2307 type Map +2287-2290 type_name Map +2290-2291 operator < +2291-2297 builtin string +2297-2298 punctuation , +2299-2305 type_name Some_E +2305-2306 operator > +2307-2308 operator = +2309-2312 keyword new +2313-2316 class_name Map +2313-2316 type_name Map +2316-2317 punctuation ( +2318-2319 punctuation ) +2319-2320 punctuation ; +2322-2328 special_keyword export +2329-2337 keyword function +2338-2341 function add +2341-2342 punctuation ( +2343-2344 operator : +2345-2351 builtin number +2351-2352 punctuation , +2354-2355 operator : +2356-2362 builtin number +2362-2363 punctuation ) +2363-2364 operator : +2365-2371 builtin number +2372-2373 punctuation { +2375-2381 special_keyword return +2384-2385 operator + +2387-2388 punctuation ; +2389-2390 punctuation } +2392-2398 special_keyword export +2399-2404 keyword const +2405-2409 function_variable plus +2410-2411 operator = +2412-2413 punctuation ( +2414-2415 operator : +2416-2419 builtin any +2419-2420 punctuation , +2422-2423 operator : +2424-2427 builtin any +2427-2428 punctuation ) +2428-2434 type_annotation : any +2428-2429 : : +2429-2434 type any +2430-2433 builtin any +2434-2436 operator => +2439-2440 operator + +2442-2443 punctuation ; +2445-2467 comment // boundary test cases +2468-2474 special_keyword export +2475-2480 keyword const +2499-2500 operator = +2501-2530 string 'const class function string' +2530-2531 punctuation ; +2532-2538 special_keyword export +2539-2544 keyword const +2562-2563 operator = +2564-2590 string '// this is not a comment' +2590-2591 punctuation ; +2592-2598 special_keyword export +2599-2604 keyword const +2624-2625 operator = +2626-2643 template_string `Value: ${1 + 2}` +2626-2627 template_punctuation ` +2627-2634 string Value: +2634-2642 interpolation ${1 + 2} +2634-2636 interpolation_punctuation ${ +2636-2637 number 1 +2638-2639 operator + +2640-2641 number 2 +2641-2642 interpolation_punctuation } +2642-2643 template_punctuation ` +2643-2644 punctuation ; +2646-2678 comment // regex that looks like comment +2679-2685 special_keyword export +2686-2691 keyword const +2698-2699 operator = +2700-2709 regex /\/\/.*/g +2700-2701 regex_delimiter / +2701-2707 regex_source \/\/.* +2707-2708 regex_delimiter / +2708-2709 regex_flags g +2709-2710 punctuation ; +2711-2717 special_keyword export +2718-2723 keyword const +2738-2739 operator = +2740-2772 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ +2740-2741 regex_delimiter / +2741-2771 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +2771-2772 regex_delimiter / +2772-2773 punctuation ; +2775-2831 comment // string in comment should not be highlighted as string +2832-2883 comment // const commented = "this string is in a comment"; === STATS === Total tokens: 619 -Sample length: 2889 characters +Sample length: 2884 characters Token types: punctuation: 235 diff --git a/src/fixtures/helpers.ts b/src/fixtures/helpers.ts index 3cccd320..3f490173 100644 --- a/src/fixtures/helpers.ts +++ b/src/fixtures/helpers.ts @@ -51,7 +51,7 @@ export const discover_samples = (): Array => { * Get the fixture path for a given language and variant */ export const get_fixture_path = (lang: string, variant: string, ext: 'json' | 'txt'): string => { - return join('fixtures/generated', lang, `${lang}_${variant}.${ext}`); + return join('src/fixtures/generated', lang, `${lang}_${variant}.${ext}`); }; /** diff --git a/src/fixtures/update.task.ts b/src/fixtures/update.task.ts index 5f904f6d..723a6f00 100644 --- a/src/fixtures/update.task.ts +++ b/src/fixtures/update.task.ts @@ -1,6 +1,6 @@ import type {Task} from '@ryanatkn/gro'; import {writeFileSync, mkdirSync, rmSync, existsSync} from 'node:fs'; -import {join} from 'node:path'; +import {join, resolve} from 'node:path'; import {format_file} from '@ryanatkn/gro/format_file.js'; import { discover_samples, @@ -20,9 +20,11 @@ export const task: Task = { // Get unique languages to clean directories const languages = new Set(samples.map((s) => s.lang)); + const generated_fixtures_dir = resolve('src/fixtures/generated'); + // Remove existing language directories for (const lang of languages) { - const dir = join('fixtures/generated', lang); + const dir = join(generated_fixtures_dir, lang); if (existsSync(dir)) { rmSync(dir, {recursive: true, force: true}); console.log(`Removed existing directory: ${dir}`); // eslint-disable-line no-console @@ -37,7 +39,7 @@ export const task: Task = { const output = process_sample(sample); // Ensure directory exists - const dir = join('fixtures/generated', sample.lang); + const dir = join(generated_fixtures_dir, sample.lang); mkdirSync(dir, {recursive: true}); // Write JSON file diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 250852fa..9e61a9c1 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -209,7 +209,7 @@ export {a, A, b, c, D}; sample_langs as unknown as any as Sample_Lang satisfies Sample_Lang; -export interface Some_E { +export interface Some_E { name: string; age: number; t?: T; diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index 55f4ea4e..ab054f05 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -121,7 +121,7 @@ export {a, A, b, c, D}; sample_langs as unknown as any as Sample_Lang satisfies Sample_Lang; -export interface Some_E { +export interface Some_E { name: string; age: number; t?: T; From c0104faaaf87313b353c1d77777939b22ae05ca4 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 13:14:29 -0400 Subject: [PATCH 19/49] wip --- src/fixtures/generated/html/html_complex.json | 157 ++- src/fixtures/generated/html/html_complex.txt | 171 ++- .../generated/svelte/svelte_complex.json | 981 ++++++++------- .../generated/svelte/svelte_complex.txt | 1092 ++++++++--------- src/lib/samples/all.ts | 97 +- src/lib/samples/sample_complex.html | 8 + src/lib/samples/sample_complex.svelte | 89 +- 7 files changed, 1337 insertions(+), 1258 deletions(-) diff --git a/src/fixtures/generated/html/html_complex.json b/src/fixtures/generated/html/html_complex.json index 72a85484..995d8e51 100644 --- a/src/fixtures/generated/html/html_complex.json +++ b/src/fixtures/generated/html/html_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "html", "variant": "complex", - "content": "\n\n
\n\t

hello world!

\n
\n\n

some text

\n\n\n\n\n\n
\n\n
\n\n\"access\"\n\n
    \n\t
  • list item 1
  • \n\t
  • list item 2
  • \n
\n\n\n\n\n\n ]]>\n", + "content": "\n\n
\n\t

hello world!

\n
\n\n

some text

\n\n\n\n\n\n
\n\n
\n\n\"access\"\n\n
    \n\t
  • list item 1
  • \n\t
  • list item 2
  • \n
\n\n
\n\t\n\t\n
\n\n\n\n\n\n ]]>\n", "filepath": "src/lib/samples/sample_complex.html" }, "tokens": [ @@ -115,48 +115,129 @@ {"type": "tag", "start": 342, "end": 346}, {"type": "punctuation", "start": 342, "end": 344}, {"type": "punctuation", "start": 346, "end": 347}, - {"type": "tag", "start": 349, "end": 380}, - {"type": "tag", "start": 349, "end": 356}, + {"type": "tag", "start": 349, "end": 386}, + {"type": "tag", "start": 349, "end": 354}, {"type": "punctuation", "start": 349, "end": 350}, - {"type": "attr_name", "start": 357, "end": 361}, - {"type": "attr_value", "start": 361, "end": 379}, + {"type": "attr_name", "start": 355, "end": 361}, + {"type": "attr_value", "start": 361, "end": 371}, {"type": "punctuation", "start": 361, "end": 362}, {"type": "punctuation", "start": 362, "end": 363}, + {"type": "punctuation", "start": 370, "end": 371}, + {"type": "attr_name", "start": 372, "end": 378}, + {"type": "attr_value", "start": 378, "end": 385}, {"type": "punctuation", "start": 378, "end": 379}, {"type": "punctuation", "start": 379, "end": 380}, - {"type": "script", "start": 380, "end": 404}, - {"type": "lang_js", "start": 380, "end": 404}, - {"type": "keyword", "start": 382, "end": 387}, - {"type": "operator", "start": 391, "end": 392}, - {"type": "string", "start": 393, "end": 402}, - {"type": "punctuation", "start": 402, "end": 403}, - {"type": "tag", "start": 404, "end": 413}, - {"type": "tag", "start": 404, "end": 412}, - {"type": "punctuation", "start": 404, "end": 406}, + {"type": "punctuation", "start": 384, "end": 385}, + {"type": "punctuation", "start": 385, "end": 386}, + {"type": "tag", "start": 388, "end": 450}, + {"type": "tag", "start": 388, "end": 394}, + {"type": "punctuation", "start": 388, "end": 389}, + {"type": "attr_name", "start": 395, "end": 399}, + {"type": "attr_value", "start": 399, "end": 406}, + {"type": "punctuation", "start": 399, "end": 400}, + {"type": "punctuation", "start": 400, "end": 401}, + {"type": "punctuation", "start": 405, "end": 406}, + {"type": "attr_name", "start": 407, "end": 411}, + {"type": "attr_value", "start": 411, "end": 422}, + {"type": "punctuation", "start": 411, "end": 412}, {"type": "punctuation", "start": 412, "end": 413}, - {"type": "tag", "start": 415, "end": 438}, - {"type": "tag", "start": 415, "end": 421}, - {"type": "punctuation", "start": 415, "end": 416}, - {"type": "attr_name", "start": 422, "end": 426}, - {"type": "attr_value", "start": 426, "end": 437}, - {"type": "punctuation", "start": 426, "end": 427}, - {"type": "punctuation", "start": 427, "end": 428}, - {"type": "punctuation", "start": 436, "end": 437}, - {"type": "punctuation", "start": 437, "end": 438}, - {"type": "style", "start": 438, "end": 482}, - {"type": "lang_css", "start": 438, "end": 482}, - {"type": "selector", "start": 440, "end": 456}, - {"type": "punctuation", "start": 457, "end": 458}, - {"type": "property", "start": 461, "end": 468}, - {"type": "punctuation", "start": 468, "end": 469}, - {"type": "string", "start": 470, "end": 477}, - {"type": "punctuation", "start": 477, "end": 478}, - {"type": "punctuation", "start": 480, "end": 481}, - {"type": "tag", "start": 482, "end": 490}, - {"type": "tag", "start": 482, "end": 489}, - {"type": "punctuation", "start": 482, "end": 484}, - {"type": "punctuation", "start": 489, "end": 490}, - {"type": "cdata", "start": 492, "end": 540} + {"type": "punctuation", "start": 421, "end": 422}, + {"type": "attr_name", "start": 423, "end": 434}, + {"type": "attr_value", "start": 434, "end": 447}, + {"type": "punctuation", "start": 434, "end": 435}, + {"type": "punctuation", "start": 435, "end": 436}, + {"type": "punctuation", "start": 446, "end": 447}, + {"type": "punctuation", "start": 448, "end": 450}, + {"type": "tag", "start": 452, "end": 495}, + {"type": "tag", "start": 452, "end": 459}, + {"type": "punctuation", "start": 452, "end": 453}, + {"type": "attr_name", "start": 460, "end": 464}, + {"type": "attr_value", "start": 464, "end": 473}, + {"type": "punctuation", "start": 464, "end": 465}, + {"type": "punctuation", "start": 465, "end": 466}, + {"type": "punctuation", "start": 472, "end": 473}, + {"type": "attr_name", "start": 474, "end": 483}, + {"type": "attr_value", "start": 483, "end": 494}, + {"type": "punctuation", "start": 483, "end": 484}, + {"type": "punctuation", "start": 484, "end": 485}, + {"type": "punctuation", "start": 493, "end": 494}, + {"type": "punctuation", "start": 494, "end": 495}, + {"type": "tag", "start": 498, "end": 516}, + {"type": "tag", "start": 498, "end": 505}, + {"type": "punctuation", "start": 498, "end": 499}, + {"type": "attr_name", "start": 506, "end": 511}, + {"type": "attr_value", "start": 511, "end": 515}, + {"type": "punctuation", "start": 511, "end": 512}, + {"type": "punctuation", "start": 512, "end": 513}, + {"type": "punctuation", "start": 514, "end": 515}, + {"type": "punctuation", "start": 515, "end": 516}, + {"type": "tag", "start": 521, "end": 530}, + {"type": "tag", "start": 521, "end": 529}, + {"type": "punctuation", "start": 521, "end": 523}, + {"type": "punctuation", "start": 529, "end": 530}, + {"type": "tag", "start": 533, "end": 551}, + {"type": "tag", "start": 533, "end": 540}, + {"type": "punctuation", "start": 533, "end": 534}, + {"type": "attr_name", "start": 541, "end": 546}, + {"type": "attr_value", "start": 546, "end": 550}, + {"type": "punctuation", "start": 546, "end": 547}, + {"type": "punctuation", "start": 547, "end": 548}, + {"type": "punctuation", "start": 549, "end": 550}, + {"type": "punctuation", "start": 550, "end": 551}, + {"type": "tag", "start": 557, "end": 566}, + {"type": "tag", "start": 557, "end": 565}, + {"type": "punctuation", "start": 557, "end": 559}, + {"type": "punctuation", "start": 565, "end": 566}, + {"type": "tag", "start": 568, "end": 577}, + {"type": "tag", "start": 568, "end": 576}, + {"type": "punctuation", "start": 568, "end": 570}, + {"type": "punctuation", "start": 576, "end": 577}, + {"type": "tag", "start": 578, "end": 585}, + {"type": "tag", "start": 578, "end": 584}, + {"type": "punctuation", "start": 578, "end": 580}, + {"type": "punctuation", "start": 584, "end": 585}, + {"type": "tag", "start": 587, "end": 618}, + {"type": "tag", "start": 587, "end": 594}, + {"type": "punctuation", "start": 587, "end": 588}, + {"type": "attr_name", "start": 595, "end": 599}, + {"type": "attr_value", "start": 599, "end": 617}, + {"type": "punctuation", "start": 599, "end": 600}, + {"type": "punctuation", "start": 600, "end": 601}, + {"type": "punctuation", "start": 616, "end": 617}, + {"type": "punctuation", "start": 617, "end": 618}, + {"type": "script", "start": 618, "end": 642}, + {"type": "lang_js", "start": 618, "end": 642}, + {"type": "keyword", "start": 620, "end": 625}, + {"type": "operator", "start": 629, "end": 630}, + {"type": "string", "start": 631, "end": 640}, + {"type": "punctuation", "start": 640, "end": 641}, + {"type": "tag", "start": 642, "end": 651}, + {"type": "tag", "start": 642, "end": 650}, + {"type": "punctuation", "start": 642, "end": 644}, + {"type": "punctuation", "start": 650, "end": 651}, + {"type": "tag", "start": 653, "end": 676}, + {"type": "tag", "start": 653, "end": 659}, + {"type": "punctuation", "start": 653, "end": 654}, + {"type": "attr_name", "start": 660, "end": 664}, + {"type": "attr_value", "start": 664, "end": 675}, + {"type": "punctuation", "start": 664, "end": 665}, + {"type": "punctuation", "start": 665, "end": 666}, + {"type": "punctuation", "start": 674, "end": 675}, + {"type": "punctuation", "start": 675, "end": 676}, + {"type": "style", "start": 676, "end": 720}, + {"type": "lang_css", "start": 676, "end": 720}, + {"type": "selector", "start": 678, "end": 694}, + {"type": "punctuation", "start": 695, "end": 696}, + {"type": "property", "start": 699, "end": 706}, + {"type": "punctuation", "start": 706, "end": 707}, + {"type": "string", "start": 708, "end": 715}, + {"type": "punctuation", "start": 715, "end": 716}, + {"type": "punctuation", "start": 718, "end": 719}, + {"type": "tag", "start": 720, "end": 728}, + {"type": "tag", "start": 720, "end": 727}, + {"type": "punctuation", "start": 720, "end": 722}, + {"type": "punctuation", "start": 727, "end": 728}, + {"type": "cdata", "start": 730, "end": 778} ], - "html": "<!doctype html>\n\n<div class=\"test\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">some <span class=\"a b c\">text</span></p>\n\n<button type=\"button\" disabled>click me</button>\n\n<!-- comment <div>a<br /> b</div> <script> -->\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<script type=\"text/javascript\">\n\tconst ok = '<style>';\n</script>\n\n<style type=\"text/css\">\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n\n<![CDATA[ if (a < 0) alert(\"b\"); <not-a-tag> ]]>\n" + "html": "<!doctype html>\n\n<div class=\"test\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">some <span class=\"a b c\">text</span></p>\n\n<button type=\"button\" disabled>click me</button>\n\n<!-- comment <div>a<br /> b</div> <script> -->\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<form action=\"/submit\" method=\"post\">\n\t<input type=\"text\" name=\"username\" placeholder=\"Enter name\" />\n\t<select name=\"option\" data-role=\"dropdown\">\n\t\t<option value=\"1\">First</option>\n\t\t<option value=\"2\">Second</option>\n\t</select>\n</form>\n\n<script type=\"text/javascript\">\n\tconst ok = '<style>';\n</script>\n\n<style type=\"text/css\">\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n\n<![CDATA[ if (a < 0) alert(\"b\"); <not-a-tag> ]]>\n" } diff --git a/src/fixtures/generated/html/html_complex.txt b/src/fixtures/generated/html/html_complex.txt index cd8b4eba..c249da77 100644 --- a/src/fixtures/generated/html/html_complex.txt +++ b/src/fixtures/generated/html/html_complex.txt @@ -108,58 +108,139 @@ 342-346 tag - 349-380 tag - 404-412 tag - 415-438 tag - 482-489 tag - 492-540 cdata ]]> + 370-371 punctuation " + 372-378 attr_name method + 378-385 attr_value ="post" + 378-379 punctuation = + 379-380 punctuation " + 384-385 punctuation " + 385-386 punctuation > + 388-450 tag + 388-394 tag + 452-495 tag + 498-516 tag + 521-529 tag + 533-551 tag + 557-565 tag + 568-577 tag + 568-576 tag + 578-585 tag + 578-584 tag + 587-618 tag + 642-650 tag + 653-676 tag + 720-727 tag + 730-778 cdata ]]> === STATS === -Total tokens: 151 -Sample length: 541 characters +Total tokens: 232 +Sample length: 779 characters Token types: - punctuation: 75 - tag: 46 - attr_name: 9 - attr_value: 8 + punctuation: 120 + tag: 64 + attr_name: 18 + attr_value: 17 string: 2 doctype: 1 comment: 1 diff --git a/src/fixtures/generated/svelte/svelte_complex.json b/src/fixtures/generated/svelte/svelte_complex.json index 534150d4..77df9a73 100644 --- a/src/fixtures/generated/svelte/svelte_complex.json +++ b/src/fixtures/generated/svelte/svelte_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "svelte", "variant": "complex", - "content": "\n\n\n\n

hello {HELLO}!

\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n\n\n
\n\t

hello world!

\n
\n\n

\n\tsome text\n

\n\n\n\n\n{a}\n{b}\n{bound}\n{D}\n\n
\n\n
\n\n\"access\"\n\n
    \n\t
  • list item 1
  • \n\t
  • list item 2
  • \n
\n\n\n", + "content": "\n\n\n\n

hello {HELLO}!

\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n{@html 'raw html'}\n\n\n\n
\n\tinteractive element\n
\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t\n{/snippet}\n\n
\n\t

hello world!

\n
\n\n

\n\tsome text\n

\n\n\n\n\n{a}\n{b}\n{bound}\n\n
\n\n
\n\n\"access\"\n\n
    \n\t
  • list item 1
  • \n\t
  • list item 2
  • \n
\n\n\n
\n\t\n\t\n
\n\n\n", "filepath": "src/lib/samples/sample_complex.svelte" }, "tokens": [ @@ -37,8 +37,8 @@ {"type": "punctuation", "start": 81, "end": 82}, {"type": "punctuation", "start": 84, "end": 85}, {"type": "punctuation", "start": 85, "end": 86}, - {"type": "script", "start": 86, "end": 1268}, - {"type": "lang_ts", "start": 86, "end": 1268}, + {"type": "script", "start": 86, "end": 670}, + {"type": "lang_ts", "start": 86, "end": 670}, {"type": "comment", "start": 88, "end": 107}, {"type": "special_keyword", "start": 109, "end": 115}, {"type": "special_keyword", "start": 122, "end": 126}, @@ -61,541 +61,516 @@ {"type": "punctuation", "start": 229, "end": 230}, {"type": "punctuation", "start": 230, "end": 231}, {"type": "punctuation", "start": 242, "end": 243}, - {"type": "punctuation", "start": 245, "end": 246}, - {"type": "operator", "start": 246, "end": 247}, - {"type": "punctuation", "start": 248, "end": 249}, + {"type": "punctuation", "start": 253, "end": 254}, + {"type": "punctuation", "start": 256, "end": 257}, {"type": "operator", "start": 257, "end": 258}, - {"type": "operator", "start": 265, "end": 266}, - {"type": "builtin", "start": 266, "end": 272}, - {"type": "punctuation", "start": 272, "end": 273}, - {"type": "builtin", "start": 274, "end": 277}, - {"type": "operator", "start": 277, "end": 278}, - {"type": "punctuation", "start": 278, "end": 279}, - {"type": "operator", "start": 287, "end": 288}, + {"type": "punctuation", "start": 259, "end": 260}, + {"type": "operator", "start": 268, "end": 269}, + {"type": "operator", "start": 276, "end": 277}, + {"type": "builtin", "start": 277, "end": 283}, + {"type": "punctuation", "start": 283, "end": 284}, + {"type": "builtin", "start": 285, "end": 288}, {"type": "operator", "start": 288, "end": 289}, - {"type": "builtin", "start": 290, "end": 297}, - {"type": "punctuation", "start": 297, "end": 298}, - {"type": "operator", "start": 309, "end": 310}, - {"type": "punctuation", "start": 318, "end": 319}, - {"type": "punctuation", "start": 321, "end": 322}, - {"type": "operator", "start": 323, "end": 324}, - {"type": "function", "start": 325, "end": 331}, - {"type": "punctuation", "start": 331, "end": 332}, - {"type": "punctuation", "start": 332, "end": 333}, - {"type": "punctuation", "start": 333, "end": 334}, - {"type": "keyword", "start": 337, "end": 342}, - {"type": "operator", "start": 354, "end": 355}, - {"type": "function", "start": 356, "end": 364}, - {"type": "punctuation", "start": 364, "end": 365}, - {"type": "punctuation", "start": 371, "end": 372}, - {"type": "function", "start": 372, "end": 376}, - {"type": "punctuation", "start": 376, "end": 377}, - {"type": "punctuation", "start": 382, "end": 383}, - {"type": "punctuation", "start": 383, "end": 384}, - {"type": "punctuation", "start": 384, "end": 385}, - {"type": "keyword", "start": 388, "end": 393}, - {"type": "operator", "start": 396, "end": 397}, - {"type": "number", "start": 398, "end": 399}, + {"type": "punctuation", "start": 289, "end": 290}, + {"type": "operator", "start": 298, "end": 299}, + {"type": "operator", "start": 299, "end": 300}, + {"type": "builtin", "start": 301, "end": 308}, + {"type": "punctuation", "start": 308, "end": 309}, + {"type": "operator", "start": 320, "end": 321}, + {"type": "punctuation", "start": 329, "end": 330}, + {"type": "operator", "start": 340, "end": 341}, + {"type": "operator", "start": 341, "end": 342}, + {"type": "punctuation", "start": 343, "end": 344}, + {"type": "punctuation", "start": 344, "end": 345}, + {"type": "operator", "start": 346, "end": 348}, + {"type": "keyword", "start": 349, "end": 353}, + {"type": "punctuation", "start": 353, "end": 354}, + {"type": "punctuation", "start": 356, "end": 357}, + {"type": "operator", "start": 358, "end": 359}, + {"type": "function", "start": 360, "end": 366}, + {"type": "punctuation", "start": 366, "end": 367}, + {"type": "punctuation", "start": 367, "end": 368}, + {"type": "punctuation", "start": 368, "end": 369}, + {"type": "keyword", "start": 372, "end": 377}, + {"type": "operator", "start": 389, "end": 390}, + {"type": "function", "start": 391, "end": 399}, {"type": "punctuation", "start": 399, "end": 400}, - {"type": "keyword", "start": 403, "end": 408}, - {"type": "operator", "start": 411, "end": 412}, - {"type": "string", "start": 413, "end": 416}, - {"type": "punctuation", "start": 416, "end": 417}, - {"type": "keyword", "start": 420, "end": 423}, - {"type": "type_annotation", "start": 425, "end": 435}, - {"type": ":", "start": 425, "end": 426}, - {"type": "type", "start": 426, "end": 435}, - {"type": "builtin", "start": 427, "end": 434}, - {"type": "operator", "start": 435, "end": 436}, - {"type": "function", "start": 437, "end": 443}, - {"type": "punctuation", "start": 443, "end": 444}, - {"type": "boolean", "start": 444, "end": 448}, - {"type": "punctuation", "start": 448, "end": 449}, - {"type": "punctuation", "start": 449, "end": 450}, - {"type": "special_keyword", "start": 453, "end": 459}, - {"type": "keyword", "start": 460, "end": 464}, - {"type": "class_name", "start": 465, "end": 474}, - {"type": "type_name", "start": 465, "end": 474}, - {"type": "operator", "start": 475, "end": 476}, - {"type": "number", "start": 477, "end": 478}, - {"type": "operator", "start": 479, "end": 480}, - {"type": "string", "start": 481, "end": 484}, - {"type": "operator", "start": 485, "end": 486}, - {"type": "boolean", "start": 487, "end": 491}, - {"type": "punctuation", "start": 491, "end": 492}, - {"type": "keyword", "start": 495, "end": 500}, - {"type": "class_name", "start": 501, "end": 502}, - {"type": "constant", "start": 501, "end": 502}, - {"type": "punctuation", "start": 503, "end": 504}, - {"type": "type_annotation", "start": 509, "end": 518}, - {"type": ":", "start": 509, "end": 510}, - {"type": "type", "start": 510, "end": 518}, - {"type": "builtin", "start": 511, "end": 517}, - {"type": "operator", "start": 518, "end": 519}, - {"type": "string", "start": 520, "end": 523}, - {"type": "punctuation", "start": 523, "end": 524}, - {"type": "operator", "start": 529, "end": 530}, - {"type": "builtin", "start": 531, "end": 537}, - {"type": "punctuation", "start": 537, "end": 538}, - {"type": "operator", "start": 544, "end": 545}, - {"type": "function", "start": 546, "end": 552}, - {"type": "punctuation", "start": 552, "end": 553}, - {"type": "boolean", "start": 553, "end": 558}, - {"type": "punctuation", "start": 558, "end": 559}, - {"type": "punctuation", "start": 559, "end": 560}, - {"type": "function", "start": 564, "end": 575}, - {"type": "punctuation", "start": 575, "end": 576}, - {"type": "operator", "start": 578, "end": 579}, - {"type": "builtin", "start": 580, "end": 586}, - {"type": "punctuation", "start": 586, "end": 587}, - {"type": "punctuation", "start": 588, "end": 589}, - {"type": "keyword", "start": 593, "end": 597}, - {"type": "punctuation", "start": 597, "end": 598}, - {"type": "operator", "start": 601, "end": 602}, - {"type": "punctuation", "start": 605, "end": 606}, - {"type": "punctuation", "start": 609, "end": 610}, - {"type": "function", "start": 614, "end": 626}, - {"type": "punctuation", "start": 626, "end": 627}, - {"type": "punctuation", "start": 627, "end": 628}, - {"type": "operator", "start": 628, "end": 629}, - {"type": "builtin", "start": 630, "end": 636}, + {"type": "punctuation", "start": 406, "end": 407}, + {"type": "function", "start": 407, "end": 411}, + {"type": "punctuation", "start": 411, "end": 412}, + {"type": "punctuation", "start": 417, "end": 418}, + {"type": "punctuation", "start": 418, "end": 419}, + {"type": "punctuation", "start": 419, "end": 420}, + {"type": "keyword", "start": 423, "end": 428}, + {"type": "operator", "start": 431, "end": 432}, + {"type": "number", "start": 433, "end": 434}, + {"type": "punctuation", "start": 434, "end": 435}, + {"type": "keyword", "start": 438, "end": 443}, + {"type": "operator", "start": 446, "end": 447}, + {"type": "string", "start": 448, "end": 451}, + {"type": "punctuation", "start": 451, "end": 452}, + {"type": "keyword", "start": 455, "end": 458}, + {"type": "type_annotation", "start": 460, "end": 470}, + {"type": ":", "start": 460, "end": 461}, + {"type": "type", "start": 461, "end": 470}, + {"type": "builtin", "start": 462, "end": 469}, + {"type": "operator", "start": 470, "end": 471}, + {"type": "function", "start": 472, "end": 478}, + {"type": "punctuation", "start": 478, "end": 479}, + {"type": "boolean", "start": 479, "end": 483}, + {"type": "punctuation", "start": 483, "end": 484}, + {"type": "punctuation", "start": 484, "end": 485}, + {"type": "keyword", "start": 488, "end": 496}, + {"type": "function", "start": 497, "end": 507}, + {"type": "punctuation", "start": 507, "end": 508}, + {"type": "operator", "start": 514, "end": 515}, + {"type": "builtin", "start": 516, "end": 522}, + {"type": "punctuation", "start": 522, "end": 523}, + {"type": "operator", "start": 530, "end": 531}, + {"type": "builtin", "start": 532, "end": 538}, + {"type": "punctuation", "start": 538, "end": 539}, + {"type": "punctuation", "start": 540, "end": 541}, + {"type": "special_keyword", "start": 544, "end": 550}, + {"type": "punctuation", "start": 551, "end": 552}, + {"type": "operator", "start": 553, "end": 554}, + {"type": "punctuation", "start": 566, "end": 567}, + {"type": "operator", "start": 568, "end": 570}, + {"type": "punctuation", "start": 571, "end": 572}, + {"type": "builtin", "start": 576, "end": 583}, + {"type": "punctuation", "start": 583, "end": 584}, + {"type": "function", "start": 584, "end": 587}, + {"type": "punctuation", "start": 587, "end": 588}, + {"type": "punctuation", "start": 594, "end": 595}, + {"type": "punctuation", "start": 602, "end": 603}, + {"type": "punctuation", "start": 603, "end": 604}, + {"type": "punctuation", "start": 607, "end": 608}, + {"type": "punctuation", "start": 608, "end": 609}, + {"type": "punctuation", "start": 611, "end": 612}, + {"type": "keyword", "start": 615, "end": 618}, + {"type": "operator", "start": 625, "end": 626}, + {"type": "function", "start": 627, "end": 633}, + {"type": "punctuation", "start": 633, "end": 634}, + {"type": "string", "start": 634, "end": 636}, + {"type": "punctuation", "start": 636, "end": 637}, {"type": "punctuation", "start": 637, "end": 638}, - {"type": "special_keyword", "start": 642, "end": 648}, - {"type": "template_string", "start": 649, "end": 668}, - {"type": "template_punctuation", "start": 649, "end": 650}, - {"type": "string", "start": 650, "end": 657}, - {"type": "interpolation", "start": 657, "end": 667}, - {"type": "interpolation_punctuation", "start": 657, "end": 659}, - {"type": "keyword", "start": 659, "end": 663}, - {"type": "punctuation", "start": 663, "end": 664}, - {"type": "interpolation_punctuation", "start": 666, "end": 667}, - {"type": "template_punctuation", "start": 667, "end": 668}, + {"type": "keyword", "start": 640, "end": 643}, + {"type": "operator", "start": 655, "end": 656}, {"type": "punctuation", "start": 668, "end": 669}, - {"type": "punctuation", "start": 672, "end": 673}, - {"type": "function_variable", "start": 677, "end": 692}, - {"type": "operator", "start": 693, "end": 694}, - {"type": "punctuation", "start": 695, "end": 696}, - {"type": "punctuation", "start": 696, "end": 697}, - {"type": "operator", "start": 698, "end": 700}, - {"type": "punctuation", "start": 701, "end": 702}, - {"type": "comment", "start": 706, "end": 715}, - {"type": "keyword", "start": 719, "end": 723}, - {"type": "punctuation", "start": 723, "end": 724}, - {"type": "function", "start": 724, "end": 739}, + {"type": "tag", "start": 670, "end": 679}, + {"type": "tag", "start": 670, "end": 678}, + {"type": "punctuation", "start": 670, "end": 672}, + {"type": "punctuation", "start": 678, "end": 679}, + {"type": "tag", "start": 681, "end": 685}, + {"type": "tag", "start": 681, "end": 684}, + {"type": "punctuation", "start": 681, "end": 682}, + {"type": "punctuation", "start": 684, "end": 685}, + {"type": "lang_ts", "start": 691, "end": 698}, + {"type": "punctuation", "start": 691, "end": 692}, + {"type": "constant", "start": 692, "end": 697}, + {"type": "punctuation", "start": 697, "end": 698}, + {"type": "tag", "start": 699, "end": 704}, + {"type": "tag", "start": 699, "end": 703}, + {"type": "punctuation", "start": 699, "end": 701}, + {"type": "punctuation", "start": 703, "end": 704}, + {"type": "each", "start": 706, "end": 737}, + {"type": "punctuation", "start": 706, "end": 707}, + {"type": "keyword", "start": 707, "end": 712}, + {"type": "lang_ts", "start": 713, "end": 724}, + {"type": "keyword", "start": 724, "end": 726}, + {"type": "lang_ts", "start": 727, "end": 731}, + {"type": "lang_ts", "start": 731, "end": 736}, + {"type": "punctuation", "start": 731, "end": 732}, + {"type": "punctuation", "start": 735, "end": 736}, + {"type": "punctuation", "start": 736, "end": 737}, + {"type": "lang_ts", "start": 739, "end": 762}, {"type": "punctuation", "start": 739, "end": 740}, - {"type": "punctuation", "start": 740, "end": 741}, - {"type": "punctuation", "start": 741, "end": 742}, - {"type": "comment", "start": 746, "end": 752}, - {"type": "punctuation", "start": 755, "end": 756}, + {"type": "keyword", "start": 741, "end": 746}, + {"type": "operator", "start": 749, "end": 750}, {"type": "punctuation", "start": 756, "end": 757}, - {"type": "function", "start": 761, "end": 776}, - {"type": "punctuation", "start": 776, "end": 777}, + {"type": "punctuation", "start": 760, "end": 761}, + {"type": "punctuation", "start": 761, "end": 762}, + {"type": "lang_ts", "start": 764, "end": 767}, + {"type": "punctuation", "start": 764, "end": 765}, + {"type": "punctuation", "start": 766, "end": 767}, + {"type": "each", "start": 768, "end": 775}, + {"type": "punctuation", "start": 768, "end": 769}, + {"type": "keyword", "start": 769, "end": 774}, + {"type": "punctuation", "start": 774, "end": 775}, + {"type": "lang_ts", "start": 777, "end": 784}, {"type": "punctuation", "start": 777, "end": 778}, - {"type": "punctuation", "start": 779, "end": 780}, - {"type": "special_keyword", "start": 784, "end": 789}, - {"type": "keyword", "start": 790, "end": 793}, - {"type": "class_name", "start": 794, "end": 799}, - {"type": "type_name", "start": 794, "end": 799}, - {"type": "punctuation", "start": 799, "end": 800}, - {"type": "template_string", "start": 800, "end": 816}, - {"type": "template_punctuation", "start": 800, "end": 801}, - {"type": "interpolation", "start": 801, "end": 811}, - {"type": "interpolation_punctuation", "start": 801, "end": 803}, - {"type": "keyword", "start": 803, "end": 807}, + {"type": "special_keyword", "start": 779, "end": 781}, + {"type": "punctuation", "start": 783, "end": 784}, + {"type": "tag", "start": 786, "end": 827}, + {"type": "tag", "start": 786, "end": 792}, + {"type": "punctuation", "start": 786, "end": 787}, + {"type": "attr_name", "start": 793, "end": 804}, + {"type": "attr_value", "start": 804, "end": 808}, + {"type": "punctuation", "start": 804, "end": 805}, + {"type": "punctuation", "start": 805, "end": 806}, {"type": "punctuation", "start": 807, "end": 808}, - {"type": "interpolation_punctuation", "start": 810, "end": 811}, - {"type": "string", "start": 811, "end": 815}, - {"type": "template_punctuation", "start": 815, "end": 816}, - {"type": "punctuation", "start": 816, "end": 817}, - {"type": "punctuation", "start": 817, "end": 818}, + {"type": "attr_name", "start": 809, "end": 821}, + {"type": "lang_ts", "start": 821, "end": 824}, {"type": "punctuation", "start": 821, "end": 822}, - {"type": "keyword", "start": 826, "end": 835}, - {"type": "function", "start": 836, "end": 852}, - {"type": "punctuation", "start": 852, "end": 853}, - {"type": "punctuation", "start": 853, "end": 854}, + {"type": "number", "start": 822, "end": 823}, + {"type": "punctuation", "start": 823, "end": 824}, + {"type": "punctuation", "start": 825, "end": 827}, + {"type": "lang_ts", "start": 828, "end": 835}, + {"type": "punctuation", "start": 828, "end": 829}, + {"type": "operator", "start": 829, "end": 830}, + {"type": "special_keyword", "start": 830, "end": 834}, + {"type": "punctuation", "start": 834, "end": 835}, + {"type": "tag", "start": 837, "end": 901}, + {"type": "tag", "start": 837, "end": 843}, + {"type": "punctuation", "start": 837, "end": 838}, + {"type": "attr_name", "start": 844, "end": 855}, + {"type": "attr_value", "start": 855, "end": 859}, {"type": "punctuation", "start": 855, "end": 856}, - {"type": "builtin", "start": 860, "end": 867}, - {"type": "punctuation", "start": 867, "end": 868}, - {"type": "function", "start": 868, "end": 871}, - {"type": "punctuation", "start": 871, "end": 872}, - {"type": "keyword", "start": 872, "end": 875}, - {"type": "class_name", "start": 876, "end": 880}, - {"type": "type_name", "start": 876, "end": 880}, - {"type": "punctuation", "start": 880, "end": 881}, - {"type": "number", "start": 881, "end": 884}, + {"type": "punctuation", "start": 856, "end": 857}, + {"type": "punctuation", "start": 858, "end": 859}, + {"type": "attr_name", "start": 860, "end": 872}, + {"type": "lang_ts", "start": 872, "end": 875}, + {"type": "punctuation", "start": 872, "end": 873}, + {"type": "number", "start": 873, "end": 874}, + {"type": "punctuation", "start": 874, "end": 875}, + {"type": "attr_name", "start": 876, "end": 884}, + {"type": "lang_ts", "start": 884, "end": 900}, {"type": "punctuation", "start": 884, "end": 885}, {"type": "punctuation", "start": 885, "end": 886}, {"type": "punctuation", "start": 886, "end": 887}, - {"type": "comment", "start": 888, "end": 921}, - {"type": "punctuation", "start": 924, "end": 925}, - {"type": "punctuation", "start": 927, "end": 928}, - {"type": "comment", "start": 931, "end": 941}, - {"type": "comment", "start": 944, "end": 990}, - {"type": "comment", "start": 993, "end": 1019}, - {"type": "special_keyword", "start": 1022, "end": 1028}, - {"type": "keyword", "start": 1029, "end": 1038}, - {"type": "class_name", "start": 1039, "end": 1045}, - {"type": "type_name", "start": 1039, "end": 1045}, - {"type": "punctuation", "start": 1046, "end": 1047}, - {"type": "operator", "start": 1054, "end": 1055}, - {"type": "builtin", "start": 1056, "end": 1062}, - {"type": "punctuation", "start": 1062, "end": 1063}, - {"type": "operator", "start": 1069, "end": 1070}, - {"type": "builtin", "start": 1071, "end": 1077}, - {"type": "punctuation", "start": 1077, "end": 1078}, - {"type": "punctuation", "start": 1080, "end": 1081}, - {"type": "special_keyword", "start": 1084, "end": 1090}, - {"type": "keyword", "start": 1091, "end": 1096}, - {"type": "type_annotation", "start": 1103, "end": 1112}, - {"type": ":", "start": 1103, "end": 1104}, - {"type": "type", "start": 1104, "end": 1112}, - {"type": "type_name", "start": 1105, "end": 1111}, - {"type": "operator", "start": 1112, "end": 1113}, - {"type": "punctuation", "start": 1114, "end": 1115}, - {"type": "operator", "start": 1119, "end": 1120}, - {"type": "string", "start": 1121, "end": 1128}, - {"type": "punctuation", "start": 1128, "end": 1129}, - {"type": "operator", "start": 1133, "end": 1134}, - {"type": "number", "start": 1135, "end": 1138}, - {"type": "punctuation", "start": 1138, "end": 1139}, - {"type": "punctuation", "start": 1139, "end": 1140}, - {"type": "special_keyword", "start": 1143, "end": 1149}, - {"type": "keyword", "start": 1150, "end": 1158}, - {"type": "function", "start": 1159, "end": 1162}, - {"type": "punctuation", "start": 1162, "end": 1163}, - {"type": "operator", "start": 1164, "end": 1165}, - {"type": "builtin", "start": 1166, "end": 1172}, + {"type": "operator", "start": 888, "end": 890}, + {"type": "punctuation", "start": 891, "end": 892}, + {"type": "operator", "start": 894, "end": 895}, + {"type": "operator", "start": 896, "end": 897}, + {"type": "punctuation", "start": 898, "end": 899}, + {"type": "punctuation", "start": 899, "end": 900}, + {"type": "punctuation", "start": 900, "end": 901}, + {"type": "lang_ts", "start": 904, "end": 924}, + {"type": "punctuation", "start": 904, "end": 905}, + {"type": "decorator", "start": 905, "end": 912}, + {"type": "at", "start": 905, "end": 906}, + {"type": "function", "start": 906, "end": 912}, + {"type": "function", "start": 913, "end": 921}, + {"type": "punctuation", "start": 921, "end": 922}, + {"type": "punctuation", "start": 922, "end": 923}, + {"type": "punctuation", "start": 923, "end": 924}, + {"type": "tag", "start": 926, "end": 934}, + {"type": "tag", "start": 926, "end": 933}, + {"type": "punctuation", "start": 926, "end": 928}, + {"type": "punctuation", "start": 933, "end": 934}, + {"type": "lang_ts", "start": 935, "end": 940}, + {"type": "punctuation", "start": 935, "end": 936}, + {"type": "operator", "start": 936, "end": 937}, + {"type": "special_keyword", "start": 937, "end": 939}, + {"type": "punctuation", "start": 939, "end": 940}, + {"type": "tag", "start": 950, "end": 958}, + {"type": "tag", "start": 950, "end": 957}, + {"type": "punctuation", "start": 950, "end": 951}, + {"type": "punctuation", "start": 957, "end": 958}, + {"type": "tag", "start": 966, "end": 975}, + {"type": "tag", "start": 966, "end": 974}, + {"type": "punctuation", "start": 966, "end": 968}, + {"type": "punctuation", "start": 974, "end": 975}, + {"type": "tag", "start": 979, "end": 1011}, + {"type": "tag", "start": 979, "end": 985}, + {"type": "punctuation", "start": 979, "end": 980}, + {"type": "attr_name", "start": 986, "end": 996}, + {"type": "namespace", "start": 986, "end": 991}, + {"type": "attr_name", "start": 997, "end": 1001}, + {"type": "attr_value", "start": 1001, "end": 1008}, + {"type": "punctuation", "start": 1001, "end": 1002}, + {"type": "punctuation", "start": 1002, "end": 1003}, + {"type": "punctuation", "start": 1007, "end": 1008}, + {"type": "punctuation", "start": 1009, "end": 1011}, + {"type": "tag", "start": 1013, "end": 1093}, + {"type": "tag", "start": 1013, "end": 1017}, + {"type": "punctuation", "start": 1013, "end": 1014}, + {"type": "attr_name", "start": 1018, "end": 1028}, + {"type": "namespace", "start": 1018, "end": 1023}, + {"type": "lang_ts", "start": 1028, "end": 1041}, + {"type": "punctuation", "start": 1028, "end": 1029}, + {"type": "punctuation", "start": 1040, "end": 1041}, + {"type": "attr_name", "start": 1042, "end": 1055}, + {"type": "namespace", "start": 1042, "end": 1048}, + {"type": "lang_ts", "start": 1055, "end": 1058}, + {"type": "punctuation", "start": 1055, "end": 1056}, + {"type": "punctuation", "start": 1057, "end": 1058}, + {"type": "lang_ts", "start": 1059, "end": 1092}, + {"type": "punctuation", "start": 1059, "end": 1060}, + {"type": "decorator", "start": 1060, "end": 1067}, + {"type": "at", "start": 1060, "end": 1061}, + {"type": "function", "start": 1061, "end": 1067}, + {"type": "function", "start": 1068, "end": 1078}, + {"type": "punctuation", "start": 1078, "end": 1079}, + {"type": "string", "start": 1079, "end": 1086}, + {"type": "punctuation", "start": 1086, "end": 1087}, + {"type": "number", "start": 1088, "end": 1090}, + {"type": "punctuation", "start": 1090, "end": 1091}, + {"type": "punctuation", "start": 1091, "end": 1092}, + {"type": "punctuation", "start": 1092, "end": 1093}, + {"type": "tag", "start": 1115, "end": 1121}, + {"type": "tag", "start": 1115, "end": 1120}, + {"type": "punctuation", "start": 1115, "end": 1117}, + {"type": "punctuation", "start": 1120, "end": 1121}, + {"type": "lang_ts", "start": 1123, "end": 1145}, + {"type": "punctuation", "start": 1123, "end": 1124}, + {"type": "decorator", "start": 1124, "end": 1131}, + {"type": "at", "start": 1124, "end": 1125}, + {"type": "function", "start": 1125, "end": 1131}, + {"type": "function", "start": 1132, "end": 1142}, + {"type": "punctuation", "start": 1142, "end": 1143}, + {"type": "punctuation", "start": 1143, "end": 1144}, + {"type": "punctuation", "start": 1144, "end": 1145}, + {"type": "lang_ts", "start": 1147, "end": 1170}, + {"type": "punctuation", "start": 1147, "end": 1148}, + {"type": "function", "start": 1157, "end": 1167}, + {"type": "punctuation", "start": 1167, "end": 1168}, + {"type": "punctuation", "start": 1168, "end": 1169}, + {"type": "punctuation", "start": 1169, "end": 1170}, + {"type": "tag", "start": 1172, "end": 1190}, + {"type": "tag", "start": 1172, "end": 1179}, {"type": "punctuation", "start": 1172, "end": 1173}, - {"type": "operator", "start": 1175, "end": 1176}, - {"type": "builtin", "start": 1177, "end": 1183}, - {"type": "punctuation", "start": 1183, "end": 1184}, - {"type": "operator", "start": 1184, "end": 1185}, - {"type": "builtin", "start": 1186, "end": 1192}, - {"type": "punctuation", "start": 1193, "end": 1194}, - {"type": "special_keyword", "start": 1197, "end": 1203}, - {"type": "operator", "start": 1206, "end": 1207}, - {"type": "punctuation", "start": 1209, "end": 1210}, - {"type": "punctuation", "start": 1212, "end": 1213}, - {"type": "special_keyword", "start": 1216, "end": 1222}, - {"type": "keyword", "start": 1223, "end": 1228}, - {"type": "function_variable", "start": 1229, "end": 1233}, - {"type": "operator", "start": 1234, "end": 1235}, + {"type": "lang_ts", "start": 1180, "end": 1189}, + {"type": "punctuation", "start": 1180, "end": 1181}, + {"type": "punctuation", "start": 1188, "end": 1189}, + {"type": "punctuation", "start": 1189, "end": 1190}, + {"type": "tag", "start": 1203, "end": 1212}, + {"type": "tag", "start": 1203, "end": 1211}, + {"type": "punctuation", "start": 1203, "end": 1205}, + {"type": "punctuation", "start": 1211, "end": 1212}, + {"type": "lang_ts", "start": 1213, "end": 1223}, + {"type": "punctuation", "start": 1213, "end": 1214}, + {"type": "operator", "start": 1214, "end": 1215}, + {"type": "punctuation", "start": 1222, "end": 1223}, + {"type": "tag", "start": 1225, "end": 1266}, + {"type": "tag", "start": 1225, "end": 1229}, + {"type": "punctuation", "start": 1225, "end": 1226}, + {"type": "attr_name", "start": 1230, "end": 1235}, + {"type": "attr_value", "start": 1235, "end": 1250}, + {"type": "punctuation", "start": 1235, "end": 1236}, {"type": "punctuation", "start": 1236, "end": 1237}, - {"type": "operator", "start": 1238, "end": 1239}, - {"type": "builtin", "start": 1240, "end": 1243}, - {"type": "punctuation", "start": 1243, "end": 1244}, - {"type": "operator", "start": 1246, "end": 1247}, - {"type": "builtin", "start": 1248, "end": 1251}, - {"type": "punctuation", "start": 1251, "end": 1252}, - {"type": "type_annotation", "start": 1252, "end": 1258}, - {"type": ":", "start": 1252, "end": 1253}, - {"type": "type", "start": 1253, "end": 1258}, - {"type": "builtin", "start": 1254, "end": 1257}, - {"type": "operator", "start": 1258, "end": 1260}, - {"type": "operator", "start": 1263, "end": 1264}, - {"type": "punctuation", "start": 1266, "end": 1267}, - {"type": "tag", "start": 1268, "end": 1277}, - {"type": "tag", "start": 1268, "end": 1276}, - {"type": "punctuation", "start": 1268, "end": 1270}, - {"type": "punctuation", "start": 1276, "end": 1277}, - {"type": "tag", "start": 1279, "end": 1283}, - {"type": "tag", "start": 1279, "end": 1282}, - {"type": "punctuation", "start": 1279, "end": 1280}, - {"type": "punctuation", "start": 1282, "end": 1283}, - {"type": "lang_ts", "start": 1289, "end": 1296}, - {"type": "punctuation", "start": 1289, "end": 1290}, - {"type": "constant", "start": 1290, "end": 1295}, - {"type": "punctuation", "start": 1295, "end": 1296}, - {"type": "tag", "start": 1297, "end": 1302}, - {"type": "tag", "start": 1297, "end": 1301}, - {"type": "punctuation", "start": 1297, "end": 1299}, - {"type": "punctuation", "start": 1301, "end": 1302}, - {"type": "each", "start": 1304, "end": 1335}, + {"type": "punctuation", "start": 1249, "end": 1250}, + {"type": "attr_name", "start": 1251, "end": 1253}, + {"type": "attr_value", "start": 1253, "end": 1265}, + {"type": "punctuation", "start": 1253, "end": 1254}, + {"type": "punctuation", "start": 1254, "end": 1255}, + {"type": "punctuation", "start": 1264, "end": 1265}, + {"type": "punctuation", "start": 1265, "end": 1266}, + {"type": "tag", "start": 1268, "end": 1271}, + {"type": "tag", "start": 1268, "end": 1270}, + {"type": "punctuation", "start": 1268, "end": 1269}, + {"type": "punctuation", "start": 1270, "end": 1271}, + {"type": "tag", "start": 1283, "end": 1287}, + {"type": "tag", "start": 1283, "end": 1286}, + {"type": "punctuation", "start": 1283, "end": 1285}, + {"type": "punctuation", "start": 1286, "end": 1287}, + {"type": "tag", "start": 1288, "end": 1294}, + {"type": "tag", "start": 1288, "end": 1293}, + {"type": "punctuation", "start": 1288, "end": 1290}, + {"type": "punctuation", "start": 1293, "end": 1294}, + {"type": "tag", "start": 1296, "end": 1330}, + {"type": "tag", "start": 1296, "end": 1298}, + {"type": "punctuation", "start": 1296, "end": 1297}, + {"type": "attr_name", "start": 1299, "end": 1304}, + {"type": "attr_value", "start": 1304, "end": 1329}, {"type": "punctuation", "start": 1304, "end": 1305}, - {"type": "keyword", "start": 1305, "end": 1310}, - {"type": "lang_ts", "start": 1311, "end": 1322}, - {"type": "keyword", "start": 1322, "end": 1324}, - {"type": "lang_ts", "start": 1325, "end": 1329}, - {"type": "lang_ts", "start": 1329, "end": 1334}, + {"type": "punctuation", "start": 1305, "end": 1306}, + {"type": "punctuation", "start": 1328, "end": 1329}, {"type": "punctuation", "start": 1329, "end": 1330}, - {"type": "punctuation", "start": 1333, "end": 1334}, - {"type": "punctuation", "start": 1334, "end": 1335}, - {"type": "lang_ts", "start": 1337, "end": 1364}, + {"type": "tag", "start": 1337, "end": 1357}, + {"type": "tag", "start": 1337, "end": 1342}, {"type": "punctuation", "start": 1337, "end": 1338}, - {"type": "keyword", "start": 1339, "end": 1344}, - {"type": "operator", "start": 1351, "end": 1352}, - {"type": "punctuation", "start": 1358, "end": 1359}, - {"type": "punctuation", "start": 1362, "end": 1363}, - {"type": "punctuation", "start": 1363, "end": 1364}, - {"type": "lang_ts", "start": 1366, "end": 1373}, - {"type": "punctuation", "start": 1366, "end": 1367}, + {"type": "attr_name", "start": 1343, "end": 1348}, + {"type": "attr_value", "start": 1348, "end": 1356}, + {"type": "punctuation", "start": 1348, "end": 1349}, + {"type": "punctuation", "start": 1349, "end": 1350}, + {"type": "punctuation", "start": 1355, "end": 1356}, + {"type": "punctuation", "start": 1356, "end": 1357}, + {"type": "tag", "start": 1361, "end": 1368}, + {"type": "tag", "start": 1361, "end": 1367}, + {"type": "punctuation", "start": 1361, "end": 1363}, + {"type": "punctuation", "start": 1367, "end": 1368}, + {"type": "tag", "start": 1369, "end": 1373}, + {"type": "tag", "start": 1369, "end": 1372}, + {"type": "punctuation", "start": 1369, "end": 1371}, {"type": "punctuation", "start": 1372, "end": 1373}, - {"type": "each", "start": 1374, "end": 1381}, - {"type": "punctuation", "start": 1374, "end": 1375}, - {"type": "keyword", "start": 1375, "end": 1380}, - {"type": "punctuation", "start": 1380, "end": 1381}, - {"type": "lang_ts", "start": 1383, "end": 1390}, - {"type": "punctuation", "start": 1383, "end": 1384}, - {"type": "special_keyword", "start": 1385, "end": 1387}, - {"type": "punctuation", "start": 1389, "end": 1390}, - {"type": "tag", "start": 1392, "end": 1433}, - {"type": "tag", "start": 1392, "end": 1398}, - {"type": "punctuation", "start": 1392, "end": 1393}, - {"type": "attr_name", "start": 1399, "end": 1410}, - {"type": "attr_value", "start": 1410, "end": 1414}, - {"type": "punctuation", "start": 1410, "end": 1411}, - {"type": "punctuation", "start": 1411, "end": 1412}, - {"type": "punctuation", "start": 1413, "end": 1414}, - {"type": "attr_name", "start": 1415, "end": 1427}, - {"type": "lang_ts", "start": 1427, "end": 1430}, - {"type": "punctuation", "start": 1427, "end": 1428}, - {"type": "number", "start": 1428, "end": 1429}, - {"type": "punctuation", "start": 1429, "end": 1430}, - {"type": "punctuation", "start": 1431, "end": 1433}, - {"type": "lang_ts", "start": 1434, "end": 1441}, - {"type": "punctuation", "start": 1434, "end": 1435}, - {"type": "operator", "start": 1435, "end": 1436}, - {"type": "special_keyword", "start": 1436, "end": 1440}, - {"type": "punctuation", "start": 1440, "end": 1441}, - {"type": "tag", "start": 1443, "end": 1507}, - {"type": "tag", "start": 1443, "end": 1449}, - {"type": "punctuation", "start": 1443, "end": 1444}, - {"type": "attr_name", "start": 1450, "end": 1461}, - {"type": "attr_value", "start": 1461, "end": 1465}, - {"type": "punctuation", "start": 1461, "end": 1462}, - {"type": "punctuation", "start": 1462, "end": 1463}, - {"type": "punctuation", "start": 1464, "end": 1465}, - {"type": "attr_name", "start": 1466, "end": 1478}, - {"type": "lang_ts", "start": 1478, "end": 1481}, - {"type": "punctuation", "start": 1478, "end": 1479}, - {"type": "number", "start": 1479, "end": 1480}, - {"type": "punctuation", "start": 1480, "end": 1481}, - {"type": "attr_name", "start": 1482, "end": 1490}, - {"type": "lang_ts", "start": 1490, "end": 1506}, + {"type": "tag", "start": 1375, "end": 1406}, + {"type": "tag", "start": 1375, "end": 1382}, + {"type": "punctuation", "start": 1375, "end": 1376}, + {"type": "attr_name", "start": 1383, "end": 1387}, + {"type": "attr_value", "start": 1387, "end": 1396}, + {"type": "punctuation", "start": 1387, "end": 1388}, + {"type": "punctuation", "start": 1388, "end": 1389}, + {"type": "punctuation", "start": 1395, "end": 1396}, + {"type": "attr_name", "start": 1397, "end": 1405}, + {"type": "punctuation", "start": 1405, "end": 1406}, + {"type": "tag", "start": 1416, "end": 1425}, + {"type": "tag", "start": 1416, "end": 1424}, + {"type": "punctuation", "start": 1416, "end": 1418}, + {"type": "punctuation", "start": 1424, "end": 1425}, + {"type": "comment", "start": 1427, "end": 1464}, + {"type": "lang_ts", "start": 1465, "end": 1468}, + {"type": "punctuation", "start": 1465, "end": 1466}, + {"type": "punctuation", "start": 1467, "end": 1468}, + {"type": "lang_ts", "start": 1469, "end": 1472}, + {"type": "punctuation", "start": 1469, "end": 1470}, + {"type": "punctuation", "start": 1471, "end": 1472}, + {"type": "lang_ts", "start": 1473, "end": 1480}, + {"type": "punctuation", "start": 1473, "end": 1474}, + {"type": "punctuation", "start": 1479, "end": 1480}, + {"type": "tag", "start": 1482, "end": 1488}, + {"type": "tag", "start": 1482, "end": 1485}, + {"type": "punctuation", "start": 1482, "end": 1483}, + {"type": "punctuation", "start": 1486, "end": 1488}, + {"type": "tag", "start": 1490, "end": 1496}, + {"type": "tag", "start": 1490, "end": 1493}, {"type": "punctuation", "start": 1490, "end": 1491}, - {"type": "punctuation", "start": 1491, "end": 1492}, - {"type": "punctuation", "start": 1492, "end": 1493}, - {"type": "operator", "start": 1494, "end": 1496}, - {"type": "punctuation", "start": 1497, "end": 1498}, - {"type": "operator", "start": 1500, "end": 1501}, - {"type": "operator", "start": 1502, "end": 1503}, - {"type": "punctuation", "start": 1504, "end": 1505}, - {"type": "punctuation", "start": 1505, "end": 1506}, + {"type": "punctuation", "start": 1494, "end": 1496}, + {"type": "tag", "start": 1498, "end": 1534}, + {"type": "tag", "start": 1498, "end": 1502}, + {"type": "punctuation", "start": 1498, "end": 1499}, + {"type": "attr_name", "start": 1503, "end": 1506}, + {"type": "attr_value", "start": 1506, "end": 1518}, {"type": "punctuation", "start": 1506, "end": 1507}, - {"type": "lang_ts", "start": 1510, "end": 1530}, - {"type": "punctuation", "start": 1510, "end": 1511}, - {"type": "decorator", "start": 1511, "end": 1518}, - {"type": "at", "start": 1511, "end": 1512}, - {"type": "function", "start": 1512, "end": 1518}, - {"type": "function", "start": 1519, "end": 1527}, - {"type": "punctuation", "start": 1527, "end": 1528}, - {"type": "punctuation", "start": 1528, "end": 1529}, - {"type": "punctuation", "start": 1529, "end": 1530}, - {"type": "tag", "start": 1532, "end": 1540}, - {"type": "tag", "start": 1532, "end": 1539}, + {"type": "punctuation", "start": 1507, "end": 1508}, + {"type": "punctuation", "start": 1517, "end": 1518}, + {"type": "attr_name", "start": 1519, "end": 1522}, + {"type": "attr_value", "start": 1522, "end": 1531}, + {"type": "punctuation", "start": 1522, "end": 1523}, + {"type": "punctuation", "start": 1523, "end": 1524}, + {"type": "punctuation", "start": 1530, "end": 1531}, {"type": "punctuation", "start": 1532, "end": 1534}, + {"type": "tag", "start": 1536, "end": 1540}, + {"type": "tag", "start": 1536, "end": 1539}, + {"type": "punctuation", "start": 1536, "end": 1537}, {"type": "punctuation", "start": 1539, "end": 1540}, - {"type": "lang_ts", "start": 1541, "end": 1546}, - {"type": "punctuation", "start": 1541, "end": 1542}, - {"type": "operator", "start": 1542, "end": 1543}, - {"type": "special_keyword", "start": 1543, "end": 1545}, + {"type": "tag", "start": 1542, "end": 1546}, + {"type": "tag", "start": 1542, "end": 1545}, + {"type": "punctuation", "start": 1542, "end": 1543}, {"type": "punctuation", "start": 1545, "end": 1546}, - {"type": "doctype", "start": 1548, "end": 1563}, - {"type": "tag", "start": 1565, "end": 1606}, - {"type": "tag", "start": 1565, "end": 1569}, - {"type": "punctuation", "start": 1565, "end": 1566}, - {"type": "attr_name", "start": 1570, "end": 1575}, - {"type": "attr_value", "start": 1575, "end": 1590}, - {"type": "punctuation", "start": 1575, "end": 1576}, - {"type": "punctuation", "start": 1576, "end": 1577}, + {"type": "tag", "start": 1557, "end": 1562}, + {"type": "tag", "start": 1557, "end": 1561}, + {"type": "punctuation", "start": 1557, "end": 1559}, + {"type": "punctuation", "start": 1561, "end": 1562}, + {"type": "tag", "start": 1564, "end": 1568}, + {"type": "tag", "start": 1564, "end": 1567}, + {"type": "punctuation", "start": 1564, "end": 1565}, + {"type": "punctuation", "start": 1567, "end": 1568}, + {"type": "tag", "start": 1579, "end": 1584}, + {"type": "tag", "start": 1579, "end": 1583}, + {"type": "punctuation", "start": 1579, "end": 1581}, + {"type": "punctuation", "start": 1583, "end": 1584}, + {"type": "tag", "start": 1585, "end": 1590}, + {"type": "tag", "start": 1585, "end": 1589}, + {"type": "punctuation", "start": 1585, "end": 1587}, {"type": "punctuation", "start": 1589, "end": 1590}, - {"type": "attr_name", "start": 1591, "end": 1593}, - {"type": "attr_value", "start": 1593, "end": 1605}, - {"type": "punctuation", "start": 1593, "end": 1594}, - {"type": "punctuation", "start": 1594, "end": 1595}, - {"type": "punctuation", "start": 1604, "end": 1605}, - {"type": "punctuation", "start": 1605, "end": 1606}, - {"type": "tag", "start": 1608, "end": 1611}, - {"type": "tag", "start": 1608, "end": 1610}, - {"type": "punctuation", "start": 1608, "end": 1609}, - {"type": "punctuation", "start": 1610, "end": 1611}, - {"type": "tag", "start": 1623, "end": 1627}, - {"type": "tag", "start": 1623, "end": 1626}, - {"type": "punctuation", "start": 1623, "end": 1625}, - {"type": "punctuation", "start": 1626, "end": 1627}, - {"type": "tag", "start": 1628, "end": 1634}, - {"type": "tag", "start": 1628, "end": 1633}, - {"type": "punctuation", "start": 1628, "end": 1630}, - {"type": "punctuation", "start": 1633, "end": 1634}, - {"type": "tag", "start": 1636, "end": 1670}, - {"type": "tag", "start": 1636, "end": 1638}, + {"type": "comment", "start": 1592, "end": 1635}, + {"type": "tag", "start": 1636, "end": 1641}, + {"type": "tag", "start": 1636, "end": 1640}, {"type": "punctuation", "start": 1636, "end": 1637}, - {"type": "attr_name", "start": 1639, "end": 1644}, - {"type": "attr_value", "start": 1644, "end": 1669}, - {"type": "punctuation", "start": 1644, "end": 1645}, - {"type": "punctuation", "start": 1645, "end": 1646}, - {"type": "punctuation", "start": 1668, "end": 1669}, - {"type": "punctuation", "start": 1669, "end": 1670}, - {"type": "tag", "start": 1677, "end": 1697}, - {"type": "tag", "start": 1677, "end": 1682}, - {"type": "punctuation", "start": 1677, "end": 1678}, - {"type": "attr_name", "start": 1683, "end": 1688}, - {"type": "attr_value", "start": 1688, "end": 1696}, - {"type": "punctuation", "start": 1688, "end": 1689}, - {"type": "punctuation", "start": 1689, "end": 1690}, - {"type": "punctuation", "start": 1695, "end": 1696}, - {"type": "punctuation", "start": 1696, "end": 1697}, - {"type": "tag", "start": 1701, "end": 1708}, - {"type": "tag", "start": 1701, "end": 1707}, - {"type": "punctuation", "start": 1701, "end": 1703}, - {"type": "punctuation", "start": 1707, "end": 1708}, - {"type": "tag", "start": 1709, "end": 1713}, - {"type": "tag", "start": 1709, "end": 1712}, - {"type": "punctuation", "start": 1709, "end": 1711}, - {"type": "punctuation", "start": 1712, "end": 1713}, - {"type": "tag", "start": 1715, "end": 1746}, - {"type": "tag", "start": 1715, "end": 1722}, - {"type": "punctuation", "start": 1715, "end": 1716}, - {"type": "attr_name", "start": 1723, "end": 1727}, - {"type": "attr_value", "start": 1727, "end": 1736}, - {"type": "punctuation", "start": 1727, "end": 1728}, + {"type": "punctuation", "start": 1640, "end": 1641}, + {"type": "tag", "start": 1643, "end": 1651}, + {"type": "tag", "start": 1643, "end": 1650}, + {"type": "punctuation", "start": 1643, "end": 1644}, + {"type": "punctuation", "start": 1650, "end": 1651}, + {"type": "script", "start": 1651, "end": 1689}, + {"type": "lang_ts", "start": 1651, "end": 1689}, + {"type": "keyword", "start": 1654, "end": 1659}, + {"type": "operator", "start": 1670, "end": 1671}, + {"type": "string", "start": 1672, "end": 1686}, + {"type": "punctuation", "start": 1686, "end": 1687}, + {"type": "tag", "start": 1689, "end": 1698}, + {"type": "tag", "start": 1689, "end": 1697}, + {"type": "punctuation", "start": 1689, "end": 1691}, + {"type": "punctuation", "start": 1697, "end": 1698}, + {"type": "tag", "start": 1700, "end": 1707}, + {"type": "tag", "start": 1700, "end": 1706}, + {"type": "punctuation", "start": 1700, "end": 1701}, + {"type": "punctuation", "start": 1706, "end": 1707}, + {"type": "style", "start": 1707, "end": 1741}, + {"type": "lang_css", "start": 1707, "end": 1741}, + {"type": "selector", "start": 1710, "end": 1717}, + {"type": "punctuation", "start": 1718, "end": 1719}, + {"type": "property", "start": 1723, "end": 1728}, {"type": "punctuation", "start": 1728, "end": 1729}, - {"type": "punctuation", "start": 1735, "end": 1736}, - {"type": "attr_name", "start": 1737, "end": 1745}, - {"type": "punctuation", "start": 1745, "end": 1746}, - {"type": "tag", "start": 1756, "end": 1765}, - {"type": "tag", "start": 1756, "end": 1764}, - {"type": "punctuation", "start": 1756, "end": 1758}, + {"type": "punctuation", "start": 1734, "end": 1735}, + {"type": "punctuation", "start": 1738, "end": 1739}, + {"type": "tag", "start": 1741, "end": 1749}, + {"type": "tag", "start": 1741, "end": 1748}, + {"type": "punctuation", "start": 1741, "end": 1743}, + {"type": "punctuation", "start": 1748, "end": 1749}, + {"type": "tag", "start": 1750, "end": 1756}, + {"type": "tag", "start": 1750, "end": 1755}, + {"type": "punctuation", "start": 1750, "end": 1752}, + {"type": "punctuation", "start": 1755, "end": 1756}, + {"type": "tag", "start": 1758, "end": 1765}, + {"type": "tag", "start": 1758, "end": 1764}, + {"type": "punctuation", "start": 1758, "end": 1759}, {"type": "punctuation", "start": 1764, "end": 1765}, - {"type": "comment", "start": 1767, "end": 1804}, - {"type": "lang_ts", "start": 1805, "end": 1808}, - {"type": "punctuation", "start": 1805, "end": 1806}, - {"type": "punctuation", "start": 1807, "end": 1808}, - {"type": "lang_ts", "start": 1809, "end": 1812}, - {"type": "punctuation", "start": 1809, "end": 1810}, - {"type": "punctuation", "start": 1811, "end": 1812}, - {"type": "lang_ts", "start": 1813, "end": 1820}, + {"type": "style", "start": 1765, "end": 2146}, + {"type": "lang_css", "start": 1765, "end": 2146}, + {"type": "selector", "start": 1767, "end": 1778}, + {"type": "punctuation", "start": 1779, "end": 1780}, + {"type": "property", "start": 1783, "end": 1788}, + {"type": "punctuation", "start": 1788, "end": 1789}, + {"type": "punctuation", "start": 1793, "end": 1794}, + {"type": "punctuation", "start": 1796, "end": 1797}, + {"type": "selector", "start": 1800, "end": 1812}, {"type": "punctuation", "start": 1813, "end": 1814}, - {"type": "punctuation", "start": 1819, "end": 1820}, - {"type": "lang_ts", "start": 1821, "end": 1824}, - {"type": "punctuation", "start": 1821, "end": 1822}, - {"type": "constant", "start": 1822, "end": 1823}, - {"type": "punctuation", "start": 1823, "end": 1824}, - {"type": "tag", "start": 1826, "end": 1832}, - {"type": "tag", "start": 1826, "end": 1829}, + {"type": "property", "start": 1817, "end": 1826}, {"type": "punctuation", "start": 1826, "end": 1827}, - {"type": "punctuation", "start": 1830, "end": 1832}, - {"type": "tag", "start": 1834, "end": 1840}, - {"type": "tag", "start": 1834, "end": 1837}, - {"type": "punctuation", "start": 1834, "end": 1835}, - {"type": "punctuation", "start": 1838, "end": 1840}, - {"type": "tag", "start": 1842, "end": 1878}, - {"type": "tag", "start": 1842, "end": 1846}, - {"type": "punctuation", "start": 1842, "end": 1843}, - {"type": "attr_name", "start": 1847, "end": 1850}, - {"type": "attr_value", "start": 1850, "end": 1862}, - {"type": "punctuation", "start": 1850, "end": 1851}, - {"type": "punctuation", "start": 1851, "end": 1852}, - {"type": "punctuation", "start": 1861, "end": 1862}, - {"type": "attr_name", "start": 1863, "end": 1866}, - {"type": "attr_value", "start": 1866, "end": 1875}, - {"type": "punctuation", "start": 1866, "end": 1867}, - {"type": "punctuation", "start": 1867, "end": 1868}, - {"type": "punctuation", "start": 1874, "end": 1875}, - {"type": "punctuation", "start": 1876, "end": 1878}, - {"type": "tag", "start": 1880, "end": 1884}, - {"type": "tag", "start": 1880, "end": 1883}, - {"type": "punctuation", "start": 1880, "end": 1881}, + {"type": "punctuation", "start": 1832, "end": 1833}, + {"type": "punctuation", "start": 1835, "end": 1836}, + {"type": "selector", "start": 1839, "end": 1840}, + {"type": "punctuation", "start": 1841, "end": 1842}, + {"type": "property", "start": 1845, "end": 1855}, + {"type": "punctuation", "start": 1855, "end": 1856}, + {"type": "function", "start": 1866, "end": 1870}, + {"type": "punctuation", "start": 1870, "end": 1871}, + {"type": "punctuation", "start": 1872, "end": 1873}, + {"type": "punctuation", "start": 1875, "end": 1876}, + {"type": "punctuation", "start": 1878, "end": 1879}, {"type": "punctuation", "start": 1883, "end": 1884}, - {"type": "tag", "start": 1886, "end": 1890}, - {"type": "tag", "start": 1886, "end": 1889}, - {"type": "punctuation", "start": 1886, "end": 1887}, - {"type": "punctuation", "start": 1889, "end": 1890}, - {"type": "tag", "start": 1901, "end": 1906}, - {"type": "tag", "start": 1901, "end": 1905}, - {"type": "punctuation", "start": 1901, "end": 1903}, - {"type": "punctuation", "start": 1905, "end": 1906}, - {"type": "tag", "start": 1908, "end": 1912}, - {"type": "tag", "start": 1908, "end": 1911}, - {"type": "punctuation", "start": 1908, "end": 1909}, - {"type": "punctuation", "start": 1911, "end": 1912}, - {"type": "tag", "start": 1923, "end": 1928}, - {"type": "tag", "start": 1923, "end": 1927}, - {"type": "punctuation", "start": 1923, "end": 1925}, - {"type": "punctuation", "start": 1927, "end": 1928}, - {"type": "tag", "start": 1929, "end": 1934}, - {"type": "tag", "start": 1929, "end": 1933}, - {"type": "punctuation", "start": 1929, "end": 1931}, - {"type": "punctuation", "start": 1933, "end": 1934}, - {"type": "tag", "start": 1936, "end": 1943}, - {"type": "tag", "start": 1936, "end": 1942}, - {"type": "punctuation", "start": 1936, "end": 1937}, - {"type": "punctuation", "start": 1942, "end": 1943}, - {"type": "style", "start": 1943, "end": 2324}, - {"type": "lang_css", "start": 1943, "end": 2324}, - {"type": "selector", "start": 1945, "end": 1956}, - {"type": "punctuation", "start": 1957, "end": 1958}, - {"type": "property", "start": 1961, "end": 1966}, - {"type": "punctuation", "start": 1966, "end": 1967}, - {"type": "punctuation", "start": 1971, "end": 1972}, - {"type": "punctuation", "start": 1974, "end": 1975}, - {"type": "selector", "start": 1978, "end": 1990}, - {"type": "punctuation", "start": 1991, "end": 1992}, - {"type": "property", "start": 1995, "end": 2004}, + {"type": "punctuation", "start": 1884, "end": 1885}, + {"type": "punctuation", "start": 1887, "end": 1888}, + {"type": "comment", "start": 1891, "end": 1904}, + {"type": "comment", "start": 1907, "end": 1939}, + {"type": "selector", "start": 1942, "end": 1952}, + {"type": "punctuation", "start": 1953, "end": 1954}, + {"type": "property", "start": 1957, "end": 1973}, + {"type": "punctuation", "start": 1973, "end": 1974}, + {"type": "punctuation", "start": 1979, "end": 1980}, + {"type": "punctuation", "start": 1982, "end": 1983}, + {"type": "selector", "start": 1986, "end": 1993}, + {"type": "punctuation", "start": 1994, "end": 1995}, + {"type": "property", "start": 1998, "end": 2004}, {"type": "punctuation", "start": 2004, "end": 2005}, {"type": "punctuation", "start": 2010, "end": 2011}, {"type": "punctuation", "start": 2013, "end": 2014}, - {"type": "selector", "start": 2017, "end": 2018}, - {"type": "punctuation", "start": 2019, "end": 2020}, - {"type": "property", "start": 2023, "end": 2033}, - {"type": "punctuation", "start": 2033, "end": 2034}, - {"type": "function", "start": 2044, "end": 2048}, - {"type": "punctuation", "start": 2048, "end": 2049}, - {"type": "punctuation", "start": 2050, "end": 2051}, - {"type": "punctuation", "start": 2053, "end": 2054}, - {"type": "punctuation", "start": 2056, "end": 2057}, + {"type": "atrule", "start": 2017, "end": 2042}, + {"type": "rule", "start": 2017, "end": 2023}, + {"type": "punctuation", "start": 2024, "end": 2025}, + {"type": "property", "start": 2025, "end": 2034}, + {"type": "punctuation", "start": 2034, "end": 2035}, + {"type": "punctuation", "start": 2041, "end": 2042}, + {"type": "punctuation", "start": 2043, "end": 2044}, + {"type": "selector", "start": 2047, "end": 2060}, {"type": "punctuation", "start": 2061, "end": 2062}, - {"type": "punctuation", "start": 2062, "end": 2063}, - {"type": "punctuation", "start": 2065, "end": 2066}, - {"type": "comment", "start": 2069, "end": 2082}, - {"type": "comment", "start": 2085, "end": 2117}, - {"type": "selector", "start": 2120, "end": 2130}, - {"type": "punctuation", "start": 2131, "end": 2132}, - {"type": "property", "start": 2135, "end": 2151}, - {"type": "punctuation", "start": 2151, "end": 2152}, - {"type": "punctuation", "start": 2157, "end": 2158}, - {"type": "punctuation", "start": 2160, "end": 2161}, - {"type": "selector", "start": 2164, "end": 2171}, - {"type": "punctuation", "start": 2172, "end": 2173}, - {"type": "property", "start": 2176, "end": 2182}, - {"type": "punctuation", "start": 2182, "end": 2183}, - {"type": "punctuation", "start": 2188, "end": 2189}, - {"type": "punctuation", "start": 2191, "end": 2192}, - {"type": "atrule", "start": 2195, "end": 2220}, - {"type": "rule", "start": 2195, "end": 2201}, - {"type": "punctuation", "start": 2202, "end": 2203}, - {"type": "property", "start": 2203, "end": 2212}, - {"type": "punctuation", "start": 2212, "end": 2213}, - {"type": "punctuation", "start": 2219, "end": 2220}, - {"type": "punctuation", "start": 2221, "end": 2222}, - {"type": "selector", "start": 2225, "end": 2238}, - {"type": "punctuation", "start": 2239, "end": 2240}, - {"type": "property", "start": 2244, "end": 2260}, - {"type": "punctuation", "start": 2260, "end": 2261}, - {"type": "punctuation", "start": 2271, "end": 2272}, - {"type": "punctuation", "start": 2275, "end": 2276}, - {"type": "punctuation", "start": 2278, "end": 2279}, - {"type": "selector", "start": 2282, "end": 2298}, - {"type": "punctuation", "start": 2299, "end": 2300}, - {"type": "property", "start": 2303, "end": 2310}, - {"type": "punctuation", "start": 2310, "end": 2311}, - {"type": "string", "start": 2312, "end": 2319}, - {"type": "punctuation", "start": 2319, "end": 2320}, - {"type": "punctuation", "start": 2322, "end": 2323}, - {"type": "tag", "start": 2324, "end": 2332}, - {"type": "tag", "start": 2324, "end": 2331}, - {"type": "punctuation", "start": 2324, "end": 2326}, - {"type": "punctuation", "start": 2331, "end": 2332} + {"type": "property", "start": 2066, "end": 2082}, + {"type": "punctuation", "start": 2082, "end": 2083}, + {"type": "punctuation", "start": 2093, "end": 2094}, + {"type": "punctuation", "start": 2097, "end": 2098}, + {"type": "punctuation", "start": 2100, "end": 2101}, + {"type": "selector", "start": 2104, "end": 2120}, + {"type": "punctuation", "start": 2121, "end": 2122}, + {"type": "property", "start": 2125, "end": 2132}, + {"type": "punctuation", "start": 2132, "end": 2133}, + {"type": "string", "start": 2134, "end": 2141}, + {"type": "punctuation", "start": 2141, "end": 2142}, + {"type": "punctuation", "start": 2144, "end": 2145}, + {"type": "tag", "start": 2146, "end": 2154}, + {"type": "tag", "start": 2146, "end": 2153}, + {"type": "punctuation", "start": 2146, "end": 2148}, + {"type": "punctuation", "start": 2153, "end": 2154} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const value = thing[key]}\n\t{value}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n<!DOCTYPE html>\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n{D}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 7eee969a..756c3055 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -30,8 +30,8 @@ 81-82 punctuation " 84-85 punctuation " 85-86 punctuation > - 86-1268 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n - 86-1268 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\texport type Some_Type = 1 | 'b' | true;\n\n\tclass D {\n\t\td1: string = 'd';\n\t\td2: number;\n\t\td3 = $state(false);\n\n\t\tconstructor(d2: number) {\n\t\t\tthis.d2 = d2;\n\t\t}\n\n\t\tclass_method(): string {\n\t\t\treturn `Hello, ${this.d1}`;\n\t\t}\n\n\t\tinstance_method = () => {\n\t\t\t/* ... */\n\t\t\tthis.#private_method();\n\t\t\t// foo\n\t\t};\n\n\t\t#private_method() {\n\t\t\tthrow new Error(`${this.d1} etc`);\n\t\t}\n\n\t\tprotected protected_method() {\n\t\t\tconsole.log(new Date(123)); // eslint-disable-line no-console\n\t\t}\n\t}\n\n\t// comment\n\n\t/*\n\tother comment\n\n\tconst comment = false;\n\t*/\n\n\t/**\n\t * JSDoc comment\n\t */\n\n\texport interface Some_E {\n\t\tname: string;\n\t\tage: number;\n\t}\n\n\texport const some_e: Some_E = {name: 'A. H.', age: 100};\n\n\texport function add(x: number, y: number): number {\n\t\treturn x + y;\n\t}\n\n\texport const plus = (a: any, b: any): any => a + b;\n + 86-670 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n + 86-670 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n 88-107 comment // @ts-expect-error 109-115 special_keyword import 122-126 special_keyword from @@ -54,580 +54,548 @@ 229-230 punctuation ) 230-231 punctuation , 242-243 punctuation , - 245-246 punctuation } - 246-247 operator : - 248-249 punctuation { + 253-254 punctuation , + 256-257 punctuation } 257-258 operator : - 265-266 operator < - 266-272 builtin string - 272-273 punctuation , - 274-277 builtin any - 277-278 operator > - 278-279 punctuation ; - 287-288 operator ? - 288-289 operator : - 290-297 builtin boolean - 297-298 punctuation ; - 309-310 operator : - 318-319 punctuation ; - 321-322 punctuation } - 323-324 operator = - 325-331 function $props - 331-332 punctuation ( - 332-333 punctuation ) - 333-334 punctuation ; - 337-342 keyword const - 354-355 operator = - 356-364 function $derived - 364-365 punctuation ( - 371-372 punctuation . - 372-376 function keys - 376-377 punctuation ( - 382-383 punctuation ) - 383-384 punctuation ) - 384-385 punctuation ; - 388-393 keyword const - 396-397 operator = - 398-399 number 1 - 399-400 punctuation ; - 403-408 keyword const - 411-412 operator = - 413-416 string 'b' - 416-417 punctuation ; - 420-423 keyword let - 425-435 type_annotation : boolean - 425-426 : : - 426-435 type boolean - 427-434 builtin boolean - 435-436 operator = - 437-443 function $state - 443-444 punctuation ( - 444-448 boolean true - 448-449 punctuation ) - 449-450 punctuation ; - 453-459 special_keyword export - 460-464 keyword type - 465-474 class_name Some_Type - 465-474 type_name Some_Type - 475-476 operator = - 477-478 number 1 - 479-480 operator | - 481-484 string 'b' - 485-486 operator | - 487-491 boolean true - 491-492 punctuation ; - 495-500 keyword class - 501-502 class_name D - 501-502 constant D - 503-504 punctuation { - 509-518 type_annotation : string - 509-510 : : - 510-518 type string - 511-517 builtin string - 518-519 operator = - 520-523 string 'd' - 523-524 punctuation ; - 529-530 operator : - 531-537 builtin number - 537-538 punctuation ; - 544-545 operator = - 546-552 function $state - 552-553 punctuation ( - 553-558 boolean false - 558-559 punctuation ) - 559-560 punctuation ; - 564-575 function constructor - 575-576 punctuation ( - 578-579 operator : - 580-586 builtin number - 586-587 punctuation ) - 588-589 punctuation { - 593-597 keyword this - 597-598 punctuation . - 601-602 operator = - 605-606 punctuation ; - 609-610 punctuation } - 614-626 function class_method - 626-627 punctuation ( - 627-628 punctuation ) - 628-629 operator : - 630-636 builtin string - 637-638 punctuation { - 642-648 special_keyword return - 649-668 template_string `Hello, ${this.d1}` - 649-650 template_punctuation ` - 650-657 string Hello, - 657-667 interpolation ${this.d1} - 657-659 interpolation_punctuation ${ - 659-663 keyword this - 663-664 punctuation . - 666-667 interpolation_punctuation } - 667-668 template_punctuation ` + 259-260 punctuation { + 268-269 operator : + 276-277 operator < + 277-283 builtin string + 283-284 punctuation , + 285-288 builtin any + 288-289 operator > + 289-290 punctuation ; + 298-299 operator ? + 299-300 operator : + 301-308 builtin boolean + 308-309 punctuation ; + 320-321 operator : + 329-330 punctuation ; + 340-341 operator ? + 341-342 operator : + 343-344 punctuation ( + 344-345 punctuation ) + 346-348 operator => + 349-353 keyword void + 353-354 punctuation ; + 356-357 punctuation } + 358-359 operator = + 360-366 function $props + 366-367 punctuation ( + 367-368 punctuation ) + 368-369 punctuation ; + 372-377 keyword const + 389-390 operator = + 391-399 function $derived + 399-400 punctuation ( + 406-407 punctuation . + 407-411 function keys + 411-412 punctuation ( + 417-418 punctuation ) + 418-419 punctuation ) + 419-420 punctuation ; + 423-428 keyword const + 431-432 operator = + 433-434 number 1 + 434-435 punctuation ; + 438-443 keyword const + 446-447 operator = + 448-451 string 'b' + 451-452 punctuation ; + 455-458 keyword let + 460-470 type_annotation : boolean + 460-461 : : + 461-470 type boolean + 462-469 builtin boolean + 470-471 operator = + 472-478 function $state + 478-479 punctuation ( + 479-483 boolean true + 483-484 punctuation ) + 484-485 punctuation ; + 488-496 keyword function + 497-507 function attachment + 507-508 punctuation ( + 514-515 operator : + 516-522 builtin string + 522-523 punctuation , + 530-531 operator : + 532-538 builtin number + 538-539 punctuation ) + 540-541 punctuation { + 544-550 special_keyword return + 551-552 punctuation ( + 553-554 operator : + 566-567 punctuation ) + 568-570 operator => + 571-572 punctuation { + 576-583 builtin console + 583-584 punctuation . + 584-587 function log + 587-588 punctuation ( + 594-595 punctuation , + 602-603 punctuation ) + 603-604 punctuation ; + 607-608 punctuation } + 608-609 punctuation ; + 611-612 punctuation } + 615-618 keyword let + 625-626 operator = + 627-633 function $state + 633-634 punctuation ( + 634-636 string '' + 636-637 punctuation ) + 637-638 punctuation ; + 640-643 keyword let + 655-656 operator : 668-669 punctuation ; - 672-673 punctuation } - 677-692 function_variable instance_method - 693-694 operator = - 695-696 punctuation ( - 696-697 punctuation ) - 698-700 operator => - 701-702 punctuation { - 706-715 comment /* ... */ - 719-723 keyword this - 723-724 punctuation . - 724-739 function #private_method - 739-740 punctuation ( - 740-741 punctuation ) - 741-742 punctuation ; - 746-752 comment // foo - 755-756 punctuation } - 756-757 punctuation ; - 761-776 function #private_method - 776-777 punctuation ( - 777-778 punctuation ) - 779-780 punctuation { - 784-789 special_keyword throw - 790-793 keyword new - 794-799 class_name Error - 794-799 type_name Error - 799-800 punctuation ( - 800-816 template_string `${this.d1} etc` - 800-801 template_punctuation ` - 801-811 interpolation ${this.d1} - 801-803 interpolation_punctuation ${ - 803-807 keyword this - 807-808 punctuation . - 810-811 interpolation_punctuation } - 811-815 string etc - 815-816 template_punctuation ` - 816-817 punctuation ) - 817-818 punctuation ; - 821-822 punctuation } - 826-835 keyword protected - 836-852 function protected_method - 852-853 punctuation ( - 853-854 punctuation ) - 855-856 punctuation { - 860-867 builtin console - 867-868 punctuation . - 868-871 function log - 871-872 punctuation ( - 872-875 keyword new - 876-880 class_name Date - 876-880 type_name Date - 880-881 punctuation ( - 881-884 number 123 - 884-885 punctuation ) - 885-886 punctuation ) - 886-887 punctuation ; - 888-921 comment // eslint-disable-line no-console - 924-925 punctuation } - 927-928 punctuation } - 931-941 comment // comment - 944-990 comment /*\n\tother comment\n\n\tconst comment = false;\n\t*/ - 993-1019 comment /**\n\t * JSDoc comment\n\t */ -1022-1028 special_keyword export -1029-1038 keyword interface -1039-1045 class_name Some_E -1039-1045 type_name Some_E -1046-1047 punctuation { -1054-1055 operator : -1056-1062 builtin string -1062-1063 punctuation ; -1069-1070 operator : -1071-1077 builtin number -1077-1078 punctuation ; -1080-1081 punctuation } -1084-1090 special_keyword export -1091-1096 keyword const -1103-1112 type_annotation : Some_E -1103-1104 : : -1104-1112 type Some_E -1105-1111 type_name Some_E -1112-1113 operator = -1114-1115 punctuation { -1119-1120 operator : -1121-1128 string 'A. H.' -1128-1129 punctuation , -1133-1134 operator : -1135-1138 number 100 -1138-1139 punctuation } -1139-1140 punctuation ; -1143-1149 special_keyword export -1150-1158 keyword function -1159-1162 function add -1162-1163 punctuation ( -1164-1165 operator : -1166-1172 builtin number -1172-1173 punctuation , -1175-1176 operator : -1177-1183 builtin number -1183-1184 punctuation ) -1184-1185 operator : -1186-1192 builtin number -1193-1194 punctuation { -1197-1203 special_keyword return -1206-1207 operator + -1209-1210 punctuation ; -1212-1213 punctuation } -1216-1222 special_keyword export -1223-1228 keyword const -1229-1233 function_variable plus -1234-1235 operator = -1236-1237 punctuation ( -1238-1239 operator : -1240-1243 builtin any -1243-1244 punctuation , -1246-1247 operator : -1248-1251 builtin any -1251-1252 punctuation ) -1252-1258 type_annotation : any -1252-1253 : : -1253-1258 type any -1254-1257 builtin any -1258-1260 operator => -1263-1264 operator + -1266-1267 punctuation ; -1268-1277 tag -1268-1276 tag -1279-1283 tag

-1279-1282 tag

-1289-1296 lang_ts {HELLO} -1289-1290 punctuation { -1290-1295 constant HELLO -1295-1296 punctuation } -1297-1302 tag

-1297-1301 tag -1304-1335 each {#each thing_keys as key (key)} -1304-1305 punctuation { -1305-1310 keyword #each -1311-1322 lang_ts thing_keys -1322-1324 keyword as -1325-1329 lang_ts key -1329-1334 lang_ts (key) -1329-1330 punctuation ( -1333-1334 punctuation ) -1334-1335 punctuation } -1337-1364 lang_ts {@const value = thing[key]} -1337-1338 punctuation { -1339-1344 keyword const -1351-1352 operator = -1358-1359 punctuation [ -1362-1363 punctuation ] -1363-1364 punctuation } -1366-1373 lang_ts {value} -1366-1367 punctuation { -1372-1373 punctuation } -1374-1381 each {/each} -1374-1375 punctuation { -1375-1380 keyword /each -1380-1381 punctuation } -1383-1390 lang_ts {#if c} -1383-1384 punctuation { -1385-1387 special_keyword if -1389-1390 punctuation } -1392-1433 tag -1392-1398 tag -1434-1441 lang_ts {:else} -1434-1435 punctuation { -1435-1436 operator : -1436-1440 special_keyword else -1440-1441 punctuation } -1443-1507 tag (c = !c)}> -1443-1449 tag (c = !c)} -1490-1491 punctuation { -1491-1492 punctuation ( -1492-1493 punctuation ) -1494-1496 operator => -1497-1498 punctuation ( -1500-1501 operator = -1502-1503 operator ! -1504-1505 punctuation ) -1505-1506 punctuation } -1506-1507 punctuation > -1510-1530 lang_ts {@render children()} -1510-1511 punctuation { -1511-1518 decorator @render -1511-1512 at @ -1512-1518 function render -1519-1527 function children -1527-1528 punctuation ( -1528-1529 punctuation ) -1529-1530 punctuation } -1532-1540 tag -1532-1539 tag + 670-678 tag + 681-685 tag

+ 681-684 tag

+ 691-698 lang_ts {HELLO} + 691-692 punctuation { + 692-697 constant HELLO + 697-698 punctuation } + 699-704 tag

+ 699-703 tag + 706-737 each {#each thing_keys as key (key)} + 706-707 punctuation { + 707-712 keyword #each + 713-724 lang_ts thing_keys + 724-726 keyword as + 727-731 lang_ts key + 731-736 lang_ts (key) + 731-732 punctuation ( + 735-736 punctuation ) + 736-737 punctuation } + 739-762 lang_ts {@const v = thing[key]} + 739-740 punctuation { + 741-746 keyword const + 749-750 operator = + 756-757 punctuation [ + 760-761 punctuation ] + 761-762 punctuation } + 764-767 lang_ts {v} + 764-765 punctuation { + 766-767 punctuation } + 768-775 each {/each} + 768-769 punctuation { + 769-774 keyword /each + 774-775 punctuation } + 777-784 lang_ts {#if c} + 777-778 punctuation { + 779-781 special_keyword if + 783-784 punctuation } + 786-827 tag + 786-792 tag + 828-835 lang_ts {:else} + 828-829 punctuation { + 829-830 operator : + 830-834 special_keyword else + 834-835 punctuation } + 837-901 tag (c = !c)}> + 837-843 tag (c = !c)} + 884-885 punctuation { + 885-886 punctuation ( + 886-887 punctuation ) + 888-890 operator => + 891-892 punctuation ( + 894-895 operator = + 896-897 operator ! + 898-899 punctuation ) + 899-900 punctuation } + 900-901 punctuation > + 904-924 lang_ts {@render children()} + 904-905 punctuation { + 905-912 decorator @render + 905-906 at @ + 906-912 function render + 913-921 function children + 921-922 punctuation ( + 922-923 punctuation ) + 923-924 punctuation } + 926-934 tag + 926-933 tag + 935-940 lang_ts {/if} + 935-936 punctuation { + 936-937 operator / + 937-939 special_keyword if + 939-940 punctuation } + 950-958 tag + 950-957 tag + 966-975 tag + 966-974 tag + 979-1011 tag + 979-985 tag +1013-1093 tag
+1013-1017 tag
+1115-1121 tag
+1115-1120 tag
+1123-1145 lang_ts {@render my_snippet()} +1123-1124 punctuation { +1124-1131 decorator @render +1124-1125 at @ +1125-1131 function render +1132-1142 function my_snippet +1142-1143 punctuation ( +1143-1144 punctuation ) +1144-1145 punctuation } +1147-1170 lang_ts {#snippet my_snippet()} +1147-1148 punctuation { +1157-1167 function my_snippet +1167-1168 punctuation ( +1168-1169 punctuation ) +1169-1170 punctuation } +1172-1190 tag +1203-1211 tag +1213-1223 lang_ts {/snippet} +1213-1214 punctuation { +1214-1215 operator / +1222-1223 punctuation } +1225-1266 tag
+1225-1229 tag
+1268-1271 tag

+1268-1270 tag

+1283-1287 tag

+1283-1286 tag

+1288-1294 tag
+1288-1293 tag
+1296-1330 tag

+1296-1298 tag

+1337-1357 tag +1337-1342 tag +1361-1368 tag +1361-1367 tag +1369-1373 tag

+1369-1372 tag

+1375-1406 tag +1416-1424 tag +1427-1464 comment +1465-1468 lang_ts {a} +1465-1466 punctuation { +1467-1468 punctuation } +1469-1472 lang_ts {b} +1469-1470 punctuation { +1471-1472 punctuation } +1473-1480 lang_ts {bound} +1473-1474 punctuation { +1479-1480 punctuation } +1482-1488 tag
+1482-1485 tag
+1490-1496 tag
+1490-1493 tag
+1498-1534 tag access +1498-1502 tag +1536-1540 tag
    +1536-1539 tag
      -1541-1546 lang_ts {/if} -1541-1542 punctuation { -1542-1543 operator / -1543-1545 special_keyword if -1545-1546 punctuation } -1548-1563 doctype -1565-1606 tag
      -1565-1569 tag
      -1608-1611 tag

      -1608-1610 tag

      -1623-1627 tag

      -1623-1626 tag

      -1628-1634 tag
      -1628-1633 tag
      -1636-1670 tag

      -1636-1638 tag

      +1542-1545 tag

    • +1557-1562 tag
    • +1557-1561 tag +1564-1568 tag
    • +1564-1567 tag
    • +1579-1584 tag
    • +1579-1583 tag +1585-1590 tag
    +1585-1589 tag
+1592-1635 comment +1636-1641 tag
+1636-1640 tag
-1677-1697 tag -1677-1682 tag -1701-1708 tag -1701-1707 tag -1709-1713 tag

-1709-1712 tag

-1715-1746 tag -1756-1764 tag +1643-1651 tag +1689-1697 tag +1700-1707 tag +1741-1748 tag +1750-1756 tag
+1750-1755 tag
+1758-1765 tag -2324-2331 tag +2017-2042 atrule @media (max-width: 600px) +2017-2023 rule @media +2024-2025 punctuation ( +2025-2034 property max-width +2034-2035 punctuation : +2041-2042 punctuation ) +2043-2044 punctuation { +2047-2060 selector :global(body) +2061-2062 punctuation { +2066-2082 property background-color +2082-2083 punctuation : +2093-2094 punctuation ; +2097-2098 punctuation } +2100-2101 punctuation } +2104-2120 selector .special::before +2121-2122 punctuation { +2125-2132 property content +2132-2133 punctuation : +2134-2141 string '< & >' +2141-2142 punctuation ; +2144-2145 punctuation } +2146-2154 tag +2146-2153 tag === STATS === -Total tokens: 590 -Sample length: 2333 characters +Total tokens: 565 +Sample length: 2155 characters Token types: - punctuation: 270 - tag: 60 - operator: 45 - keyword: 24 - lang_ts: 19 - builtin: 17 - attr_name: 16 - special_keyword: 16 + punctuation: 281 + tag: 86 + operator: 31 + lang_ts: 26 + attr_name: 20 + keyword: 16 function: 16 - attr_value: 11 - string: 10 - comment: 10 - property: 8 - selector: 7 - number: 6 - class_name: 5 - type_name: 5 - constant: 4 - boolean: 4 - type_annotation: 4 - :: 4 - type: 4 - template_punctuation: 4 - interpolation_punctuation: 4 - script: 2 - template_string: 2 - interpolation: 2 - function_variable: 2 + attr_value: 12 + special_keyword: 9 + property: 9 + string: 8 + selector: 8 + builtin: 7 + comment: 5 + number: 4 + script: 3 + decorator: 3 + at: 3 + namespace: 3 + constant: 2 + boolean: 2 each: 2 - decorator: 1 - at: 1 - doctype: 1 - style: 1 - lang_css: 1 + style: 2 + lang_css: 2 + type_annotation: 1 + :: 1 + type: 1 atrule: 1 rule: 1 diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 9e61a9c1..8245ce4e 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -264,6 +264,14 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;
  • list item 2
  • +
    + + +
    + @@ -293,10 +301,12 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; thing, bound = $bindable(true), children, + onclick, }: { thing: Record; bound?: boolean; children: Snippet; + onclick?: () => void; } = $props(); const thing_keys = $derived(Object.keys(thing)); @@ -307,67 +317,21 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; let c: boolean = $state(true); - export type Some_Type = 1 | 'b' | true; - - class D { - d1: string = 'd'; - d2: number; - d3 = $state(false); - - constructor(d2: number) { - this.d2 = d2; - } - - class_method(): string { - return \`Hello, \${this.d1}\`; - } - - instance_method = () => { - /* ... */ - this.#private_method(); - // foo + function attachment(param1: string, param2: number) { + return (_: HTMLElement) => { + console.log(param1, param2); }; - - #private_method() { - throw new Error(\`\${this.d1} etc\`); - } - - protected protected_method() { - console.log(new Date(123)); // eslint-disable-line no-console - } - } - - // comment - - /* - other comment - - const comment = false; - */ - - /** - * JSDoc comment - */ - - export interface Some_E { - name: string; - age: number; } - export const some_e: Some_E = {name: 'A. H.', age: 100}; - - export function add(x: number, y: number): number { - return x + y; - } - - export const plus = (a: any, b: any): any => a + b; + let value = $state(''); + let element_ref: HTMLElement;

    hello {HELLO}!

    {#each thing_keys as key (key)} - {@const value = thing[key]} - {value} + {@const v = thing[key]} + {v} {/each} {#if c} @@ -378,7 +342,19 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;
    {/if} - +{@html 'raw html'} + + + +
    + interactive element +
    + +{@render my_snippet()} + +{#snippet my_snippet()} + +{/snippet}

    hello world!

    @@ -394,7 +370,6 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; {a} {b} {bound} -{D}
    @@ -407,6 +382,18 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;
  • list item 2
  • + +
    + + +
    + +
    + \n
    \n\n\n", + "content": "\n\n\n\n

    hello {HELLO}!

    \n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n{@html 'raw html'}\n\n\n\n
    \n\tinteractive element\n
    \n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t\n{/snippet}\n\n
    \n\t

    hello world!

    \n
    \n\n

    \n\tsome text\n

    \n\n\n\n\n{a}\n{b}\n{bound}\n\n
    \n\n
    \n\n\"access\"\n\n
      \n\t
    • list item 1
    • \n\t
    • list item 2
    • \n
    \n\n\n
    \n\t\n\t\n
    \n\n\n", "filepath": "src/lib/samples/sample_complex.svelte" }, "tokens": [ @@ -37,8 +37,8 @@ {"type": "punctuation", "start": 81, "end": 82}, {"type": "punctuation", "start": 84, "end": 85}, {"type": "punctuation", "start": 85, "end": 86}, - {"type": "script", "start": 86, "end": 670}, - {"type": "lang_ts", "start": 86, "end": 670}, + {"type": "script", "start": 86, "end": 721}, + {"type": "lang_ts", "start": 86, "end": 721}, {"type": "comment", "start": 88, "end": 107}, {"type": "special_keyword", "start": 109, "end": 115}, {"type": "special_keyword", "start": 122, "end": 126}, @@ -154,72 +154,66 @@ {"type": "punctuation", "start": 636, "end": 637}, {"type": "punctuation", "start": 637, "end": 638}, {"type": "keyword", "start": 640, "end": 643}, - {"type": "operator", "start": 655, "end": 656}, - {"type": "punctuation", "start": 668, "end": 669}, - {"type": "tag", "start": 670, "end": 679}, - {"type": "tag", "start": 670, "end": 678}, - {"type": "punctuation", "start": 670, "end": 672}, - {"type": "punctuation", "start": 678, "end": 679}, - {"type": "tag", "start": 681, "end": 685}, - {"type": "tag", "start": 681, "end": 684}, - {"type": "punctuation", "start": 681, "end": 682}, - {"type": "punctuation", "start": 684, "end": 685}, - {"type": "lang_ts", "start": 691, "end": 698}, - {"type": "punctuation", "start": 691, "end": 692}, - {"type": "constant", "start": 692, "end": 697}, - {"type": "punctuation", "start": 697, "end": 698}, - {"type": "tag", "start": 699, "end": 704}, - {"type": "tag", "start": 699, "end": 703}, - {"type": "punctuation", "start": 699, "end": 701}, - {"type": "punctuation", "start": 703, "end": 704}, - {"type": "each", "start": 706, "end": 737}, + {"type": "type_annotation", "start": 655, "end": 681}, + {"type": ":", "start": 655, "end": 656}, + {"type": "type", "start": 656, "end": 681}, + {"type": "type_name", "start": 657, "end": 668}, + {"type": "operator", "start": 669, "end": 670}, + {"type": "keyword", "start": 671, "end": 680}, + {"type": "operator", "start": 681, "end": 682}, + {"type": "keyword", "start": 683, "end": 692}, + {"type": "punctuation", "start": 692, "end": 693}, + {"type": "builtin", "start": 695, "end": 702}, + {"type": "punctuation", "start": 702, "end": 703}, + {"type": "function", "start": 703, "end": 706}, {"type": "punctuation", "start": 706, "end": 707}, - {"type": "keyword", "start": 707, "end": 712}, - {"type": "lang_ts", "start": 713, "end": 724}, - {"type": "keyword", "start": 724, "end": 726}, - {"type": "lang_ts", "start": 727, "end": 731}, - {"type": "lang_ts", "start": 731, "end": 736}, - {"type": "punctuation", "start": 731, "end": 732}, + {"type": "punctuation", "start": 718, "end": 719}, + {"type": "punctuation", "start": 719, "end": 720}, + {"type": "tag", "start": 721, "end": 730}, + {"type": "tag", "start": 721, "end": 729}, + {"type": "punctuation", "start": 721, "end": 723}, + {"type": "punctuation", "start": 729, "end": 730}, + {"type": "tag", "start": 732, "end": 736}, + {"type": "tag", "start": 732, "end": 735}, + {"type": "punctuation", "start": 732, "end": 733}, {"type": "punctuation", "start": 735, "end": 736}, - {"type": "punctuation", "start": 736, "end": 737}, - {"type": "lang_ts", "start": 739, "end": 762}, - {"type": "punctuation", "start": 739, "end": 740}, - {"type": "keyword", "start": 741, "end": 746}, - {"type": "operator", "start": 749, "end": 750}, - {"type": "punctuation", "start": 756, "end": 757}, - {"type": "punctuation", "start": 760, "end": 761}, - {"type": "punctuation", "start": 761, "end": 762}, - {"type": "lang_ts", "start": 764, "end": 767}, - {"type": "punctuation", "start": 764, "end": 765}, - {"type": "punctuation", "start": 766, "end": 767}, - {"type": "each", "start": 768, "end": 775}, - {"type": "punctuation", "start": 768, "end": 769}, - {"type": "keyword", "start": 769, "end": 774}, - {"type": "punctuation", "start": 774, "end": 775}, - {"type": "lang_ts", "start": 777, "end": 784}, - {"type": "punctuation", "start": 777, "end": 778}, - {"type": "special_keyword", "start": 779, "end": 781}, - {"type": "punctuation", "start": 783, "end": 784}, - {"type": "tag", "start": 786, "end": 827}, - {"type": "tag", "start": 786, "end": 792}, + {"type": "lang_ts", "start": 742, "end": 749}, + {"type": "punctuation", "start": 742, "end": 743}, + {"type": "constant", "start": 743, "end": 748}, + {"type": "punctuation", "start": 748, "end": 749}, + {"type": "tag", "start": 750, "end": 755}, + {"type": "tag", "start": 750, "end": 754}, + {"type": "punctuation", "start": 750, "end": 752}, + {"type": "punctuation", "start": 754, "end": 755}, + {"type": "each", "start": 757, "end": 788}, + {"type": "punctuation", "start": 757, "end": 758}, + {"type": "keyword", "start": 758, "end": 763}, + {"type": "lang_ts", "start": 764, "end": 775}, + {"type": "keyword", "start": 775, "end": 777}, + {"type": "lang_ts", "start": 778, "end": 782}, + {"type": "lang_ts", "start": 782, "end": 787}, + {"type": "punctuation", "start": 782, "end": 783}, {"type": "punctuation", "start": 786, "end": 787}, - {"type": "attr_name", "start": 793, "end": 804}, - {"type": "attr_value", "start": 804, "end": 808}, - {"type": "punctuation", "start": 804, "end": 805}, - {"type": "punctuation", "start": 805, "end": 806}, + {"type": "punctuation", "start": 787, "end": 788}, + {"type": "lang_ts", "start": 790, "end": 813}, + {"type": "punctuation", "start": 790, "end": 791}, + {"type": "keyword", "start": 792, "end": 797}, + {"type": "operator", "start": 800, "end": 801}, {"type": "punctuation", "start": 807, "end": 808}, - {"type": "attr_name", "start": 809, "end": 821}, - {"type": "lang_ts", "start": 821, "end": 824}, - {"type": "punctuation", "start": 821, "end": 822}, - {"type": "number", "start": 822, "end": 823}, - {"type": "punctuation", "start": 823, "end": 824}, - {"type": "punctuation", "start": 825, "end": 827}, + {"type": "punctuation", "start": 811, "end": 812}, + {"type": "punctuation", "start": 812, "end": 813}, + {"type": "lang_ts", "start": 815, "end": 818}, + {"type": "punctuation", "start": 815, "end": 816}, + {"type": "punctuation", "start": 817, "end": 818}, + {"type": "each", "start": 819, "end": 826}, + {"type": "punctuation", "start": 819, "end": 820}, + {"type": "keyword", "start": 820, "end": 825}, + {"type": "punctuation", "start": 825, "end": 826}, {"type": "lang_ts", "start": 828, "end": 835}, {"type": "punctuation", "start": 828, "end": 829}, - {"type": "operator", "start": 829, "end": 830}, - {"type": "special_keyword", "start": 830, "end": 834}, + {"type": "special_keyword", "start": 830, "end": 832}, {"type": "punctuation", "start": 834, "end": 835}, - {"type": "tag", "start": 837, "end": 901}, + {"type": "tag", "start": 837, "end": 878}, {"type": "tag", "start": 837, "end": 843}, {"type": "punctuation", "start": 837, "end": 838}, {"type": "attr_name", "start": 844, "end": 855}, @@ -232,345 +226,364 @@ {"type": "punctuation", "start": 872, "end": 873}, {"type": "number", "start": 873, "end": 874}, {"type": "punctuation", "start": 874, "end": 875}, - {"type": "attr_name", "start": 876, "end": 884}, - {"type": "lang_ts", "start": 884, "end": 900}, - {"type": "punctuation", "start": 884, "end": 885}, + {"type": "punctuation", "start": 876, "end": 878}, + {"type": "lang_ts", "start": 879, "end": 886}, + {"type": "punctuation", "start": 879, "end": 880}, + {"type": "operator", "start": 880, "end": 881}, + {"type": "special_keyword", "start": 881, "end": 885}, {"type": "punctuation", "start": 885, "end": 886}, - {"type": "punctuation", "start": 886, "end": 887}, - {"type": "operator", "start": 888, "end": 890}, - {"type": "punctuation", "start": 891, "end": 892}, - {"type": "operator", "start": 894, "end": 895}, - {"type": "operator", "start": 896, "end": 897}, - {"type": "punctuation", "start": 898, "end": 899}, - {"type": "punctuation", "start": 899, "end": 900}, - {"type": "punctuation", "start": 900, "end": 901}, - {"type": "lang_ts", "start": 904, "end": 924}, - {"type": "punctuation", "start": 904, "end": 905}, - {"type": "decorator", "start": 905, "end": 912}, - {"type": "at", "start": 905, "end": 906}, - {"type": "function", "start": 906, "end": 912}, - {"type": "function", "start": 913, "end": 921}, - {"type": "punctuation", "start": 921, "end": 922}, - {"type": "punctuation", "start": 922, "end": 923}, + {"type": "tag", "start": 888, "end": 952}, + {"type": "tag", "start": 888, "end": 894}, + {"type": "punctuation", "start": 888, "end": 889}, + {"type": "attr_name", "start": 895, "end": 906}, + {"type": "attr_value", "start": 906, "end": 910}, + {"type": "punctuation", "start": 906, "end": 907}, + {"type": "punctuation", "start": 907, "end": 908}, + {"type": "punctuation", "start": 909, "end": 910}, + {"type": "attr_name", "start": 911, "end": 923}, + {"type": "lang_ts", "start": 923, "end": 926}, {"type": "punctuation", "start": 923, "end": 924}, - {"type": "tag", "start": 926, "end": 934}, - {"type": "tag", "start": 926, "end": 933}, - {"type": "punctuation", "start": 926, "end": 928}, - {"type": "punctuation", "start": 933, "end": 934}, - {"type": "lang_ts", "start": 935, "end": 940}, + {"type": "number", "start": 924, "end": 925}, + {"type": "punctuation", "start": 925, "end": 926}, + {"type": "attr_name", "start": 927, "end": 935}, + {"type": "lang_ts", "start": 935, "end": 951}, {"type": "punctuation", "start": 935, "end": 936}, - {"type": "operator", "start": 936, "end": 937}, - {"type": "special_keyword", "start": 937, "end": 939}, - {"type": "punctuation", "start": 939, "end": 940}, - {"type": "tag", "start": 950, "end": 958}, - {"type": "tag", "start": 950, "end": 957}, + {"type": "punctuation", "start": 936, "end": 937}, + {"type": "punctuation", "start": 937, "end": 938}, + {"type": "operator", "start": 939, "end": 941}, + {"type": "punctuation", "start": 942, "end": 943}, + {"type": "operator", "start": 945, "end": 946}, + {"type": "operator", "start": 947, "end": 948}, + {"type": "punctuation", "start": 949, "end": 950}, {"type": "punctuation", "start": 950, "end": 951}, - {"type": "punctuation", "start": 957, "end": 958}, - {"type": "tag", "start": 966, "end": 975}, - {"type": "tag", "start": 966, "end": 974}, - {"type": "punctuation", "start": 966, "end": 968}, + {"type": "punctuation", "start": 951, "end": 952}, + {"type": "lang_ts", "start": 955, "end": 975}, + {"type": "punctuation", "start": 955, "end": 956}, + {"type": "decorator", "start": 956, "end": 963}, + {"type": "at", "start": 956, "end": 957}, + {"type": "function", "start": 957, "end": 963}, + {"type": "function", "start": 964, "end": 972}, + {"type": "punctuation", "start": 972, "end": 973}, + {"type": "punctuation", "start": 973, "end": 974}, {"type": "punctuation", "start": 974, "end": 975}, - {"type": "tag", "start": 979, "end": 1011}, - {"type": "tag", "start": 979, "end": 985}, - {"type": "punctuation", "start": 979, "end": 980}, - {"type": "attr_name", "start": 986, "end": 996}, - {"type": "namespace", "start": 986, "end": 991}, - {"type": "attr_name", "start": 997, "end": 1001}, - {"type": "attr_value", "start": 1001, "end": 1008}, + {"type": "tag", "start": 977, "end": 985}, + {"type": "tag", "start": 977, "end": 984}, + {"type": "punctuation", "start": 977, "end": 979}, + {"type": "punctuation", "start": 984, "end": 985}, + {"type": "lang_ts", "start": 986, "end": 991}, + {"type": "punctuation", "start": 986, "end": 987}, + {"type": "operator", "start": 987, "end": 988}, + {"type": "special_keyword", "start": 988, "end": 990}, + {"type": "punctuation", "start": 990, "end": 991}, + {"type": "tag", "start": 1001, "end": 1009}, + {"type": "tag", "start": 1001, "end": 1008}, {"type": "punctuation", "start": 1001, "end": 1002}, - {"type": "punctuation", "start": 1002, "end": 1003}, - {"type": "punctuation", "start": 1007, "end": 1008}, - {"type": "punctuation", "start": 1009, "end": 1011}, - {"type": "tag", "start": 1013, "end": 1093}, - {"type": "tag", "start": 1013, "end": 1017}, - {"type": "punctuation", "start": 1013, "end": 1014}, - {"type": "attr_name", "start": 1018, "end": 1028}, - {"type": "namespace", "start": 1018, "end": 1023}, - {"type": "lang_ts", "start": 1028, "end": 1041}, - {"type": "punctuation", "start": 1028, "end": 1029}, - {"type": "punctuation", "start": 1040, "end": 1041}, - {"type": "attr_name", "start": 1042, "end": 1055}, - {"type": "namespace", "start": 1042, "end": 1048}, - {"type": "lang_ts", "start": 1055, "end": 1058}, - {"type": "punctuation", "start": 1055, "end": 1056}, - {"type": "punctuation", "start": 1057, "end": 1058}, - {"type": "lang_ts", "start": 1059, "end": 1092}, - {"type": "punctuation", "start": 1059, "end": 1060}, - {"type": "decorator", "start": 1060, "end": 1067}, - {"type": "at", "start": 1060, "end": 1061}, - {"type": "function", "start": 1061, "end": 1067}, - {"type": "function", "start": 1068, "end": 1078}, - {"type": "punctuation", "start": 1078, "end": 1079}, - {"type": "string", "start": 1079, "end": 1086}, - {"type": "punctuation", "start": 1086, "end": 1087}, - {"type": "number", "start": 1088, "end": 1090}, - {"type": "punctuation", "start": 1090, "end": 1091}, + {"type": "punctuation", "start": 1008, "end": 1009}, + {"type": "tag", "start": 1017, "end": 1026}, + {"type": "tag", "start": 1017, "end": 1025}, + {"type": "punctuation", "start": 1017, "end": 1019}, + {"type": "punctuation", "start": 1025, "end": 1026}, + {"type": "tag", "start": 1030, "end": 1062}, + {"type": "tag", "start": 1030, "end": 1036}, + {"type": "punctuation", "start": 1030, "end": 1031}, + {"type": "attr_name", "start": 1037, "end": 1047}, + {"type": "namespace", "start": 1037, "end": 1042}, + {"type": "attr_name", "start": 1048, "end": 1052}, + {"type": "attr_value", "start": 1052, "end": 1059}, + {"type": "punctuation", "start": 1052, "end": 1053}, + {"type": "punctuation", "start": 1053, "end": 1054}, + {"type": "punctuation", "start": 1058, "end": 1059}, + {"type": "punctuation", "start": 1060, "end": 1062}, + {"type": "tag", "start": 1064, "end": 1144}, + {"type": "tag", "start": 1064, "end": 1068}, + {"type": "punctuation", "start": 1064, "end": 1065}, + {"type": "attr_name", "start": 1069, "end": 1079}, + {"type": "namespace", "start": 1069, "end": 1074}, + {"type": "lang_ts", "start": 1079, "end": 1092}, + {"type": "punctuation", "start": 1079, "end": 1080}, {"type": "punctuation", "start": 1091, "end": 1092}, - {"type": "punctuation", "start": 1092, "end": 1093}, - {"type": "tag", "start": 1115, "end": 1121}, - {"type": "tag", "start": 1115, "end": 1120}, - {"type": "punctuation", "start": 1115, "end": 1117}, - {"type": "punctuation", "start": 1120, "end": 1121}, - {"type": "lang_ts", "start": 1123, "end": 1145}, - {"type": "punctuation", "start": 1123, "end": 1124}, - {"type": "decorator", "start": 1124, "end": 1131}, - {"type": "at", "start": 1124, "end": 1125}, - {"type": "function", "start": 1125, "end": 1131}, - {"type": "function", "start": 1132, "end": 1142}, + {"type": "attr_name", "start": 1093, "end": 1106}, + {"type": "namespace", "start": 1093, "end": 1099}, + {"type": "lang_ts", "start": 1106, "end": 1109}, + {"type": "punctuation", "start": 1106, "end": 1107}, + {"type": "punctuation", "start": 1108, "end": 1109}, + {"type": "lang_ts", "start": 1110, "end": 1143}, + {"type": "punctuation", "start": 1110, "end": 1111}, + {"type": "decorator", "start": 1111, "end": 1118}, + {"type": "at", "start": 1111, "end": 1112}, + {"type": "function", "start": 1112, "end": 1118}, + {"type": "function", "start": 1119, "end": 1129}, + {"type": "punctuation", "start": 1129, "end": 1130}, + {"type": "string", "start": 1130, "end": 1137}, + {"type": "punctuation", "start": 1137, "end": 1138}, + {"type": "number", "start": 1139, "end": 1141}, + {"type": "punctuation", "start": 1141, "end": 1142}, {"type": "punctuation", "start": 1142, "end": 1143}, {"type": "punctuation", "start": 1143, "end": 1144}, - {"type": "punctuation", "start": 1144, "end": 1145}, - {"type": "lang_ts", "start": 1147, "end": 1170}, - {"type": "punctuation", "start": 1147, "end": 1148}, - {"type": "function", "start": 1157, "end": 1167}, - {"type": "punctuation", "start": 1167, "end": 1168}, - {"type": "punctuation", "start": 1168, "end": 1169}, - {"type": "punctuation", "start": 1169, "end": 1170}, - {"type": "tag", "start": 1172, "end": 1190}, - {"type": "tag", "start": 1172, "end": 1179}, - {"type": "punctuation", "start": 1172, "end": 1173}, - {"type": "lang_ts", "start": 1180, "end": 1189}, - {"type": "punctuation", "start": 1180, "end": 1181}, - {"type": "punctuation", "start": 1188, "end": 1189}, - {"type": "punctuation", "start": 1189, "end": 1190}, - {"type": "tag", "start": 1203, "end": 1212}, - {"type": "tag", "start": 1203, "end": 1211}, - {"type": "punctuation", "start": 1203, "end": 1205}, - {"type": "punctuation", "start": 1211, "end": 1212}, - {"type": "lang_ts", "start": 1213, "end": 1223}, - {"type": "punctuation", "start": 1213, "end": 1214}, - {"type": "operator", "start": 1214, "end": 1215}, - {"type": "punctuation", "start": 1222, "end": 1223}, - {"type": "tag", "start": 1225, "end": 1266}, - {"type": "tag", "start": 1225, "end": 1229}, - {"type": "punctuation", "start": 1225, "end": 1226}, - {"type": "attr_name", "start": 1230, "end": 1235}, - {"type": "attr_value", "start": 1235, "end": 1250}, - {"type": "punctuation", "start": 1235, "end": 1236}, - {"type": "punctuation", "start": 1236, "end": 1237}, - {"type": "punctuation", "start": 1249, "end": 1250}, - {"type": "attr_name", "start": 1251, "end": 1253}, - {"type": "attr_value", "start": 1253, "end": 1265}, - {"type": "punctuation", "start": 1253, "end": 1254}, - {"type": "punctuation", "start": 1254, "end": 1255}, + {"type": "tag", "start": 1166, "end": 1172}, + {"type": "tag", "start": 1166, "end": 1171}, + {"type": "punctuation", "start": 1166, "end": 1168}, + {"type": "punctuation", "start": 1171, "end": 1172}, + {"type": "lang_ts", "start": 1174, "end": 1196}, + {"type": "punctuation", "start": 1174, "end": 1175}, + {"type": "decorator", "start": 1175, "end": 1182}, + {"type": "at", "start": 1175, "end": 1176}, + {"type": "function", "start": 1176, "end": 1182}, + {"type": "function", "start": 1183, "end": 1193}, + {"type": "punctuation", "start": 1193, "end": 1194}, + {"type": "punctuation", "start": 1194, "end": 1195}, + {"type": "punctuation", "start": 1195, "end": 1196}, + {"type": "lang_ts", "start": 1198, "end": 1221}, + {"type": "punctuation", "start": 1198, "end": 1199}, + {"type": "function", "start": 1208, "end": 1218}, + {"type": "punctuation", "start": 1218, "end": 1219}, + {"type": "punctuation", "start": 1219, "end": 1220}, + {"type": "punctuation", "start": 1220, "end": 1221}, + {"type": "tag", "start": 1223, "end": 1241}, + {"type": "tag", "start": 1223, "end": 1230}, + {"type": "punctuation", "start": 1223, "end": 1224}, + {"type": "lang_ts", "start": 1231, "end": 1240}, + {"type": "punctuation", "start": 1231, "end": 1232}, + {"type": "punctuation", "start": 1239, "end": 1240}, + {"type": "punctuation", "start": 1240, "end": 1241}, + {"type": "tag", "start": 1254, "end": 1263}, + {"type": "tag", "start": 1254, "end": 1262}, + {"type": "punctuation", "start": 1254, "end": 1256}, + {"type": "punctuation", "start": 1262, "end": 1263}, + {"type": "lang_ts", "start": 1264, "end": 1274}, {"type": "punctuation", "start": 1264, "end": 1265}, - {"type": "punctuation", "start": 1265, "end": 1266}, - {"type": "tag", "start": 1268, "end": 1271}, - {"type": "tag", "start": 1268, "end": 1270}, - {"type": "punctuation", "start": 1268, "end": 1269}, - {"type": "punctuation", "start": 1270, "end": 1271}, - {"type": "tag", "start": 1283, "end": 1287}, - {"type": "tag", "start": 1283, "end": 1286}, - {"type": "punctuation", "start": 1283, "end": 1285}, + {"type": "operator", "start": 1265, "end": 1266}, + {"type": "punctuation", "start": 1273, "end": 1274}, + {"type": "tag", "start": 1276, "end": 1317}, + {"type": "tag", "start": 1276, "end": 1280}, + {"type": "punctuation", "start": 1276, "end": 1277}, + {"type": "attr_name", "start": 1281, "end": 1286}, + {"type": "attr_value", "start": 1286, "end": 1301}, {"type": "punctuation", "start": 1286, "end": 1287}, - {"type": "tag", "start": 1288, "end": 1294}, - {"type": "tag", "start": 1288, "end": 1293}, - {"type": "punctuation", "start": 1288, "end": 1290}, - {"type": "punctuation", "start": 1293, "end": 1294}, - {"type": "tag", "start": 1296, "end": 1330}, - {"type": "tag", "start": 1296, "end": 1298}, - {"type": "punctuation", "start": 1296, "end": 1297}, - {"type": "attr_name", "start": 1299, "end": 1304}, - {"type": "attr_value", "start": 1304, "end": 1329}, + {"type": "punctuation", "start": 1287, "end": 1288}, + {"type": "punctuation", "start": 1300, "end": 1301}, + {"type": "attr_name", "start": 1302, "end": 1304}, + {"type": "attr_value", "start": 1304, "end": 1316}, {"type": "punctuation", "start": 1304, "end": 1305}, {"type": "punctuation", "start": 1305, "end": 1306}, - {"type": "punctuation", "start": 1328, "end": 1329}, - {"type": "punctuation", "start": 1329, "end": 1330}, - {"type": "tag", "start": 1337, "end": 1357}, - {"type": "tag", "start": 1337, "end": 1342}, + {"type": "punctuation", "start": 1315, "end": 1316}, + {"type": "punctuation", "start": 1316, "end": 1317}, + {"type": "tag", "start": 1319, "end": 1322}, + {"type": "tag", "start": 1319, "end": 1321}, + {"type": "punctuation", "start": 1319, "end": 1320}, + {"type": "punctuation", "start": 1321, "end": 1322}, + {"type": "tag", "start": 1334, "end": 1338}, + {"type": "tag", "start": 1334, "end": 1337}, + {"type": "punctuation", "start": 1334, "end": 1336}, {"type": "punctuation", "start": 1337, "end": 1338}, - {"type": "attr_name", "start": 1343, "end": 1348}, - {"type": "attr_value", "start": 1348, "end": 1356}, - {"type": "punctuation", "start": 1348, "end": 1349}, - {"type": "punctuation", "start": 1349, "end": 1350}, + {"type": "tag", "start": 1339, "end": 1345}, + {"type": "tag", "start": 1339, "end": 1344}, + {"type": "punctuation", "start": 1339, "end": 1341}, + {"type": "punctuation", "start": 1344, "end": 1345}, + {"type": "tag", "start": 1347, "end": 1381}, + {"type": "tag", "start": 1347, "end": 1349}, + {"type": "punctuation", "start": 1347, "end": 1348}, + {"type": "attr_name", "start": 1350, "end": 1355}, + {"type": "attr_value", "start": 1355, "end": 1380}, {"type": "punctuation", "start": 1355, "end": 1356}, {"type": "punctuation", "start": 1356, "end": 1357}, - {"type": "tag", "start": 1361, "end": 1368}, - {"type": "tag", "start": 1361, "end": 1367}, - {"type": "punctuation", "start": 1361, "end": 1363}, - {"type": "punctuation", "start": 1367, "end": 1368}, - {"type": "tag", "start": 1369, "end": 1373}, - {"type": "tag", "start": 1369, "end": 1372}, - {"type": "punctuation", "start": 1369, "end": 1371}, - {"type": "punctuation", "start": 1372, "end": 1373}, - {"type": "tag", "start": 1375, "end": 1406}, - {"type": "tag", "start": 1375, "end": 1382}, - {"type": "punctuation", "start": 1375, "end": 1376}, - {"type": "attr_name", "start": 1383, "end": 1387}, - {"type": "attr_value", "start": 1387, "end": 1396}, - {"type": "punctuation", "start": 1387, "end": 1388}, + {"type": "punctuation", "start": 1379, "end": 1380}, + {"type": "punctuation", "start": 1380, "end": 1381}, + {"type": "tag", "start": 1388, "end": 1408}, + {"type": "tag", "start": 1388, "end": 1393}, {"type": "punctuation", "start": 1388, "end": 1389}, - {"type": "punctuation", "start": 1395, "end": 1396}, - {"type": "attr_name", "start": 1397, "end": 1405}, - {"type": "punctuation", "start": 1405, "end": 1406}, - {"type": "tag", "start": 1416, "end": 1425}, - {"type": "tag", "start": 1416, "end": 1424}, - {"type": "punctuation", "start": 1416, "end": 1418}, - {"type": "punctuation", "start": 1424, "end": 1425}, - {"type": "comment", "start": 1427, "end": 1464}, - {"type": "lang_ts", "start": 1465, "end": 1468}, - {"type": "punctuation", "start": 1465, "end": 1466}, - {"type": "punctuation", "start": 1467, "end": 1468}, - {"type": "lang_ts", "start": 1469, "end": 1472}, - {"type": "punctuation", "start": 1469, "end": 1470}, - {"type": "punctuation", "start": 1471, "end": 1472}, - {"type": "lang_ts", "start": 1473, "end": 1480}, - {"type": "punctuation", "start": 1473, "end": 1474}, - {"type": "punctuation", "start": 1479, "end": 1480}, - {"type": "tag", "start": 1482, "end": 1488}, - {"type": "tag", "start": 1482, "end": 1485}, - {"type": "punctuation", "start": 1482, "end": 1483}, - {"type": "punctuation", "start": 1486, "end": 1488}, - {"type": "tag", "start": 1490, "end": 1496}, - {"type": "tag", "start": 1490, "end": 1493}, - {"type": "punctuation", "start": 1490, "end": 1491}, - {"type": "punctuation", "start": 1494, "end": 1496}, - {"type": "tag", "start": 1498, "end": 1534}, - {"type": "tag", "start": 1498, "end": 1502}, - {"type": "punctuation", "start": 1498, "end": 1499}, - {"type": "attr_name", "start": 1503, "end": 1506}, - {"type": "attr_value", "start": 1506, "end": 1518}, - {"type": "punctuation", "start": 1506, "end": 1507}, - {"type": "punctuation", "start": 1507, "end": 1508}, - {"type": "punctuation", "start": 1517, "end": 1518}, - {"type": "attr_name", "start": 1519, "end": 1522}, - {"type": "attr_value", "start": 1522, "end": 1531}, + {"type": "attr_name", "start": 1394, "end": 1399}, + {"type": "attr_value", "start": 1399, "end": 1407}, + {"type": "punctuation", "start": 1399, "end": 1400}, + {"type": "punctuation", "start": 1400, "end": 1401}, + {"type": "punctuation", "start": 1406, "end": 1407}, + {"type": "punctuation", "start": 1407, "end": 1408}, + {"type": "tag", "start": 1412, "end": 1419}, + {"type": "tag", "start": 1412, "end": 1418}, + {"type": "punctuation", "start": 1412, "end": 1414}, + {"type": "punctuation", "start": 1418, "end": 1419}, + {"type": "tag", "start": 1420, "end": 1424}, + {"type": "tag", "start": 1420, "end": 1423}, + {"type": "punctuation", "start": 1420, "end": 1422}, + {"type": "punctuation", "start": 1423, "end": 1424}, + {"type": "tag", "start": 1426, "end": 1457}, + {"type": "tag", "start": 1426, "end": 1433}, + {"type": "punctuation", "start": 1426, "end": 1427}, + {"type": "attr_name", "start": 1434, "end": 1438}, + {"type": "attr_value", "start": 1438, "end": 1447}, + {"type": "punctuation", "start": 1438, "end": 1439}, + {"type": "punctuation", "start": 1439, "end": 1440}, + {"type": "punctuation", "start": 1446, "end": 1447}, + {"type": "attr_name", "start": 1448, "end": 1456}, + {"type": "punctuation", "start": 1456, "end": 1457}, + {"type": "tag", "start": 1467, "end": 1476}, + {"type": "tag", "start": 1467, "end": 1475}, + {"type": "punctuation", "start": 1467, "end": 1469}, + {"type": "punctuation", "start": 1475, "end": 1476}, + {"type": "comment", "start": 1478, "end": 1515}, + {"type": "lang_ts", "start": 1516, "end": 1519}, + {"type": "punctuation", "start": 1516, "end": 1517}, + {"type": "punctuation", "start": 1518, "end": 1519}, + {"type": "lang_ts", "start": 1520, "end": 1523}, + {"type": "punctuation", "start": 1520, "end": 1521}, {"type": "punctuation", "start": 1522, "end": 1523}, - {"type": "punctuation", "start": 1523, "end": 1524}, + {"type": "lang_ts", "start": 1524, "end": 1531}, + {"type": "punctuation", "start": 1524, "end": 1525}, {"type": "punctuation", "start": 1530, "end": 1531}, - {"type": "punctuation", "start": 1532, "end": 1534}, - {"type": "tag", "start": 1536, "end": 1540}, - {"type": "tag", "start": 1536, "end": 1539}, - {"type": "punctuation", "start": 1536, "end": 1537}, - {"type": "punctuation", "start": 1539, "end": 1540}, - {"type": "tag", "start": 1542, "end": 1546}, - {"type": "tag", "start": 1542, "end": 1545}, - {"type": "punctuation", "start": 1542, "end": 1543}, - {"type": "punctuation", "start": 1545, "end": 1546}, - {"type": "tag", "start": 1557, "end": 1562}, - {"type": "tag", "start": 1557, "end": 1561}, - {"type": "punctuation", "start": 1557, "end": 1559}, - {"type": "punctuation", "start": 1561, "end": 1562}, - {"type": "tag", "start": 1564, "end": 1568}, - {"type": "tag", "start": 1564, "end": 1567}, - {"type": "punctuation", "start": 1564, "end": 1565}, - {"type": "punctuation", "start": 1567, "end": 1568}, - {"type": "tag", "start": 1579, "end": 1584}, - {"type": "tag", "start": 1579, "end": 1583}, - {"type": "punctuation", "start": 1579, "end": 1581}, - {"type": "punctuation", "start": 1583, "end": 1584}, - {"type": "tag", "start": 1585, "end": 1590}, - {"type": "tag", "start": 1585, "end": 1589}, - {"type": "punctuation", "start": 1585, "end": 1587}, - {"type": "punctuation", "start": 1589, "end": 1590}, - {"type": "comment", "start": 1592, "end": 1635}, + {"type": "tag", "start": 1533, "end": 1539}, + {"type": "tag", "start": 1533, "end": 1536}, + {"type": "punctuation", "start": 1533, "end": 1534}, + {"type": "punctuation", "start": 1537, "end": 1539}, + {"type": "tag", "start": 1541, "end": 1547}, + {"type": "tag", "start": 1541, "end": 1544}, + {"type": "punctuation", "start": 1541, "end": 1542}, + {"type": "punctuation", "start": 1545, "end": 1547}, + {"type": "tag", "start": 1549, "end": 1585}, + {"type": "tag", "start": 1549, "end": 1553}, + {"type": "punctuation", "start": 1549, "end": 1550}, + {"type": "attr_name", "start": 1554, "end": 1557}, + {"type": "attr_value", "start": 1557, "end": 1569}, + {"type": "punctuation", "start": 1557, "end": 1558}, + {"type": "punctuation", "start": 1558, "end": 1559}, + {"type": "punctuation", "start": 1568, "end": 1569}, + {"type": "attr_name", "start": 1570, "end": 1573}, + {"type": "attr_value", "start": 1573, "end": 1582}, + {"type": "punctuation", "start": 1573, "end": 1574}, + {"type": "punctuation", "start": 1574, "end": 1575}, + {"type": "punctuation", "start": 1581, "end": 1582}, + {"type": "punctuation", "start": 1583, "end": 1585}, + {"type": "tag", "start": 1587, "end": 1591}, + {"type": "tag", "start": 1587, "end": 1590}, + {"type": "punctuation", "start": 1587, "end": 1588}, + {"type": "punctuation", "start": 1590, "end": 1591}, + {"type": "tag", "start": 1593, "end": 1597}, + {"type": "tag", "start": 1593, "end": 1596}, + {"type": "punctuation", "start": 1593, "end": 1594}, + {"type": "punctuation", "start": 1596, "end": 1597}, + {"type": "tag", "start": 1608, "end": 1613}, + {"type": "tag", "start": 1608, "end": 1612}, + {"type": "punctuation", "start": 1608, "end": 1610}, + {"type": "punctuation", "start": 1612, "end": 1613}, + {"type": "tag", "start": 1615, "end": 1619}, + {"type": "tag", "start": 1615, "end": 1618}, + {"type": "punctuation", "start": 1615, "end": 1616}, + {"type": "punctuation", "start": 1618, "end": 1619}, + {"type": "tag", "start": 1630, "end": 1635}, + {"type": "tag", "start": 1630, "end": 1634}, + {"type": "punctuation", "start": 1630, "end": 1632}, + {"type": "punctuation", "start": 1634, "end": 1635}, {"type": "tag", "start": 1636, "end": 1641}, {"type": "tag", "start": 1636, "end": 1640}, - {"type": "punctuation", "start": 1636, "end": 1637}, + {"type": "punctuation", "start": 1636, "end": 1638}, {"type": "punctuation", "start": 1640, "end": 1641}, - {"type": "tag", "start": 1643, "end": 1651}, - {"type": "tag", "start": 1643, "end": 1650}, - {"type": "punctuation", "start": 1643, "end": 1644}, - {"type": "punctuation", "start": 1650, "end": 1651}, - {"type": "script", "start": 1651, "end": 1689}, - {"type": "lang_ts", "start": 1651, "end": 1689}, - {"type": "keyword", "start": 1654, "end": 1659}, - {"type": "operator", "start": 1670, "end": 1671}, - {"type": "string", "start": 1672, "end": 1686}, - {"type": "punctuation", "start": 1686, "end": 1687}, - {"type": "tag", "start": 1689, "end": 1698}, - {"type": "tag", "start": 1689, "end": 1697}, - {"type": "punctuation", "start": 1689, "end": 1691}, - {"type": "punctuation", "start": 1697, "end": 1698}, - {"type": "tag", "start": 1700, "end": 1707}, - {"type": "tag", "start": 1700, "end": 1706}, - {"type": "punctuation", "start": 1700, "end": 1701}, - {"type": "punctuation", "start": 1706, "end": 1707}, - {"type": "style", "start": 1707, "end": 1741}, - {"type": "lang_css", "start": 1707, "end": 1741}, - {"type": "selector", "start": 1710, "end": 1717}, - {"type": "punctuation", "start": 1718, "end": 1719}, - {"type": "property", "start": 1723, "end": 1728}, - {"type": "punctuation", "start": 1728, "end": 1729}, - {"type": "punctuation", "start": 1734, "end": 1735}, - {"type": "punctuation", "start": 1738, "end": 1739}, - {"type": "tag", "start": 1741, "end": 1749}, - {"type": "tag", "start": 1741, "end": 1748}, - {"type": "punctuation", "start": 1741, "end": 1743}, + {"type": "comment", "start": 1643, "end": 1686}, + {"type": "tag", "start": 1687, "end": 1692}, + {"type": "tag", "start": 1687, "end": 1691}, + {"type": "punctuation", "start": 1687, "end": 1688}, + {"type": "punctuation", "start": 1691, "end": 1692}, + {"type": "tag", "start": 1694, "end": 1702}, + {"type": "tag", "start": 1694, "end": 1701}, + {"type": "punctuation", "start": 1694, "end": 1695}, + {"type": "punctuation", "start": 1701, "end": 1702}, + {"type": "script", "start": 1702, "end": 1740}, + {"type": "lang_ts", "start": 1702, "end": 1740}, + {"type": "keyword", "start": 1705, "end": 1710}, + {"type": "operator", "start": 1721, "end": 1722}, + {"type": "string", "start": 1723, "end": 1737}, + {"type": "punctuation", "start": 1737, "end": 1738}, + {"type": "tag", "start": 1740, "end": 1749}, + {"type": "tag", "start": 1740, "end": 1748}, + {"type": "punctuation", "start": 1740, "end": 1742}, {"type": "punctuation", "start": 1748, "end": 1749}, - {"type": "tag", "start": 1750, "end": 1756}, - {"type": "tag", "start": 1750, "end": 1755}, - {"type": "punctuation", "start": 1750, "end": 1752}, - {"type": "punctuation", "start": 1755, "end": 1756}, - {"type": "tag", "start": 1758, "end": 1765}, - {"type": "tag", "start": 1758, "end": 1764}, - {"type": "punctuation", "start": 1758, "end": 1759}, - {"type": "punctuation", "start": 1764, "end": 1765}, - {"type": "style", "start": 1765, "end": 2146}, - {"type": "lang_css", "start": 1765, "end": 2146}, - {"type": "selector", "start": 1767, "end": 1778}, + {"type": "tag", "start": 1751, "end": 1758}, + {"type": "tag", "start": 1751, "end": 1757}, + {"type": "punctuation", "start": 1751, "end": 1752}, + {"type": "punctuation", "start": 1757, "end": 1758}, + {"type": "style", "start": 1758, "end": 1792}, + {"type": "lang_css", "start": 1758, "end": 1792}, + {"type": "selector", "start": 1761, "end": 1768}, + {"type": "punctuation", "start": 1769, "end": 1770}, + {"type": "property", "start": 1774, "end": 1779}, {"type": "punctuation", "start": 1779, "end": 1780}, - {"type": "property", "start": 1783, "end": 1788}, - {"type": "punctuation", "start": 1788, "end": 1789}, - {"type": "punctuation", "start": 1793, "end": 1794}, - {"type": "punctuation", "start": 1796, "end": 1797}, - {"type": "selector", "start": 1800, "end": 1812}, - {"type": "punctuation", "start": 1813, "end": 1814}, - {"type": "property", "start": 1817, "end": 1826}, - {"type": "punctuation", "start": 1826, "end": 1827}, - {"type": "punctuation", "start": 1832, "end": 1833}, - {"type": "punctuation", "start": 1835, "end": 1836}, - {"type": "selector", "start": 1839, "end": 1840}, - {"type": "punctuation", "start": 1841, "end": 1842}, - {"type": "property", "start": 1845, "end": 1855}, - {"type": "punctuation", "start": 1855, "end": 1856}, - {"type": "function", "start": 1866, "end": 1870}, - {"type": "punctuation", "start": 1870, "end": 1871}, - {"type": "punctuation", "start": 1872, "end": 1873}, - {"type": "punctuation", "start": 1875, "end": 1876}, - {"type": "punctuation", "start": 1878, "end": 1879}, + {"type": "punctuation", "start": 1785, "end": 1786}, + {"type": "punctuation", "start": 1789, "end": 1790}, + {"type": "tag", "start": 1792, "end": 1800}, + {"type": "tag", "start": 1792, "end": 1799}, + {"type": "punctuation", "start": 1792, "end": 1794}, + {"type": "punctuation", "start": 1799, "end": 1800}, + {"type": "tag", "start": 1801, "end": 1807}, + {"type": "tag", "start": 1801, "end": 1806}, + {"type": "punctuation", "start": 1801, "end": 1803}, + {"type": "punctuation", "start": 1806, "end": 1807}, + {"type": "tag", "start": 1809, "end": 1816}, + {"type": "tag", "start": 1809, "end": 1815}, + {"type": "punctuation", "start": 1809, "end": 1810}, + {"type": "punctuation", "start": 1815, "end": 1816}, + {"type": "style", "start": 1816, "end": 2197}, + {"type": "lang_css", "start": 1816, "end": 2197}, + {"type": "selector", "start": 1818, "end": 1829}, + {"type": "punctuation", "start": 1830, "end": 1831}, + {"type": "property", "start": 1834, "end": 1839}, + {"type": "punctuation", "start": 1839, "end": 1840}, + {"type": "punctuation", "start": 1844, "end": 1845}, + {"type": "punctuation", "start": 1847, "end": 1848}, + {"type": "selector", "start": 1851, "end": 1863}, + {"type": "punctuation", "start": 1864, "end": 1865}, + {"type": "property", "start": 1868, "end": 1877}, + {"type": "punctuation", "start": 1877, "end": 1878}, {"type": "punctuation", "start": 1883, "end": 1884}, - {"type": "punctuation", "start": 1884, "end": 1885}, - {"type": "punctuation", "start": 1887, "end": 1888}, - {"type": "comment", "start": 1891, "end": 1904}, - {"type": "comment", "start": 1907, "end": 1939}, - {"type": "selector", "start": 1942, "end": 1952}, - {"type": "punctuation", "start": 1953, "end": 1954}, - {"type": "property", "start": 1957, "end": 1973}, - {"type": "punctuation", "start": 1973, "end": 1974}, - {"type": "punctuation", "start": 1979, "end": 1980}, - {"type": "punctuation", "start": 1982, "end": 1983}, - {"type": "selector", "start": 1986, "end": 1993}, - {"type": "punctuation", "start": 1994, "end": 1995}, - {"type": "property", "start": 1998, "end": 2004}, + {"type": "punctuation", "start": 1886, "end": 1887}, + {"type": "selector", "start": 1890, "end": 1891}, + {"type": "punctuation", "start": 1892, "end": 1893}, + {"type": "property", "start": 1896, "end": 1906}, + {"type": "punctuation", "start": 1906, "end": 1907}, + {"type": "function", "start": 1917, "end": 1921}, + {"type": "punctuation", "start": 1921, "end": 1922}, + {"type": "punctuation", "start": 1923, "end": 1924}, + {"type": "punctuation", "start": 1926, "end": 1927}, + {"type": "punctuation", "start": 1929, "end": 1930}, + {"type": "punctuation", "start": 1934, "end": 1935}, + {"type": "punctuation", "start": 1935, "end": 1936}, + {"type": "punctuation", "start": 1938, "end": 1939}, + {"type": "comment", "start": 1942, "end": 1955}, + {"type": "comment", "start": 1958, "end": 1990}, + {"type": "selector", "start": 1993, "end": 2003}, {"type": "punctuation", "start": 2004, "end": 2005}, - {"type": "punctuation", "start": 2010, "end": 2011}, - {"type": "punctuation", "start": 2013, "end": 2014}, - {"type": "atrule", "start": 2017, "end": 2042}, - {"type": "rule", "start": 2017, "end": 2023}, + {"type": "property", "start": 2008, "end": 2024}, {"type": "punctuation", "start": 2024, "end": 2025}, - {"type": "property", "start": 2025, "end": 2034}, - {"type": "punctuation", "start": 2034, "end": 2035}, - {"type": "punctuation", "start": 2041, "end": 2042}, - {"type": "punctuation", "start": 2043, "end": 2044}, - {"type": "selector", "start": 2047, "end": 2060}, + {"type": "punctuation", "start": 2030, "end": 2031}, + {"type": "punctuation", "start": 2033, "end": 2034}, + {"type": "selector", "start": 2037, "end": 2044}, + {"type": "punctuation", "start": 2045, "end": 2046}, + {"type": "property", "start": 2049, "end": 2055}, + {"type": "punctuation", "start": 2055, "end": 2056}, {"type": "punctuation", "start": 2061, "end": 2062}, - {"type": "property", "start": 2066, "end": 2082}, - {"type": "punctuation", "start": 2082, "end": 2083}, - {"type": "punctuation", "start": 2093, "end": 2094}, - {"type": "punctuation", "start": 2097, "end": 2098}, - {"type": "punctuation", "start": 2100, "end": 2101}, - {"type": "selector", "start": 2104, "end": 2120}, - {"type": "punctuation", "start": 2121, "end": 2122}, - {"type": "property", "start": 2125, "end": 2132}, - {"type": "punctuation", "start": 2132, "end": 2133}, - {"type": "string", "start": 2134, "end": 2141}, - {"type": "punctuation", "start": 2141, "end": 2142}, + {"type": "punctuation", "start": 2064, "end": 2065}, + {"type": "atrule", "start": 2068, "end": 2093}, + {"type": "rule", "start": 2068, "end": 2074}, + {"type": "punctuation", "start": 2075, "end": 2076}, + {"type": "property", "start": 2076, "end": 2085}, + {"type": "punctuation", "start": 2085, "end": 2086}, + {"type": "punctuation", "start": 2092, "end": 2093}, + {"type": "punctuation", "start": 2094, "end": 2095}, + {"type": "selector", "start": 2098, "end": 2111}, + {"type": "punctuation", "start": 2112, "end": 2113}, + {"type": "property", "start": 2117, "end": 2133}, + {"type": "punctuation", "start": 2133, "end": 2134}, {"type": "punctuation", "start": 2144, "end": 2145}, - {"type": "tag", "start": 2146, "end": 2154}, - {"type": "tag", "start": 2146, "end": 2153}, - {"type": "punctuation", "start": 2146, "end": 2148}, - {"type": "punctuation", "start": 2153, "end": 2154} + {"type": "punctuation", "start": 2148, "end": 2149}, + {"type": "punctuation", "start": 2151, "end": 2152}, + {"type": "selector", "start": 2155, "end": 2171}, + {"type": "punctuation", "start": 2172, "end": 2173}, + {"type": "property", "start": 2176, "end": 2183}, + {"type": "punctuation", "start": 2183, "end": 2184}, + {"type": "string", "start": 2185, "end": 2192}, + {"type": "punctuation", "start": 2192, "end": 2193}, + {"type": "punctuation", "start": 2195, "end": 2196}, + {"type": "tag", "start": 2197, "end": 2205}, + {"type": "tag", "start": 2197, "end": 2204}, + {"type": "punctuation", "start": 2197, "end": 2199}, + {"type": "punctuation", "start": 2204, "end": 2205} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement | undefined = undefined;\n\tconsole.log(element_ref);\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 756c3055..fce0b773 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -30,8 +30,8 @@ 81-82 punctuation " 84-85 punctuation " 85-86 punctuation > - 86-670 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n - 86-670 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n + 86-721 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement | undefined = undefined;\n\tconsole.log(element_ref);\n + 86-721 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement | undefined = undefined;\n\tconsole.log(element_ref);\n 88-107 comment // @ts-expect-error 109-115 special_keyword import 122-126 special_keyword from @@ -147,442 +147,455 @@ 636-637 punctuation ) 637-638 punctuation ; 640-643 keyword let - 655-656 operator : - 668-669 punctuation ; - 670-679 tag - 670-678 tag - 681-685 tag

    - 681-684 tag

    - 691-698 lang_ts {HELLO} - 691-692 punctuation { - 692-697 constant HELLO - 697-698 punctuation } - 699-704 tag

    - 699-703 tag - 706-737 each {#each thing_keys as key (key)} - 706-707 punctuation { - 707-712 keyword #each - 713-724 lang_ts thing_keys - 724-726 keyword as - 727-731 lang_ts key - 731-736 lang_ts (key) - 731-732 punctuation ( - 735-736 punctuation ) - 736-737 punctuation } - 739-762 lang_ts {@const v = thing[key]} - 739-740 punctuation { - 741-746 keyword const - 749-750 operator = - 756-757 punctuation [ - 760-761 punctuation ] - 761-762 punctuation } - 764-767 lang_ts {v} - 764-765 punctuation { - 766-767 punctuation } - 768-775 each {/each} - 768-769 punctuation { - 769-774 keyword /each - 774-775 punctuation } - 777-784 lang_ts {#if c} - 777-778 punctuation { - 779-781 special_keyword if - 783-784 punctuation } - 786-827 tag - 786-792 tag - 828-835 lang_ts {:else} + 655-681 type_annotation : HTMLElement | undefined + 655-656 : : + 656-681 type HTMLElement | undefined + 657-668 type_name HTMLElement + 669-670 operator | + 671-680 keyword undefined + 681-682 operator = + 683-692 keyword undefined + 692-693 punctuation ; + 695-702 builtin console + 702-703 punctuation . + 703-706 function log + 706-707 punctuation ( + 718-719 punctuation ) + 719-720 punctuation ; + 721-730 tag + 721-729 tag + 732-736 tag

    + 732-735 tag

    + 742-749 lang_ts {HELLO} + 742-743 punctuation { + 743-748 constant HELLO + 748-749 punctuation } + 750-755 tag

    + 750-754 tag + 757-788 each {#each thing_keys as key (key)} + 757-758 punctuation { + 758-763 keyword #each + 764-775 lang_ts thing_keys + 775-777 keyword as + 778-782 lang_ts key + 782-787 lang_ts (key) + 782-783 punctuation ( + 786-787 punctuation ) + 787-788 punctuation } + 790-813 lang_ts {@const v = thing[key]} + 790-791 punctuation { + 792-797 keyword const + 800-801 operator = + 807-808 punctuation [ + 811-812 punctuation ] + 812-813 punctuation } + 815-818 lang_ts {v} + 815-816 punctuation { + 817-818 punctuation } + 819-826 each {/each} + 819-820 punctuation { + 820-825 keyword /each + 825-826 punctuation } + 828-835 lang_ts {#if c} 828-829 punctuation { - 829-830 operator : - 830-834 special_keyword else + 830-832 special_keyword if 834-835 punctuation } - 837-901 tag (c = !c)}> + 837-878 tag 837-843 tag (c = !c)} - 884-885 punctuation { - 885-886 punctuation ( - 886-887 punctuation ) - 888-890 operator => - 891-892 punctuation ( - 894-895 operator = - 896-897 operator ! - 898-899 punctuation ) - 899-900 punctuation } - 900-901 punctuation > - 904-924 lang_ts {@render children()} - 904-905 punctuation { - 905-912 decorator @render - 905-906 at @ - 906-912 function render - 913-921 function children - 921-922 punctuation ( - 922-923 punctuation ) - 923-924 punctuation } - 926-934 tag - 926-933 tag - 935-940 lang_ts {/if} + 876-878 punctuation /> + 879-886 lang_ts {:else} + 879-880 punctuation { + 880-881 operator : + 881-885 special_keyword else + 885-886 punctuation } + 888-952 tag (c = !c)}> + 888-894 tag (c = !c)} 935-936 punctuation { - 936-937 operator / - 937-939 special_keyword if - 939-940 punctuation } - 950-958 tag - 950-957 tag - 966-975 tag - 966-974 tag - 979-1011 tag - 979-985 tag -1013-1093 tag
    -1013-1017 tag
    + 942-943 punctuation ( + 945-946 operator = + 947-948 operator ! + 949-950 punctuation ) + 950-951 punctuation } + 951-952 punctuation > + 955-975 lang_ts {@render children()} + 955-956 punctuation { + 956-963 decorator @render + 956-957 at @ + 957-963 function render + 964-972 function children + 972-973 punctuation ( + 973-974 punctuation ) + 974-975 punctuation } + 977-985 tag + 977-984 tag + 986-991 lang_ts {/if} + 986-987 punctuation { + 987-988 operator / + 988-990 special_keyword if + 990-991 punctuation } +1001-1009 tag +1001-1008 tag +1017-1026 tag +1017-1025 tag +1030-1062 tag +1030-1036 tag +1064-1144 tag
    +1064-1068 tag
    -1115-1121 tag
    -1115-1120 tag
    -1123-1145 lang_ts {@render my_snippet()} -1123-1124 punctuation { -1124-1131 decorator @render -1124-1125 at @ -1125-1131 function render -1132-1142 function my_snippet -1142-1143 punctuation ( -1143-1144 punctuation ) -1144-1145 punctuation } -1147-1170 lang_ts {#snippet my_snippet()} -1147-1148 punctuation { -1157-1167 function my_snippet -1167-1168 punctuation ( -1168-1169 punctuation ) -1169-1170 punctuation } -1172-1190 tag -1203-1211 tag -1213-1223 lang_ts {/snippet} -1213-1214 punctuation { -1214-1215 operator / -1222-1223 punctuation } -1225-1266 tag
    -1225-1229 tag
    -1268-1271 tag

    -1268-1270 tag

    -1283-1287 tag

    -1283-1286 tag

    -1288-1294 tag
    -1288-1293 tag
    -1296-1330 tag

    -1296-1298 tag

    +1166-1172 tag

    +1166-1171 tag
    +1174-1196 lang_ts {@render my_snippet()} +1174-1175 punctuation { +1175-1182 decorator @render +1175-1176 at @ +1176-1182 function render +1183-1193 function my_snippet +1193-1194 punctuation ( +1194-1195 punctuation ) +1195-1196 punctuation } +1198-1221 lang_ts {#snippet my_snippet()} +1198-1199 punctuation { +1208-1218 function my_snippet +1218-1219 punctuation ( +1219-1220 punctuation ) +1220-1221 punctuation } +1223-1241 tag +1254-1262 tag +1264-1274 lang_ts {/snippet} +1264-1265 punctuation { +1265-1266 operator / +1273-1274 punctuation } +1276-1317 tag
    +1276-1280 tag
    -1337-1357 tag -1337-1342 tag -1361-1368 tag -1361-1367 tag -1369-1373 tag

    -1369-1372 tag

    -1375-1406 tag -1416-1424 tag -1427-1464 comment -1465-1468 lang_ts {a} -1465-1466 punctuation { -1467-1468 punctuation } -1469-1472 lang_ts {b} -1469-1470 punctuation { -1471-1472 punctuation } -1473-1480 lang_ts {bound} -1473-1474 punctuation { -1479-1480 punctuation } -1482-1488 tag
    -1482-1485 tag
    -1490-1496 tag
    -1490-1493 tag
    -1498-1534 tag access -1498-1502 tag -1536-1540 tag
      -1536-1539 tag
        -1542-1546 tag
      • -1542-1545 tag
      • -1557-1562 tag
      • -1557-1561 tag -1564-1568 tag
      • -1564-1567 tag
      • -1579-1584 tag
      • -1579-1583 tag -1585-1590 tag
      -1585-1589 tag
    -1592-1635 comment -1636-1641 tag
    -1636-1640 tag
    +1319-1322 tag

    +1319-1321 tag

    +1334-1338 tag

    +1334-1337 tag

    +1339-1345 tag
    +1339-1344 tag
    +1347-1381 tag

    +1347-1349 tag

    +1388-1408 tag +1388-1393 tag +1412-1419 tag +1412-1418 tag +1420-1424 tag

    +1420-1423 tag

    +1426-1457 tag +1467-1475 tag +1478-1515 comment +1516-1519 lang_ts {a} +1516-1517 punctuation { +1518-1519 punctuation } +1520-1523 lang_ts {b} +1520-1521 punctuation { +1522-1523 punctuation } +1524-1531 lang_ts {bound} +1524-1525 punctuation { +1530-1531 punctuation } +1533-1539 tag
    +1533-1536 tag
    +1541-1547 tag
    +1541-1544 tag
    +1549-1585 tag access +1549-1553 tag +1587-1591 tag
      +1587-1590 tag
        +1593-1597 tag
      • +1593-1596 tag
      • +1608-1613 tag
      • +1608-1612 tag +1615-1619 tag
      • +1615-1618 tag
      • +1630-1635 tag
      • +1630-1634 tag +1636-1641 tag
      +1636-1640 tag
    -1643-1651 tag -1689-1697 tag -1700-1707 tag -1741-1748 tag +1687-1692 tag
    +1687-1691 tag
    +1694-1702 tag +1740-1748 tag -1750-1756 tag
    -1750-1755 tag
    -1758-1765 tag -2146-2153 tag +1751-1758 tag +1792-1799 tag +1801-1807 tag
    +1801-1806 tag
    +1809-1816 tag +2197-2204 tag === STATS === -Total tokens: 565 -Sample length: 2155 characters +Total tokens: 578 +Sample length: 2206 characters Token types: - punctuation: 281 + punctuation: 285 tag: 86 - operator: 31 + operator: 32 lang_ts: 26 attr_name: 20 - keyword: 16 - function: 16 + keyword: 18 + function: 17 attr_value: 12 special_keyword: 9 property: 9 string: 8 + builtin: 8 selector: 8 - builtin: 7 comment: 5 number: 4 script: 3 @@ -591,11 +604,12 @@ Token types: namespace: 3 constant: 2 boolean: 2 + type_annotation: 2 + :: 2 + type: 2 each: 2 style: 2 lang_css: 2 - type_annotation: 1 - :: 1 - type: 1 + type_name: 1 atrule: 1 rule: 1 diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 8245ce4e..4d2709c5 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -324,7 +324,8 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; } let value = $state(''); - let element_ref: HTMLElement; + let element_ref: HTMLElement | undefined = undefined; + console.log(element_ref);

    hello {HELLO}!

    diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index 6f2aca53..faab827f 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -34,7 +34,8 @@ } let value = $state(''); - let element_ref: HTMLElement; + let element_ref: HTMLElement | undefined = undefined; + console.log(element_ref);

    hello {HELLO}!

    From 1f98042a7d342e5575e7f3e596b97441b632d33b Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 17:04:02 -0400 Subject: [PATCH 21/49] wip --- src/fixtures/generated/css/css_complex.json | 26 ++++++---------- src/fixtures/generated/css/css_complex.txt | 34 +++++++++------------ src/lib/samples/all.ts | 4 --- src/lib/samples/sample_complex.css | 4 --- 4 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/fixtures/generated/css/css_complex.json b/src/fixtures/generated/css/css_complex.json index caf89022..a5523867 100644 --- a/src/fixtures/generated/css/css_complex.json +++ b/src/fixtures/generated/css/css_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "css", "variant": "complex", - "content": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: lightblue;\n\t}\n}\n\n/* patterns in strings are not falsely detected */\n.content::before {\n\tcontent: ' /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tcursor: pointer;\n}\n\n.background /* comment*/ {\n\tbackground-image: url('data:image/svg+xml...');\n}\n", + "content": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: lightblue;\n\t}\n}\n\n/* patterns in strings are not falsely detected */\n.content::before {\n\tcontent: ' /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n", "filepath": "src/lib/samples/sample_complex.css" }, "tokens": [ @@ -68,21 +68,15 @@ {"type": "punctuation", "start": 425, "end": 426}, {"type": "selector", "start": 428, "end": 454}, {"type": "punctuation", "start": 455, "end": 456}, - {"type": "property", "start": 458, "end": 464}, - {"type": "punctuation", "start": 464, "end": 465}, - {"type": "punctuation", "start": 473, "end": 474}, - {"type": "punctuation", "start": 475, "end": 476}, - {"type": "comment", "start": 491, "end": 503}, + {"type": "property", "start": 458, "end": 474}, + {"type": "punctuation", "start": 474, "end": 475}, + {"type": "url", "start": 476, "end": 504}, + {"type": "function", "start": 476, "end": 479}, + {"type": "punctuation", "start": 479, "end": 480}, + {"type": "string", "start": 480, "end": 503}, + {"type": "punctuation", "start": 503, "end": 504}, {"type": "punctuation", "start": 504, "end": 505}, - {"type": "property", "start": 507, "end": 523}, - {"type": "punctuation", "start": 523, "end": 524}, - {"type": "url", "start": 525, "end": 553}, - {"type": "function", "start": 525, "end": 528}, - {"type": "punctuation", "start": 528, "end": 529}, - {"type": "string", "start": 529, "end": 552}, - {"type": "punctuation", "start": 552, "end": 553}, - {"type": "punctuation", "start": 553, "end": 554}, - {"type": "punctuation", "start": 555, "end": 556} + {"type": "punctuation", "start": 506, "end": 507} ], - "html": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n</style>\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: lightblue;\n\t}\n}\n\n/* patterns in strings are not falsely detected */\n.content::before {\n\tcontent: '</style> /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tcursor: pointer;\n}\n\n.background /* comment*/ {\n\tbackground-image: url('data:image/svg+xml...');\n}\n" + "html": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n</style>\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: lightblue;\n\t}\n}\n\n/* patterns in strings are not falsely detected */\n.content::before {\n\tcontent: '</style> /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n" } diff --git a/src/fixtures/generated/css/css_complex.txt b/src/fixtures/generated/css/css_complex.txt index 9ae37ae4..5d68133d 100644 --- a/src/fixtures/generated/css/css_complex.txt +++ b/src/fixtures/generated/css/css_complex.txt @@ -61,31 +61,25 @@ 425-426 punctuation } 428-454 selector .attr[title='Click: here'] 455-456 punctuation { - 458-464 property cursor - 464-465 punctuation : - 473-474 punctuation ; - 475-476 punctuation } - 491-503 comment /* comment*/ - 504-505 punctuation { - 507-523 property background-image - 523-524 punctuation : - 525-553 url url('data:image/svg+xml...') - 525-528 function url - 528-529 punctuation ( - 529-552 string 'data:image/svg+xml...' - 552-553 punctuation ) - 553-554 punctuation ; - 555-556 punctuation } + 458-474 property background-image + 474-475 punctuation : + 476-504 url url('data:image/svg+xml...') + 476-479 function url + 479-480 punctuation ( + 480-503 string 'data:image/svg+xml...' + 503-504 punctuation ) + 504-505 punctuation ; + 506-507 punctuation } === STATS === -Total tokens: 77 -Sample length: 557 characters +Total tokens: 71 +Sample length: 508 characters Token types: - punctuation: 48 - property: 10 + punctuation: 44 + property: 9 selector: 8 - comment: 4 + comment: 3 function: 2 string: 2 atrule: 1 diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 4d2709c5..2129bd7a 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -75,10 +75,6 @@ div > p { } .attr[title='Click: here'] { - cursor: pointer; -} - -.background /* comment*/ { background-image: url('data:image/svg+xml...'); } `, diff --git a/src/lib/samples/sample_complex.css b/src/lib/samples/sample_complex.css index 6c19b1a2..a31ec572 100644 --- a/src/lib/samples/sample_complex.css +++ b/src/lib/samples/sample_complex.css @@ -41,9 +41,5 @@ div > p { } .attr[title='Click: here'] { - cursor: pointer; -} - -.background /* comment*/ { background-image: url('data:image/svg+xml...'); } From cca09e42ae193fb73c36f29e0528aa144703bfda Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 17:16:30 -0400 Subject: [PATCH 22/49] wip --- src/fixtures/generated/css/css_complex.json | 49 +- src/fixtures/generated/css/css_complex.txt | 57 +- .../generated/svelte/svelte_complex.json | 866 ++++++++--------- .../generated/svelte/svelte_complex.txt | 920 +++++++++--------- src/fixtures/helpers.ts | 2 +- src/lib/samples/all.ts | 14 +- src/lib/samples/sample_complex.css | 3 +- src/lib/samples/sample_complex.svelte | 13 +- 8 files changed, 941 insertions(+), 983 deletions(-) diff --git a/src/fixtures/generated/css/css_complex.json b/src/fixtures/generated/css/css_complex.json index a5523867..d5804695 100644 --- a/src/fixtures/generated/css/css_complex.json +++ b/src/fixtures/generated/css/css_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "css", "variant": "complex", - "content": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: lightblue;\n\t}\n}\n\n/* patterns in strings are not falsely detected */\n.content::before {\n\tcontent: ' /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n", + "content": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: light-dark(lightblue, darkblue);\n\t}\n}\n\n.content::before {\n\tcontent: ' /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n", "filepath": "src/lib/samples/sample_complex.css" }, "tokens": [ @@ -55,28 +55,31 @@ {"type": "punctuation", "start": 274, "end": 275}, {"type": "property", "start": 278, "end": 294}, {"type": "punctuation", "start": 294, "end": 295}, - {"type": "punctuation", "start": 305, "end": 306}, - {"type": "punctuation", "start": 308, "end": 309}, - {"type": "punctuation", "start": 310, "end": 311}, - {"type": "comment", "start": 313, "end": 363}, - {"type": "selector", "start": 364, "end": 380}, - {"type": "punctuation", "start": 381, "end": 382}, - {"type": "property", "start": 384, "end": 391}, - {"type": "punctuation", "start": 391, "end": 392}, - {"type": "string", "start": 393, "end": 423}, - {"type": "punctuation", "start": 423, "end": 424}, - {"type": "punctuation", "start": 425, "end": 426}, - {"type": "selector", "start": 428, "end": 454}, - {"type": "punctuation", "start": 455, "end": 456}, - {"type": "property", "start": 458, "end": 474}, + {"type": "function", "start": 296, "end": 306}, + {"type": "punctuation", "start": 306, "end": 307}, + {"type": "punctuation", "start": 316, "end": 317}, + {"type": "punctuation", "start": 326, "end": 327}, + {"type": "punctuation", "start": 327, "end": 328}, + {"type": "punctuation", "start": 330, "end": 331}, + {"type": "punctuation", "start": 332, "end": 333}, + {"type": "selector", "start": 335, "end": 351}, + {"type": "punctuation", "start": 352, "end": 353}, + {"type": "property", "start": 355, "end": 362}, + {"type": "punctuation", "start": 362, "end": 363}, + {"type": "string", "start": 364, "end": 394}, + {"type": "punctuation", "start": 394, "end": 395}, + {"type": "punctuation", "start": 396, "end": 397}, + {"type": "selector", "start": 399, "end": 425}, + {"type": "punctuation", "start": 426, "end": 427}, + {"type": "property", "start": 429, "end": 445}, + {"type": "punctuation", "start": 445, "end": 446}, + {"type": "url", "start": 447, "end": 475}, + {"type": "function", "start": 447, "end": 450}, + {"type": "punctuation", "start": 450, "end": 451}, + {"type": "string", "start": 451, "end": 474}, {"type": "punctuation", "start": 474, "end": 475}, - {"type": "url", "start": 476, "end": 504}, - {"type": "function", "start": 476, "end": 479}, - {"type": "punctuation", "start": 479, "end": 480}, - {"type": "string", "start": 480, "end": 503}, - {"type": "punctuation", "start": 503, "end": 504}, - {"type": "punctuation", "start": 504, "end": 505}, - {"type": "punctuation", "start": 506, "end": 507} + {"type": "punctuation", "start": 475, "end": 476}, + {"type": "punctuation", "start": 477, "end": 478} ], - "html": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n</style>\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: lightblue;\n\t}\n}\n\n/* patterns in strings are not falsely detected */\n.content::before {\n\tcontent: '</style> /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n" + "html": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n</style>\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: light-dark(lightblue, darkblue);\n\t}\n}\n\n.content::before {\n\tcontent: '</style> /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n" } diff --git a/src/fixtures/generated/css/css_complex.txt b/src/fixtures/generated/css/css_complex.txt index 5d68133d..08d0b74b 100644 --- a/src/fixtures/generated/css/css_complex.txt +++ b/src/fixtures/generated/css/css_complex.txt @@ -48,39 +48,42 @@ 274-275 punctuation { 278-294 property background-color 294-295 punctuation : - 305-306 punctuation ; - 308-309 punctuation } - 310-311 punctuation } - 313-363 comment /* patterns in strings are not falsely detected */ - 364-380 selector .content::before - 381-382 punctuation { - 384-391 property content - 391-392 punctuation : - 393-423 string ' /* not a comment */' - 423-424 punctuation ; - 425-426 punctuation } - 428-454 selector .attr[title='Click: here'] - 455-456 punctuation { - 458-474 property background-image - 474-475 punctuation : - 476-504 url url('data:image/svg+xml...') - 476-479 function url - 479-480 punctuation ( - 480-503 string 'data:image/svg+xml...' - 503-504 punctuation ) - 504-505 punctuation ; - 506-507 punctuation } + 296-306 function light-dark + 306-307 punctuation ( + 316-317 punctuation , + 326-327 punctuation ) + 327-328 punctuation ; + 330-331 punctuation } + 332-333 punctuation } + 335-351 selector .content::before + 352-353 punctuation { + 355-362 property content + 362-363 punctuation : + 364-394 string ' /* not a comment */' + 394-395 punctuation ; + 396-397 punctuation } + 399-425 selector .attr[title='Click: here'] + 426-427 punctuation { + 429-445 property background-image + 445-446 punctuation : + 447-475 url url('data:image/svg+xml...') + 447-450 function url + 450-451 punctuation ( + 451-474 string 'data:image/svg+xml...' + 474-475 punctuation ) + 475-476 punctuation ; + 477-478 punctuation } === STATS === -Total tokens: 71 -Sample length: 508 characters +Total tokens: 74 +Sample length: 479 characters Token types: - punctuation: 44 + punctuation: 47 property: 9 selector: 8 - comment: 3 - function: 2 + function: 3 + comment: 2 string: 2 atrule: 1 rule: 1 diff --git a/src/fixtures/generated/svelte/svelte_complex.json b/src/fixtures/generated/svelte/svelte_complex.json index aaeb6cfa..c7a54ab6 100644 --- a/src/fixtures/generated/svelte/svelte_complex.json +++ b/src/fixtures/generated/svelte/svelte_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "svelte", "variant": "complex", - "content": "\n\n\n\n

    hello {HELLO}!

    \n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n{@html 'raw html'}\n\n\n\n
    \n\tinteractive element\n
    \n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t\n{/snippet}\n\n
    \n\t

    hello world!

    \n
    \n\n

    \n\tsome text\n

    \n\n\n\n\n{a}\n{b}\n{bound}\n\n
    \n\n
    \n\n\"access\"\n\n
      \n\t
    • list item 1
    • \n\t
    • list item 2
    • \n
    \n\n\n
    \n\t\n\t\n
    \n\n\n", + "content": "\n\n\n\n

    hello {HELLO}!

    \n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n{@html 'raw html'}\n\n\n\n
    \n\tinteractive element\n
    \n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t\n{/snippet}\n\n
    \n\t

    hello world!

    \n
    \n\n

    \n\tsome text\n

    \n\n\n\n\n{a}\n{b}\n{bound}\n\n
    \n\n
    \n\n\"access\"\n\n
      \n\t
    • list item 1
    • \n\t
    • list item 2
    • \n
    \n\n\n
    \n\t\n\t\n
    \n\n\n", "filepath": "src/lib/samples/sample_complex.svelte" }, "tokens": [ @@ -37,8 +37,8 @@ {"type": "punctuation", "start": 81, "end": 82}, {"type": "punctuation", "start": 84, "end": 85}, {"type": "punctuation", "start": 85, "end": 86}, - {"type": "script", "start": 86, "end": 721}, - {"type": "lang_ts", "start": 86, "end": 721}, + {"type": "script", "start": 86, "end": 635}, + {"type": "lang_ts", "start": 86, "end": 635}, {"type": "comment", "start": 88, "end": 107}, {"type": "special_keyword", "start": 109, "end": 115}, {"type": "special_keyword", "start": 122, "end": 126}, @@ -120,470 +120,450 @@ {"type": "boolean", "start": 479, "end": 483}, {"type": "punctuation", "start": 483, "end": 484}, {"type": "punctuation", "start": 484, "end": 485}, - {"type": "keyword", "start": 488, "end": 496}, - {"type": "function", "start": 497, "end": 507}, + {"type": "keyword", "start": 488, "end": 493}, + {"type": "function_variable", "start": 494, "end": 504}, + {"type": "operator", "start": 505, "end": 506}, {"type": "punctuation", "start": 507, "end": 508}, - {"type": "operator", "start": 514, "end": 515}, - {"type": "builtin", "start": 516, "end": 522}, - {"type": "punctuation", "start": 522, "end": 523}, - {"type": "operator", "start": 530, "end": 531}, - {"type": "builtin", "start": 532, "end": 538}, - {"type": "punctuation", "start": 538, "end": 539}, - {"type": "punctuation", "start": 540, "end": 541}, - {"type": "special_keyword", "start": 544, "end": 550}, - {"type": "punctuation", "start": 551, "end": 552}, - {"type": "operator", "start": 553, "end": 554}, - {"type": "punctuation", "start": 566, "end": 567}, - {"type": "operator", "start": 568, "end": 570}, - {"type": "punctuation", "start": 571, "end": 572}, - {"type": "builtin", "start": 576, "end": 583}, - {"type": "punctuation", "start": 583, "end": 584}, - {"type": "function", "start": 584, "end": 587}, - {"type": "punctuation", "start": 587, "end": 588}, - {"type": "punctuation", "start": 594, "end": 595}, + {"type": "operator", "start": 511, "end": 512}, + {"type": "builtin", "start": 513, "end": 519}, + {"type": "punctuation", "start": 519, "end": 520}, + {"type": "operator", "start": 524, "end": 525}, + {"type": "builtin", "start": 526, "end": 532}, + {"type": "punctuation", "start": 532, "end": 533}, + {"type": "operator", "start": 534, "end": 536}, + {"type": "punctuation", "start": 537, "end": 538}, + {"type": "operator", "start": 539, "end": 540}, + {"type": "punctuation", "start": 552, "end": 553}, + {"type": "operator", "start": 554, "end": 556}, + {"type": "punctuation", "start": 557, "end": 558}, + {"type": "punctuation", "start": 572, "end": 573}, + {"type": "punctuation", "start": 575, "end": 576}, + {"type": "punctuation", "start": 576, "end": 577}, + {"type": "keyword", "start": 580, "end": 583}, + {"type": "operator", "start": 590, "end": 591}, + {"type": "function", "start": 592, "end": 598}, + {"type": "punctuation", "start": 598, "end": 599}, + {"type": "string", "start": 599, "end": 601}, + {"type": "punctuation", "start": 601, "end": 602}, {"type": "punctuation", "start": 602, "end": 603}, - {"type": "punctuation", "start": 603, "end": 604}, - {"type": "punctuation", "start": 607, "end": 608}, - {"type": "punctuation", "start": 608, "end": 609}, - {"type": "punctuation", "start": 611, "end": 612}, - {"type": "keyword", "start": 615, "end": 618}, - {"type": "operator", "start": 625, "end": 626}, - {"type": "function", "start": 627, "end": 633}, + {"type": "keyword", "start": 605, "end": 608}, + {"type": "operator", "start": 620, "end": 621}, {"type": "punctuation", "start": 633, "end": 634}, - {"type": "string", "start": 634, "end": 636}, - {"type": "punctuation", "start": 636, "end": 637}, - {"type": "punctuation", "start": 637, "end": 638}, - {"type": "keyword", "start": 640, "end": 643}, - {"type": "type_annotation", "start": 655, "end": 681}, - {"type": ":", "start": 655, "end": 656}, - {"type": "type", "start": 656, "end": 681}, - {"type": "type_name", "start": 657, "end": 668}, - {"type": "operator", "start": 669, "end": 670}, - {"type": "keyword", "start": 671, "end": 680}, - {"type": "operator", "start": 681, "end": 682}, - {"type": "keyword", "start": 683, "end": 692}, - {"type": "punctuation", "start": 692, "end": 693}, - {"type": "builtin", "start": 695, "end": 702}, - {"type": "punctuation", "start": 702, "end": 703}, - {"type": "function", "start": 703, "end": 706}, - {"type": "punctuation", "start": 706, "end": 707}, - {"type": "punctuation", "start": 718, "end": 719}, - {"type": "punctuation", "start": 719, "end": 720}, - {"type": "tag", "start": 721, "end": 730}, - {"type": "tag", "start": 721, "end": 729}, - {"type": "punctuation", "start": 721, "end": 723}, + {"type": "tag", "start": 635, "end": 644}, + {"type": "tag", "start": 635, "end": 643}, + {"type": "punctuation", "start": 635, "end": 637}, + {"type": "punctuation", "start": 643, "end": 644}, + {"type": "tag", "start": 646, "end": 650}, + {"type": "tag", "start": 646, "end": 649}, + {"type": "punctuation", "start": 646, "end": 647}, + {"type": "punctuation", "start": 649, "end": 650}, + {"type": "lang_ts", "start": 656, "end": 663}, + {"type": "punctuation", "start": 656, "end": 657}, + {"type": "constant", "start": 657, "end": 662}, + {"type": "punctuation", "start": 662, "end": 663}, + {"type": "tag", "start": 664, "end": 669}, + {"type": "tag", "start": 664, "end": 668}, + {"type": "punctuation", "start": 664, "end": 666}, + {"type": "punctuation", "start": 668, "end": 669}, + {"type": "each", "start": 671, "end": 702}, + {"type": "punctuation", "start": 671, "end": 672}, + {"type": "keyword", "start": 672, "end": 677}, + {"type": "lang_ts", "start": 678, "end": 689}, + {"type": "keyword", "start": 689, "end": 691}, + {"type": "lang_ts", "start": 692, "end": 696}, + {"type": "lang_ts", "start": 696, "end": 701}, + {"type": "punctuation", "start": 696, "end": 697}, + {"type": "punctuation", "start": 700, "end": 701}, + {"type": "punctuation", "start": 701, "end": 702}, + {"type": "lang_ts", "start": 704, "end": 727}, + {"type": "punctuation", "start": 704, "end": 705}, + {"type": "keyword", "start": 706, "end": 711}, + {"type": "operator", "start": 714, "end": 715}, + {"type": "punctuation", "start": 721, "end": 722}, + {"type": "punctuation", "start": 725, "end": 726}, + {"type": "punctuation", "start": 726, "end": 727}, + {"type": "lang_ts", "start": 729, "end": 732}, {"type": "punctuation", "start": 729, "end": 730}, - {"type": "tag", "start": 732, "end": 736}, - {"type": "tag", "start": 732, "end": 735}, - {"type": "punctuation", "start": 732, "end": 733}, - {"type": "punctuation", "start": 735, "end": 736}, + {"type": "punctuation", "start": 731, "end": 732}, + {"type": "each", "start": 733, "end": 740}, + {"type": "punctuation", "start": 733, "end": 734}, + {"type": "keyword", "start": 734, "end": 739}, + {"type": "punctuation", "start": 739, "end": 740}, {"type": "lang_ts", "start": 742, "end": 749}, {"type": "punctuation", "start": 742, "end": 743}, - {"type": "constant", "start": 743, "end": 748}, + {"type": "special_keyword", "start": 744, "end": 746}, {"type": "punctuation", "start": 748, "end": 749}, - {"type": "tag", "start": 750, "end": 755}, - {"type": "tag", "start": 750, "end": 754}, - {"type": "punctuation", "start": 750, "end": 752}, - {"type": "punctuation", "start": 754, "end": 755}, - {"type": "each", "start": 757, "end": 788}, - {"type": "punctuation", "start": 757, "end": 758}, - {"type": "keyword", "start": 758, "end": 763}, - {"type": "lang_ts", "start": 764, "end": 775}, - {"type": "keyword", "start": 775, "end": 777}, - {"type": "lang_ts", "start": 778, "end": 782}, - {"type": "lang_ts", "start": 782, "end": 787}, - {"type": "punctuation", "start": 782, "end": 783}, + {"type": "tag", "start": 751, "end": 792}, + {"type": "tag", "start": 751, "end": 757}, + {"type": "punctuation", "start": 751, "end": 752}, + {"type": "attr_name", "start": 758, "end": 769}, + {"type": "attr_value", "start": 769, "end": 773}, + {"type": "punctuation", "start": 769, "end": 770}, + {"type": "punctuation", "start": 770, "end": 771}, + {"type": "punctuation", "start": 772, "end": 773}, + {"type": "attr_name", "start": 774, "end": 786}, + {"type": "lang_ts", "start": 786, "end": 789}, {"type": "punctuation", "start": 786, "end": 787}, - {"type": "punctuation", "start": 787, "end": 788}, - {"type": "lang_ts", "start": 790, "end": 813}, - {"type": "punctuation", "start": 790, "end": 791}, - {"type": "keyword", "start": 792, "end": 797}, - {"type": "operator", "start": 800, "end": 801}, - {"type": "punctuation", "start": 807, "end": 808}, - {"type": "punctuation", "start": 811, "end": 812}, - {"type": "punctuation", "start": 812, "end": 813}, - {"type": "lang_ts", "start": 815, "end": 818}, - {"type": "punctuation", "start": 815, "end": 816}, - {"type": "punctuation", "start": 817, "end": 818}, - {"type": "each", "start": 819, "end": 826}, - {"type": "punctuation", "start": 819, "end": 820}, - {"type": "keyword", "start": 820, "end": 825}, - {"type": "punctuation", "start": 825, "end": 826}, - {"type": "lang_ts", "start": 828, "end": 835}, - {"type": "punctuation", "start": 828, "end": 829}, - {"type": "special_keyword", "start": 830, "end": 832}, - {"type": "punctuation", "start": 834, "end": 835}, - {"type": "tag", "start": 837, "end": 878}, - {"type": "tag", "start": 837, "end": 843}, + {"type": "number", "start": 787, "end": 788}, + {"type": "punctuation", "start": 788, "end": 789}, + {"type": "punctuation", "start": 790, "end": 792}, + {"type": "lang_ts", "start": 793, "end": 800}, + {"type": "punctuation", "start": 793, "end": 794}, + {"type": "operator", "start": 794, "end": 795}, + {"type": "special_keyword", "start": 795, "end": 799}, + {"type": "punctuation", "start": 799, "end": 800}, + {"type": "tag", "start": 802, "end": 866}, + {"type": "tag", "start": 802, "end": 808}, + {"type": "punctuation", "start": 802, "end": 803}, + {"type": "attr_name", "start": 809, "end": 820}, + {"type": "attr_value", "start": 820, "end": 824}, + {"type": "punctuation", "start": 820, "end": 821}, + {"type": "punctuation", "start": 821, "end": 822}, + {"type": "punctuation", "start": 823, "end": 824}, + {"type": "attr_name", "start": 825, "end": 837}, + {"type": "lang_ts", "start": 837, "end": 840}, {"type": "punctuation", "start": 837, "end": 838}, - {"type": "attr_name", "start": 844, "end": 855}, - {"type": "attr_value", "start": 855, "end": 859}, - {"type": "punctuation", "start": 855, "end": 856}, + {"type": "number", "start": 838, "end": 839}, + {"type": "punctuation", "start": 839, "end": 840}, + {"type": "attr_name", "start": 841, "end": 849}, + {"type": "lang_ts", "start": 849, "end": 865}, + {"type": "punctuation", "start": 849, "end": 850}, + {"type": "punctuation", "start": 850, "end": 851}, + {"type": "punctuation", "start": 851, "end": 852}, + {"type": "operator", "start": 853, "end": 855}, {"type": "punctuation", "start": 856, "end": 857}, - {"type": "punctuation", "start": 858, "end": 859}, - {"type": "attr_name", "start": 860, "end": 872}, - {"type": "lang_ts", "start": 872, "end": 875}, - {"type": "punctuation", "start": 872, "end": 873}, - {"type": "number", "start": 873, "end": 874}, - {"type": "punctuation", "start": 874, "end": 875}, - {"type": "punctuation", "start": 876, "end": 878}, - {"type": "lang_ts", "start": 879, "end": 886}, - {"type": "punctuation", "start": 879, "end": 880}, - {"type": "operator", "start": 880, "end": 881}, - {"type": "special_keyword", "start": 881, "end": 885}, - {"type": "punctuation", "start": 885, "end": 886}, - {"type": "tag", "start": 888, "end": 952}, - {"type": "tag", "start": 888, "end": 894}, + {"type": "operator", "start": 859, "end": 860}, + {"type": "operator", "start": 861, "end": 862}, + {"type": "punctuation", "start": 863, "end": 864}, + {"type": "punctuation", "start": 864, "end": 865}, + {"type": "punctuation", "start": 865, "end": 866}, + {"type": "lang_ts", "start": 869, "end": 889}, + {"type": "punctuation", "start": 869, "end": 870}, + {"type": "decorator", "start": 870, "end": 877}, + {"type": "at", "start": 870, "end": 871}, + {"type": "function", "start": 871, "end": 877}, + {"type": "function", "start": 878, "end": 886}, + {"type": "punctuation", "start": 886, "end": 887}, + {"type": "punctuation", "start": 887, "end": 888}, {"type": "punctuation", "start": 888, "end": 889}, - {"type": "attr_name", "start": 895, "end": 906}, - {"type": "attr_value", "start": 906, "end": 910}, - {"type": "punctuation", "start": 906, "end": 907}, - {"type": "punctuation", "start": 907, "end": 908}, - {"type": "punctuation", "start": 909, "end": 910}, - {"type": "attr_name", "start": 911, "end": 923}, - {"type": "lang_ts", "start": 923, "end": 926}, - {"type": "punctuation", "start": 923, "end": 924}, - {"type": "number", "start": 924, "end": 925}, - {"type": "punctuation", "start": 925, "end": 926}, - {"type": "attr_name", "start": 927, "end": 935}, - {"type": "lang_ts", "start": 935, "end": 951}, - {"type": "punctuation", "start": 935, "end": 936}, - {"type": "punctuation", "start": 936, "end": 937}, - {"type": "punctuation", "start": 937, "end": 938}, - {"type": "operator", "start": 939, "end": 941}, - {"type": "punctuation", "start": 942, "end": 943}, - {"type": "operator", "start": 945, "end": 946}, - {"type": "operator", "start": 947, "end": 948}, - {"type": "punctuation", "start": 949, "end": 950}, - {"type": "punctuation", "start": 950, "end": 951}, - {"type": "punctuation", "start": 951, "end": 952}, - {"type": "lang_ts", "start": 955, "end": 975}, - {"type": "punctuation", "start": 955, "end": 956}, - {"type": "decorator", "start": 956, "end": 963}, - {"type": "at", "start": 956, "end": 957}, - {"type": "function", "start": 957, "end": 963}, - {"type": "function", "start": 964, "end": 972}, + {"type": "tag", "start": 891, "end": 899}, + {"type": "tag", "start": 891, "end": 898}, + {"type": "punctuation", "start": 891, "end": 893}, + {"type": "punctuation", "start": 898, "end": 899}, + {"type": "lang_ts", "start": 900, "end": 905}, + {"type": "punctuation", "start": 900, "end": 901}, + {"type": "operator", "start": 901, "end": 902}, + {"type": "special_keyword", "start": 902, "end": 904}, + {"type": "punctuation", "start": 904, "end": 905}, + {"type": "tag", "start": 915, "end": 923}, + {"type": "tag", "start": 915, "end": 922}, + {"type": "punctuation", "start": 915, "end": 916}, + {"type": "punctuation", "start": 922, "end": 923}, + {"type": "tag", "start": 931, "end": 940}, + {"type": "tag", "start": 931, "end": 939}, + {"type": "punctuation", "start": 931, "end": 933}, + {"type": "punctuation", "start": 939, "end": 940}, + {"type": "tag", "start": 944, "end": 976}, + {"type": "tag", "start": 944, "end": 950}, + {"type": "punctuation", "start": 944, "end": 945}, + {"type": "attr_name", "start": 951, "end": 961}, + {"type": "namespace", "start": 951, "end": 956}, + {"type": "attr_name", "start": 962, "end": 966}, + {"type": "attr_value", "start": 966, "end": 973}, + {"type": "punctuation", "start": 966, "end": 967}, + {"type": "punctuation", "start": 967, "end": 968}, {"type": "punctuation", "start": 972, "end": 973}, - {"type": "punctuation", "start": 973, "end": 974}, - {"type": "punctuation", "start": 974, "end": 975}, - {"type": "tag", "start": 977, "end": 985}, - {"type": "tag", "start": 977, "end": 984}, - {"type": "punctuation", "start": 977, "end": 979}, - {"type": "punctuation", "start": 984, "end": 985}, - {"type": "lang_ts", "start": 986, "end": 991}, - {"type": "punctuation", "start": 986, "end": 987}, - {"type": "operator", "start": 987, "end": 988}, - {"type": "special_keyword", "start": 988, "end": 990}, - {"type": "punctuation", "start": 990, "end": 991}, - {"type": "tag", "start": 1001, "end": 1009}, - {"type": "tag", "start": 1001, "end": 1008}, - {"type": "punctuation", "start": 1001, "end": 1002}, - {"type": "punctuation", "start": 1008, "end": 1009}, - {"type": "tag", "start": 1017, "end": 1026}, - {"type": "tag", "start": 1017, "end": 1025}, - {"type": "punctuation", "start": 1017, "end": 1019}, - {"type": "punctuation", "start": 1025, "end": 1026}, - {"type": "tag", "start": 1030, "end": 1062}, - {"type": "tag", "start": 1030, "end": 1036}, - {"type": "punctuation", "start": 1030, "end": 1031}, - {"type": "attr_name", "start": 1037, "end": 1047}, - {"type": "namespace", "start": 1037, "end": 1042}, - {"type": "attr_name", "start": 1048, "end": 1052}, - {"type": "attr_value", "start": 1052, "end": 1059}, - {"type": "punctuation", "start": 1052, "end": 1053}, - {"type": "punctuation", "start": 1053, "end": 1054}, - {"type": "punctuation", "start": 1058, "end": 1059}, - {"type": "punctuation", "start": 1060, "end": 1062}, - {"type": "tag", "start": 1064, "end": 1144}, - {"type": "tag", "start": 1064, "end": 1068}, - {"type": "punctuation", "start": 1064, "end": 1065}, - {"type": "attr_name", "start": 1069, "end": 1079}, - {"type": "namespace", "start": 1069, "end": 1074}, - {"type": "lang_ts", "start": 1079, "end": 1092}, - {"type": "punctuation", "start": 1079, "end": 1080}, - {"type": "punctuation", "start": 1091, "end": 1092}, - {"type": "attr_name", "start": 1093, "end": 1106}, - {"type": "namespace", "start": 1093, "end": 1099}, - {"type": "lang_ts", "start": 1106, "end": 1109}, - {"type": "punctuation", "start": 1106, "end": 1107}, + {"type": "punctuation", "start": 974, "end": 976}, + {"type": "tag", "start": 978, "end": 1058}, + {"type": "tag", "start": 978, "end": 982}, + {"type": "punctuation", "start": 978, "end": 979}, + {"type": "attr_name", "start": 983, "end": 993}, + {"type": "namespace", "start": 983, "end": 988}, + {"type": "lang_ts", "start": 993, "end": 1006}, + {"type": "punctuation", "start": 993, "end": 994}, + {"type": "punctuation", "start": 1005, "end": 1006}, + {"type": "attr_name", "start": 1007, "end": 1020}, + {"type": "namespace", "start": 1007, "end": 1013}, + {"type": "lang_ts", "start": 1020, "end": 1023}, + {"type": "punctuation", "start": 1020, "end": 1021}, + {"type": "punctuation", "start": 1022, "end": 1023}, + {"type": "lang_ts", "start": 1024, "end": 1057}, + {"type": "punctuation", "start": 1024, "end": 1025}, + {"type": "decorator", "start": 1025, "end": 1032}, + {"type": "at", "start": 1025, "end": 1026}, + {"type": "function", "start": 1026, "end": 1032}, + {"type": "function", "start": 1033, "end": 1043}, + {"type": "punctuation", "start": 1043, "end": 1044}, + {"type": "string", "start": 1044, "end": 1051}, + {"type": "punctuation", "start": 1051, "end": 1052}, + {"type": "number", "start": 1053, "end": 1055}, + {"type": "punctuation", "start": 1055, "end": 1056}, + {"type": "punctuation", "start": 1056, "end": 1057}, + {"type": "punctuation", "start": 1057, "end": 1058}, + {"type": "tag", "start": 1080, "end": 1086}, + {"type": "tag", "start": 1080, "end": 1085}, + {"type": "punctuation", "start": 1080, "end": 1082}, + {"type": "punctuation", "start": 1085, "end": 1086}, + {"type": "lang_ts", "start": 1088, "end": 1110}, + {"type": "punctuation", "start": 1088, "end": 1089}, + {"type": "decorator", "start": 1089, "end": 1096}, + {"type": "at", "start": 1089, "end": 1090}, + {"type": "function", "start": 1090, "end": 1096}, + {"type": "function", "start": 1097, "end": 1107}, + {"type": "punctuation", "start": 1107, "end": 1108}, {"type": "punctuation", "start": 1108, "end": 1109}, - {"type": "lang_ts", "start": 1110, "end": 1143}, - {"type": "punctuation", "start": 1110, "end": 1111}, - {"type": "decorator", "start": 1111, "end": 1118}, - {"type": "at", "start": 1111, "end": 1112}, - {"type": "function", "start": 1112, "end": 1118}, - {"type": "function", "start": 1119, "end": 1129}, - {"type": "punctuation", "start": 1129, "end": 1130}, - {"type": "string", "start": 1130, "end": 1137}, + {"type": "punctuation", "start": 1109, "end": 1110}, + {"type": "lang_ts", "start": 1112, "end": 1135}, + {"type": "punctuation", "start": 1112, "end": 1113}, + {"type": "function", "start": 1122, "end": 1132}, + {"type": "punctuation", "start": 1132, "end": 1133}, + {"type": "punctuation", "start": 1133, "end": 1134}, + {"type": "punctuation", "start": 1134, "end": 1135}, + {"type": "tag", "start": 1137, "end": 1155}, + {"type": "tag", "start": 1137, "end": 1144}, {"type": "punctuation", "start": 1137, "end": 1138}, - {"type": "number", "start": 1139, "end": 1141}, - {"type": "punctuation", "start": 1141, "end": 1142}, - {"type": "punctuation", "start": 1142, "end": 1143}, - {"type": "punctuation", "start": 1143, "end": 1144}, - {"type": "tag", "start": 1166, "end": 1172}, - {"type": "tag", "start": 1166, "end": 1171}, - {"type": "punctuation", "start": 1166, "end": 1168}, - {"type": "punctuation", "start": 1171, "end": 1172}, - {"type": "lang_ts", "start": 1174, "end": 1196}, - {"type": "punctuation", "start": 1174, "end": 1175}, - {"type": "decorator", "start": 1175, "end": 1182}, - {"type": "at", "start": 1175, "end": 1176}, - {"type": "function", "start": 1176, "end": 1182}, - {"type": "function", "start": 1183, "end": 1193}, - {"type": "punctuation", "start": 1193, "end": 1194}, - {"type": "punctuation", "start": 1194, "end": 1195}, - {"type": "punctuation", "start": 1195, "end": 1196}, - {"type": "lang_ts", "start": 1198, "end": 1221}, - {"type": "punctuation", "start": 1198, "end": 1199}, - {"type": "function", "start": 1208, "end": 1218}, + {"type": "lang_ts", "start": 1145, "end": 1154}, + {"type": "punctuation", "start": 1145, "end": 1146}, + {"type": "punctuation", "start": 1153, "end": 1154}, + {"type": "punctuation", "start": 1154, "end": 1155}, + {"type": "tag", "start": 1168, "end": 1177}, + {"type": "tag", "start": 1168, "end": 1176}, + {"type": "punctuation", "start": 1168, "end": 1170}, + {"type": "punctuation", "start": 1176, "end": 1177}, + {"type": "lang_ts", "start": 1178, "end": 1188}, + {"type": "punctuation", "start": 1178, "end": 1179}, + {"type": "operator", "start": 1179, "end": 1180}, + {"type": "punctuation", "start": 1187, "end": 1188}, + {"type": "tag", "start": 1190, "end": 1231}, + {"type": "tag", "start": 1190, "end": 1194}, + {"type": "punctuation", "start": 1190, "end": 1191}, + {"type": "attr_name", "start": 1195, "end": 1200}, + {"type": "attr_value", "start": 1200, "end": 1215}, + {"type": "punctuation", "start": 1200, "end": 1201}, + {"type": "punctuation", "start": 1201, "end": 1202}, + {"type": "punctuation", "start": 1214, "end": 1215}, + {"type": "attr_name", "start": 1216, "end": 1218}, + {"type": "attr_value", "start": 1218, "end": 1230}, {"type": "punctuation", "start": 1218, "end": 1219}, {"type": "punctuation", "start": 1219, "end": 1220}, - {"type": "punctuation", "start": 1220, "end": 1221}, - {"type": "tag", "start": 1223, "end": 1241}, - {"type": "tag", "start": 1223, "end": 1230}, - {"type": "punctuation", "start": 1223, "end": 1224}, - {"type": "lang_ts", "start": 1231, "end": 1240}, - {"type": "punctuation", "start": 1231, "end": 1232}, - {"type": "punctuation", "start": 1239, "end": 1240}, - {"type": "punctuation", "start": 1240, "end": 1241}, - {"type": "tag", "start": 1254, "end": 1263}, - {"type": "tag", "start": 1254, "end": 1262}, - {"type": "punctuation", "start": 1254, "end": 1256}, - {"type": "punctuation", "start": 1262, "end": 1263}, - {"type": "lang_ts", "start": 1264, "end": 1274}, - {"type": "punctuation", "start": 1264, "end": 1265}, - {"type": "operator", "start": 1265, "end": 1266}, - {"type": "punctuation", "start": 1273, "end": 1274}, - {"type": "tag", "start": 1276, "end": 1317}, - {"type": "tag", "start": 1276, "end": 1280}, - {"type": "punctuation", "start": 1276, "end": 1277}, - {"type": "attr_name", "start": 1281, "end": 1286}, - {"type": "attr_value", "start": 1286, "end": 1301}, - {"type": "punctuation", "start": 1286, "end": 1287}, - {"type": "punctuation", "start": 1287, "end": 1288}, - {"type": "punctuation", "start": 1300, "end": 1301}, - {"type": "attr_name", "start": 1302, "end": 1304}, - {"type": "attr_value", "start": 1304, "end": 1316}, - {"type": "punctuation", "start": 1304, "end": 1305}, - {"type": "punctuation", "start": 1305, "end": 1306}, - {"type": "punctuation", "start": 1315, "end": 1316}, - {"type": "punctuation", "start": 1316, "end": 1317}, - {"type": "tag", "start": 1319, "end": 1322}, - {"type": "tag", "start": 1319, "end": 1321}, - {"type": "punctuation", "start": 1319, "end": 1320}, + {"type": "punctuation", "start": 1229, "end": 1230}, + {"type": "punctuation", "start": 1230, "end": 1231}, + {"type": "tag", "start": 1233, "end": 1236}, + {"type": "tag", "start": 1233, "end": 1235}, + {"type": "punctuation", "start": 1233, "end": 1234}, + {"type": "punctuation", "start": 1235, "end": 1236}, + {"type": "tag", "start": 1248, "end": 1252}, + {"type": "tag", "start": 1248, "end": 1251}, + {"type": "punctuation", "start": 1248, "end": 1250}, + {"type": "punctuation", "start": 1251, "end": 1252}, + {"type": "tag", "start": 1253, "end": 1259}, + {"type": "tag", "start": 1253, "end": 1258}, + {"type": "punctuation", "start": 1253, "end": 1255}, + {"type": "punctuation", "start": 1258, "end": 1259}, + {"type": "tag", "start": 1261, "end": 1295}, + {"type": "tag", "start": 1261, "end": 1263}, + {"type": "punctuation", "start": 1261, "end": 1262}, + {"type": "attr_name", "start": 1264, "end": 1269}, + {"type": "attr_value", "start": 1269, "end": 1294}, + {"type": "punctuation", "start": 1269, "end": 1270}, + {"type": "punctuation", "start": 1270, "end": 1271}, + {"type": "punctuation", "start": 1293, "end": 1294}, + {"type": "punctuation", "start": 1294, "end": 1295}, + {"type": "tag", "start": 1302, "end": 1322}, + {"type": "tag", "start": 1302, "end": 1307}, + {"type": "punctuation", "start": 1302, "end": 1303}, + {"type": "attr_name", "start": 1308, "end": 1313}, + {"type": "attr_value", "start": 1313, "end": 1321}, + {"type": "punctuation", "start": 1313, "end": 1314}, + {"type": "punctuation", "start": 1314, "end": 1315}, + {"type": "punctuation", "start": 1320, "end": 1321}, {"type": "punctuation", "start": 1321, "end": 1322}, + {"type": "tag", "start": 1326, "end": 1333}, + {"type": "tag", "start": 1326, "end": 1332}, + {"type": "punctuation", "start": 1326, "end": 1328}, + {"type": "punctuation", "start": 1332, "end": 1333}, {"type": "tag", "start": 1334, "end": 1338}, {"type": "tag", "start": 1334, "end": 1337}, {"type": "punctuation", "start": 1334, "end": 1336}, {"type": "punctuation", "start": 1337, "end": 1338}, - {"type": "tag", "start": 1339, "end": 1345}, - {"type": "tag", "start": 1339, "end": 1344}, - {"type": "punctuation", "start": 1339, "end": 1341}, - {"type": "punctuation", "start": 1344, "end": 1345}, - {"type": "tag", "start": 1347, "end": 1381}, - {"type": "tag", "start": 1347, "end": 1349}, - {"type": "punctuation", "start": 1347, "end": 1348}, - {"type": "attr_name", "start": 1350, "end": 1355}, - {"type": "attr_value", "start": 1355, "end": 1380}, - {"type": "punctuation", "start": 1355, "end": 1356}, - {"type": "punctuation", "start": 1356, "end": 1357}, - {"type": "punctuation", "start": 1379, "end": 1380}, - {"type": "punctuation", "start": 1380, "end": 1381}, - {"type": "tag", "start": 1388, "end": 1408}, - {"type": "tag", "start": 1388, "end": 1393}, - {"type": "punctuation", "start": 1388, "end": 1389}, - {"type": "attr_name", "start": 1394, "end": 1399}, - {"type": "attr_value", "start": 1399, "end": 1407}, - {"type": "punctuation", "start": 1399, "end": 1400}, - {"type": "punctuation", "start": 1400, "end": 1401}, - {"type": "punctuation", "start": 1406, "end": 1407}, - {"type": "punctuation", "start": 1407, "end": 1408}, - {"type": "tag", "start": 1412, "end": 1419}, - {"type": "tag", "start": 1412, "end": 1418}, - {"type": "punctuation", "start": 1412, "end": 1414}, - {"type": "punctuation", "start": 1418, "end": 1419}, - {"type": "tag", "start": 1420, "end": 1424}, - {"type": "tag", "start": 1420, "end": 1423}, - {"type": "punctuation", "start": 1420, "end": 1422}, - {"type": "punctuation", "start": 1423, "end": 1424}, - {"type": "tag", "start": 1426, "end": 1457}, - {"type": "tag", "start": 1426, "end": 1433}, - {"type": "punctuation", "start": 1426, "end": 1427}, - {"type": "attr_name", "start": 1434, "end": 1438}, - {"type": "attr_value", "start": 1438, "end": 1447}, + {"type": "tag", "start": 1340, "end": 1371}, + {"type": "tag", "start": 1340, "end": 1347}, + {"type": "punctuation", "start": 1340, "end": 1341}, + {"type": "attr_name", "start": 1348, "end": 1352}, + {"type": "attr_value", "start": 1352, "end": 1361}, + {"type": "punctuation", "start": 1352, "end": 1353}, + {"type": "punctuation", "start": 1353, "end": 1354}, + {"type": "punctuation", "start": 1360, "end": 1361}, + {"type": "attr_name", "start": 1362, "end": 1370}, + {"type": "punctuation", "start": 1370, "end": 1371}, + {"type": "tag", "start": 1381, "end": 1390}, + {"type": "tag", "start": 1381, "end": 1389}, + {"type": "punctuation", "start": 1381, "end": 1383}, + {"type": "punctuation", "start": 1389, "end": 1390}, + {"type": "comment", "start": 1392, "end": 1429}, + {"type": "lang_ts", "start": 1430, "end": 1433}, + {"type": "punctuation", "start": 1430, "end": 1431}, + {"type": "punctuation", "start": 1432, "end": 1433}, + {"type": "lang_ts", "start": 1434, "end": 1437}, + {"type": "punctuation", "start": 1434, "end": 1435}, + {"type": "punctuation", "start": 1436, "end": 1437}, + {"type": "lang_ts", "start": 1438, "end": 1445}, {"type": "punctuation", "start": 1438, "end": 1439}, - {"type": "punctuation", "start": 1439, "end": 1440}, - {"type": "punctuation", "start": 1446, "end": 1447}, - {"type": "attr_name", "start": 1448, "end": 1456}, - {"type": "punctuation", "start": 1456, "end": 1457}, - {"type": "tag", "start": 1467, "end": 1476}, - {"type": "tag", "start": 1467, "end": 1475}, - {"type": "punctuation", "start": 1467, "end": 1469}, - {"type": "punctuation", "start": 1475, "end": 1476}, - {"type": "comment", "start": 1478, "end": 1515}, - {"type": "lang_ts", "start": 1516, "end": 1519}, - {"type": "punctuation", "start": 1516, "end": 1517}, - {"type": "punctuation", "start": 1518, "end": 1519}, - {"type": "lang_ts", "start": 1520, "end": 1523}, - {"type": "punctuation", "start": 1520, "end": 1521}, - {"type": "punctuation", "start": 1522, "end": 1523}, - {"type": "lang_ts", "start": 1524, "end": 1531}, - {"type": "punctuation", "start": 1524, "end": 1525}, - {"type": "punctuation", "start": 1530, "end": 1531}, - {"type": "tag", "start": 1533, "end": 1539}, - {"type": "tag", "start": 1533, "end": 1536}, - {"type": "punctuation", "start": 1533, "end": 1534}, - {"type": "punctuation", "start": 1537, "end": 1539}, - {"type": "tag", "start": 1541, "end": 1547}, - {"type": "tag", "start": 1541, "end": 1544}, - {"type": "punctuation", "start": 1541, "end": 1542}, - {"type": "punctuation", "start": 1545, "end": 1547}, - {"type": "tag", "start": 1549, "end": 1585}, - {"type": "tag", "start": 1549, "end": 1553}, - {"type": "punctuation", "start": 1549, "end": 1550}, - {"type": "attr_name", "start": 1554, "end": 1557}, - {"type": "attr_value", "start": 1557, "end": 1569}, - {"type": "punctuation", "start": 1557, "end": 1558}, - {"type": "punctuation", "start": 1558, "end": 1559}, - {"type": "punctuation", "start": 1568, "end": 1569}, - {"type": "attr_name", "start": 1570, "end": 1573}, - {"type": "attr_value", "start": 1573, "end": 1582}, - {"type": "punctuation", "start": 1573, "end": 1574}, - {"type": "punctuation", "start": 1574, "end": 1575}, - {"type": "punctuation", "start": 1581, "end": 1582}, - {"type": "punctuation", "start": 1583, "end": 1585}, - {"type": "tag", "start": 1587, "end": 1591}, - {"type": "tag", "start": 1587, "end": 1590}, - {"type": "punctuation", "start": 1587, "end": 1588}, - {"type": "punctuation", "start": 1590, "end": 1591}, - {"type": "tag", "start": 1593, "end": 1597}, - {"type": "tag", "start": 1593, "end": 1596}, - {"type": "punctuation", "start": 1593, "end": 1594}, - {"type": "punctuation", "start": 1596, "end": 1597}, - {"type": "tag", "start": 1608, "end": 1613}, - {"type": "tag", "start": 1608, "end": 1612}, - {"type": "punctuation", "start": 1608, "end": 1610}, - {"type": "punctuation", "start": 1612, "end": 1613}, - {"type": "tag", "start": 1615, "end": 1619}, - {"type": "tag", "start": 1615, "end": 1618}, + {"type": "punctuation", "start": 1444, "end": 1445}, + {"type": "tag", "start": 1447, "end": 1453}, + {"type": "tag", "start": 1447, "end": 1450}, + {"type": "punctuation", "start": 1447, "end": 1448}, + {"type": "punctuation", "start": 1451, "end": 1453}, + {"type": "tag", "start": 1455, "end": 1461}, + {"type": "tag", "start": 1455, "end": 1458}, + {"type": "punctuation", "start": 1455, "end": 1456}, + {"type": "punctuation", "start": 1459, "end": 1461}, + {"type": "tag", "start": 1463, "end": 1499}, + {"type": "tag", "start": 1463, "end": 1467}, + {"type": "punctuation", "start": 1463, "end": 1464}, + {"type": "attr_name", "start": 1468, "end": 1471}, + {"type": "attr_value", "start": 1471, "end": 1483}, + {"type": "punctuation", "start": 1471, "end": 1472}, + {"type": "punctuation", "start": 1472, "end": 1473}, + {"type": "punctuation", "start": 1482, "end": 1483}, + {"type": "attr_name", "start": 1484, "end": 1487}, + {"type": "attr_value", "start": 1487, "end": 1496}, + {"type": "punctuation", "start": 1487, "end": 1488}, + {"type": "punctuation", "start": 1488, "end": 1489}, + {"type": "punctuation", "start": 1495, "end": 1496}, + {"type": "punctuation", "start": 1497, "end": 1499}, + {"type": "tag", "start": 1501, "end": 1505}, + {"type": "tag", "start": 1501, "end": 1504}, + {"type": "punctuation", "start": 1501, "end": 1502}, + {"type": "punctuation", "start": 1504, "end": 1505}, + {"type": "tag", "start": 1507, "end": 1511}, + {"type": "tag", "start": 1507, "end": 1510}, + {"type": "punctuation", "start": 1507, "end": 1508}, + {"type": "punctuation", "start": 1510, "end": 1511}, + {"type": "tag", "start": 1522, "end": 1527}, + {"type": "tag", "start": 1522, "end": 1526}, + {"type": "punctuation", "start": 1522, "end": 1524}, + {"type": "punctuation", "start": 1526, "end": 1527}, + {"type": "tag", "start": 1529, "end": 1533}, + {"type": "tag", "start": 1529, "end": 1532}, + {"type": "punctuation", "start": 1529, "end": 1530}, + {"type": "punctuation", "start": 1532, "end": 1533}, + {"type": "tag", "start": 1544, "end": 1549}, + {"type": "tag", "start": 1544, "end": 1548}, + {"type": "punctuation", "start": 1544, "end": 1546}, + {"type": "punctuation", "start": 1548, "end": 1549}, + {"type": "tag", "start": 1550, "end": 1555}, + {"type": "tag", "start": 1550, "end": 1554}, + {"type": "punctuation", "start": 1550, "end": 1552}, + {"type": "punctuation", "start": 1554, "end": 1555}, + {"type": "comment", "start": 1557, "end": 1600}, + {"type": "tag", "start": 1601, "end": 1606}, + {"type": "tag", "start": 1601, "end": 1605}, + {"type": "punctuation", "start": 1601, "end": 1602}, + {"type": "punctuation", "start": 1605, "end": 1606}, + {"type": "tag", "start": 1608, "end": 1616}, + {"type": "tag", "start": 1608, "end": 1615}, + {"type": "punctuation", "start": 1608, "end": 1609}, {"type": "punctuation", "start": 1615, "end": 1616}, - {"type": "punctuation", "start": 1618, "end": 1619}, - {"type": "tag", "start": 1630, "end": 1635}, - {"type": "tag", "start": 1630, "end": 1634}, - {"type": "punctuation", "start": 1630, "end": 1632}, - {"type": "punctuation", "start": 1634, "end": 1635}, - {"type": "tag", "start": 1636, "end": 1641}, - {"type": "tag", "start": 1636, "end": 1640}, - {"type": "punctuation", "start": 1636, "end": 1638}, - {"type": "punctuation", "start": 1640, "end": 1641}, - {"type": "comment", "start": 1643, "end": 1686}, - {"type": "tag", "start": 1687, "end": 1692}, - {"type": "tag", "start": 1687, "end": 1691}, - {"type": "punctuation", "start": 1687, "end": 1688}, - {"type": "punctuation", "start": 1691, "end": 1692}, - {"type": "tag", "start": 1694, "end": 1702}, - {"type": "tag", "start": 1694, "end": 1701}, - {"type": "punctuation", "start": 1694, "end": 1695}, - {"type": "punctuation", "start": 1701, "end": 1702}, - {"type": "script", "start": 1702, "end": 1740}, - {"type": "lang_ts", "start": 1702, "end": 1740}, - {"type": "keyword", "start": 1705, "end": 1710}, - {"type": "operator", "start": 1721, "end": 1722}, - {"type": "string", "start": 1723, "end": 1737}, - {"type": "punctuation", "start": 1737, "end": 1738}, - {"type": "tag", "start": 1740, "end": 1749}, - {"type": "tag", "start": 1740, "end": 1748}, - {"type": "punctuation", "start": 1740, "end": 1742}, - {"type": "punctuation", "start": 1748, "end": 1749}, - {"type": "tag", "start": 1751, "end": 1758}, - {"type": "tag", "start": 1751, "end": 1757}, - {"type": "punctuation", "start": 1751, "end": 1752}, - {"type": "punctuation", "start": 1757, "end": 1758}, - {"type": "style", "start": 1758, "end": 1792}, - {"type": "lang_css", "start": 1758, "end": 1792}, - {"type": "selector", "start": 1761, "end": 1768}, - {"type": "punctuation", "start": 1769, "end": 1770}, - {"type": "property", "start": 1774, "end": 1779}, - {"type": "punctuation", "start": 1779, "end": 1780}, - {"type": "punctuation", "start": 1785, "end": 1786}, - {"type": "punctuation", "start": 1789, "end": 1790}, - {"type": "tag", "start": 1792, "end": 1800}, - {"type": "tag", "start": 1792, "end": 1799}, - {"type": "punctuation", "start": 1792, "end": 1794}, - {"type": "punctuation", "start": 1799, "end": 1800}, - {"type": "tag", "start": 1801, "end": 1807}, - {"type": "tag", "start": 1801, "end": 1806}, - {"type": "punctuation", "start": 1801, "end": 1803}, + {"type": "script", "start": 1616, "end": 1654}, + {"type": "lang_ts", "start": 1616, "end": 1654}, + {"type": "keyword", "start": 1619, "end": 1624}, + {"type": "operator", "start": 1635, "end": 1636}, + {"type": "string", "start": 1637, "end": 1651}, + {"type": "punctuation", "start": 1651, "end": 1652}, + {"type": "tag", "start": 1654, "end": 1663}, + {"type": "tag", "start": 1654, "end": 1662}, + {"type": "punctuation", "start": 1654, "end": 1656}, + {"type": "punctuation", "start": 1662, "end": 1663}, + {"type": "tag", "start": 1665, "end": 1672}, + {"type": "tag", "start": 1665, "end": 1671}, + {"type": "punctuation", "start": 1665, "end": 1666}, + {"type": "punctuation", "start": 1671, "end": 1672}, + {"type": "style", "start": 1672, "end": 1706}, + {"type": "lang_css", "start": 1672, "end": 1706}, + {"type": "selector", "start": 1675, "end": 1682}, + {"type": "punctuation", "start": 1683, "end": 1684}, + {"type": "property", "start": 1688, "end": 1693}, + {"type": "punctuation", "start": 1693, "end": 1694}, + {"type": "punctuation", "start": 1699, "end": 1700}, + {"type": "punctuation", "start": 1703, "end": 1704}, + {"type": "tag", "start": 1706, "end": 1714}, + {"type": "tag", "start": 1706, "end": 1713}, + {"type": "punctuation", "start": 1706, "end": 1708}, + {"type": "punctuation", "start": 1713, "end": 1714}, + {"type": "tag", "start": 1715, "end": 1721}, + {"type": "tag", "start": 1715, "end": 1720}, + {"type": "punctuation", "start": 1715, "end": 1717}, + {"type": "punctuation", "start": 1720, "end": 1721}, + {"type": "tag", "start": 1723, "end": 1730}, + {"type": "tag", "start": 1723, "end": 1729}, + {"type": "punctuation", "start": 1723, "end": 1724}, + {"type": "punctuation", "start": 1729, "end": 1730}, + {"type": "style", "start": 1730, "end": 2111}, + {"type": "lang_css", "start": 1730, "end": 2111}, + {"type": "selector", "start": 1732, "end": 1743}, + {"type": "punctuation", "start": 1744, "end": 1745}, + {"type": "property", "start": 1748, "end": 1753}, + {"type": "punctuation", "start": 1753, "end": 1754}, + {"type": "punctuation", "start": 1758, "end": 1759}, + {"type": "punctuation", "start": 1761, "end": 1762}, + {"type": "selector", "start": 1765, "end": 1777}, + {"type": "punctuation", "start": 1778, "end": 1779}, + {"type": "property", "start": 1782, "end": 1791}, + {"type": "punctuation", "start": 1791, "end": 1792}, + {"type": "punctuation", "start": 1797, "end": 1798}, + {"type": "punctuation", "start": 1800, "end": 1801}, + {"type": "selector", "start": 1804, "end": 1805}, {"type": "punctuation", "start": 1806, "end": 1807}, - {"type": "tag", "start": 1809, "end": 1816}, - {"type": "tag", "start": 1809, "end": 1815}, - {"type": "punctuation", "start": 1809, "end": 1810}, - {"type": "punctuation", "start": 1815, "end": 1816}, - {"type": "style", "start": 1816, "end": 2197}, - {"type": "lang_css", "start": 1816, "end": 2197}, - {"type": "selector", "start": 1818, "end": 1829}, - {"type": "punctuation", "start": 1830, "end": 1831}, - {"type": "property", "start": 1834, "end": 1839}, - {"type": "punctuation", "start": 1839, "end": 1840}, - {"type": "punctuation", "start": 1844, "end": 1845}, - {"type": "punctuation", "start": 1847, "end": 1848}, - {"type": "selector", "start": 1851, "end": 1863}, - {"type": "punctuation", "start": 1864, "end": 1865}, - {"type": "property", "start": 1868, "end": 1877}, - {"type": "punctuation", "start": 1877, "end": 1878}, - {"type": "punctuation", "start": 1883, "end": 1884}, - {"type": "punctuation", "start": 1886, "end": 1887}, - {"type": "selector", "start": 1890, "end": 1891}, - {"type": "punctuation", "start": 1892, "end": 1893}, - {"type": "property", "start": 1896, "end": 1906}, - {"type": "punctuation", "start": 1906, "end": 1907}, - {"type": "function", "start": 1917, "end": 1921}, - {"type": "punctuation", "start": 1921, "end": 1922}, - {"type": "punctuation", "start": 1923, "end": 1924}, - {"type": "punctuation", "start": 1926, "end": 1927}, - {"type": "punctuation", "start": 1929, "end": 1930}, - {"type": "punctuation", "start": 1934, "end": 1935}, - {"type": "punctuation", "start": 1935, "end": 1936}, + {"type": "property", "start": 1810, "end": 1820}, + {"type": "punctuation", "start": 1820, "end": 1821}, + {"type": "function", "start": 1831, "end": 1835}, + {"type": "punctuation", "start": 1835, "end": 1836}, + {"type": "punctuation", "start": 1837, "end": 1838}, + {"type": "punctuation", "start": 1840, "end": 1841}, + {"type": "punctuation", "start": 1843, "end": 1844}, + {"type": "punctuation", "start": 1848, "end": 1849}, + {"type": "punctuation", "start": 1849, "end": 1850}, + {"type": "punctuation", "start": 1852, "end": 1853}, + {"type": "comment", "start": 1856, "end": 1869}, + {"type": "comment", "start": 1872, "end": 1904}, + {"type": "selector", "start": 1907, "end": 1917}, + {"type": "punctuation", "start": 1918, "end": 1919}, + {"type": "property", "start": 1922, "end": 1938}, {"type": "punctuation", "start": 1938, "end": 1939}, - {"type": "comment", "start": 1942, "end": 1955}, - {"type": "comment", "start": 1958, "end": 1990}, - {"type": "selector", "start": 1993, "end": 2003}, - {"type": "punctuation", "start": 2004, "end": 2005}, - {"type": "property", "start": 2008, "end": 2024}, - {"type": "punctuation", "start": 2024, "end": 2025}, - {"type": "punctuation", "start": 2030, "end": 2031}, - {"type": "punctuation", "start": 2033, "end": 2034}, - {"type": "selector", "start": 2037, "end": 2044}, - {"type": "punctuation", "start": 2045, "end": 2046}, - {"type": "property", "start": 2049, "end": 2055}, - {"type": "punctuation", "start": 2055, "end": 2056}, - {"type": "punctuation", "start": 2061, "end": 2062}, - {"type": "punctuation", "start": 2064, "end": 2065}, - {"type": "atrule", "start": 2068, "end": 2093}, - {"type": "rule", "start": 2068, "end": 2074}, - {"type": "punctuation", "start": 2075, "end": 2076}, - {"type": "property", "start": 2076, "end": 2085}, - {"type": "punctuation", "start": 2085, "end": 2086}, - {"type": "punctuation", "start": 2092, "end": 2093}, - {"type": "punctuation", "start": 2094, "end": 2095}, - {"type": "selector", "start": 2098, "end": 2111}, - {"type": "punctuation", "start": 2112, "end": 2113}, - {"type": "property", "start": 2117, "end": 2133}, - {"type": "punctuation", "start": 2133, "end": 2134}, - {"type": "punctuation", "start": 2144, "end": 2145}, - {"type": "punctuation", "start": 2148, "end": 2149}, - {"type": "punctuation", "start": 2151, "end": 2152}, - {"type": "selector", "start": 2155, "end": 2171}, - {"type": "punctuation", "start": 2172, "end": 2173}, - {"type": "property", "start": 2176, "end": 2183}, - {"type": "punctuation", "start": 2183, "end": 2184}, - {"type": "string", "start": 2185, "end": 2192}, - {"type": "punctuation", "start": 2192, "end": 2193}, - {"type": "punctuation", "start": 2195, "end": 2196}, - {"type": "tag", "start": 2197, "end": 2205}, - {"type": "tag", "start": 2197, "end": 2204}, - {"type": "punctuation", "start": 2197, "end": 2199}, - {"type": "punctuation", "start": 2204, "end": 2205} + {"type": "punctuation", "start": 1944, "end": 1945}, + {"type": "punctuation", "start": 1947, "end": 1948}, + {"type": "selector", "start": 1951, "end": 1958}, + {"type": "punctuation", "start": 1959, "end": 1960}, + {"type": "property", "start": 1963, "end": 1969}, + {"type": "punctuation", "start": 1969, "end": 1970}, + {"type": "punctuation", "start": 1975, "end": 1976}, + {"type": "punctuation", "start": 1978, "end": 1979}, + {"type": "atrule", "start": 1982, "end": 2007}, + {"type": "rule", "start": 1982, "end": 1988}, + {"type": "punctuation", "start": 1989, "end": 1990}, + {"type": "property", "start": 1990, "end": 1999}, + {"type": "punctuation", "start": 1999, "end": 2000}, + {"type": "punctuation", "start": 2006, "end": 2007}, + {"type": "punctuation", "start": 2008, "end": 2009}, + {"type": "selector", "start": 2012, "end": 2025}, + {"type": "punctuation", "start": 2026, "end": 2027}, + {"type": "property", "start": 2031, "end": 2047}, + {"type": "punctuation", "start": 2047, "end": 2048}, + {"type": "punctuation", "start": 2058, "end": 2059}, + {"type": "punctuation", "start": 2062, "end": 2063}, + {"type": "punctuation", "start": 2065, "end": 2066}, + {"type": "selector", "start": 2069, "end": 2085}, + {"type": "punctuation", "start": 2086, "end": 2087}, + {"type": "property", "start": 2090, "end": 2097}, + {"type": "punctuation", "start": 2097, "end": 2098}, + {"type": "string", "start": 2099, "end": 2106}, + {"type": "punctuation", "start": 2106, "end": 2107}, + {"type": "punctuation", "start": 2109, "end": 2110}, + {"type": "tag", "start": 2111, "end": 2119}, + {"type": "tag", "start": 2111, "end": 2118}, + {"type": "punctuation", "start": 2111, "end": 2113}, + {"type": "punctuation", "start": 2118, "end": 2119} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement | undefined = undefined;\n\tconsole.log(element_ref);\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index fce0b773..213c7481 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -30,8 +30,8 @@ 81-82 punctuation " 84-85 punctuation " 85-86 punctuation > - 86-721 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement | undefined = undefined;\n\tconsole.log(element_ref);\n - 86-721 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tfunction attachment(param1: string, param2: number) {\n\t\treturn (_: HTMLElement) => {\n\t\t\tconsole.log(param1, param2);\n\t\t};\n\t}\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement | undefined = undefined;\n\tconsole.log(element_ref);\n + 86-635 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n + 86-635 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n 88-107 comment // @ts-expect-error 109-115 special_keyword import 122-126 special_keyword from @@ -113,489 +113,469 @@ 479-483 boolean true 483-484 punctuation ) 484-485 punctuation ; - 488-496 keyword function - 497-507 function attachment + 488-493 keyword const + 494-504 function_variable attachment + 505-506 operator = 507-508 punctuation ( - 514-515 operator : - 516-522 builtin string - 522-523 punctuation , - 530-531 operator : - 532-538 builtin number - 538-539 punctuation ) - 540-541 punctuation { - 544-550 special_keyword return - 551-552 punctuation ( - 553-554 operator : - 566-567 punctuation ) - 568-570 operator => - 571-572 punctuation { - 576-583 builtin console - 583-584 punctuation . - 584-587 function log - 587-588 punctuation ( - 594-595 punctuation , - 602-603 punctuation ) - 603-604 punctuation ; - 607-608 punctuation } - 608-609 punctuation ; - 611-612 punctuation } - 615-618 keyword let - 625-626 operator = - 627-633 function $state - 633-634 punctuation ( - 634-636 string '' - 636-637 punctuation ) - 637-638 punctuation ; - 640-643 keyword let - 655-681 type_annotation : HTMLElement | undefined - 655-656 : : - 656-681 type HTMLElement | undefined - 657-668 type_name HTMLElement - 669-670 operator | - 671-680 keyword undefined - 681-682 operator = - 683-692 keyword undefined - 692-693 punctuation ; - 695-702 builtin console - 702-703 punctuation . - 703-706 function log - 706-707 punctuation ( - 718-719 punctuation ) - 719-720 punctuation ; - 721-730 tag - 721-729 tag - 732-736 tag

    - 732-735 tag

    - 742-749 lang_ts {HELLO} + 511-512 operator : + 513-519 builtin string + 519-520 punctuation , + 524-525 operator : + 526-532 builtin number + 532-533 punctuation ) + 534-536 operator => + 537-538 punctuation ( + 539-540 operator : + 552-553 punctuation ) + 554-556 operator => + 557-558 punctuation { + 572-573 punctuation ; + 575-576 punctuation } + 576-577 punctuation ; + 580-583 keyword let + 590-591 operator = + 592-598 function $state + 598-599 punctuation ( + 599-601 string '' + 601-602 punctuation ) + 602-603 punctuation ; + 605-608 keyword let + 620-621 operator : + 633-634 punctuation ; + 635-644 tag + 635-643 tag + 646-650 tag

    + 646-649 tag

    + 656-663 lang_ts {HELLO} + 656-657 punctuation { + 657-662 constant HELLO + 662-663 punctuation } + 664-669 tag

    + 664-668 tag + 671-702 each {#each thing_keys as key (key)} + 671-672 punctuation { + 672-677 keyword #each + 678-689 lang_ts thing_keys + 689-691 keyword as + 692-696 lang_ts key + 696-701 lang_ts (key) + 696-697 punctuation ( + 700-701 punctuation ) + 701-702 punctuation } + 704-727 lang_ts {@const v = thing[key]} + 704-705 punctuation { + 706-711 keyword const + 714-715 operator = + 721-722 punctuation [ + 725-726 punctuation ] + 726-727 punctuation } + 729-732 lang_ts {v} + 729-730 punctuation { + 731-732 punctuation } + 733-740 each {/each} + 733-734 punctuation { + 734-739 keyword /each + 739-740 punctuation } + 742-749 lang_ts {#if c} 742-743 punctuation { - 743-748 constant HELLO + 744-746 special_keyword if 748-749 punctuation } - 750-755 tag - 750-754 tag - 757-788 each {#each thing_keys as key (key)} - 757-758 punctuation { - 758-763 keyword #each - 764-775 lang_ts thing_keys - 775-777 keyword as - 778-782 lang_ts key - 782-787 lang_ts (key) - 782-783 punctuation ( - 786-787 punctuation ) - 787-788 punctuation } - 790-813 lang_ts {@const v = thing[key]} - 790-791 punctuation { - 792-797 keyword const - 800-801 operator = - 807-808 punctuation [ - 811-812 punctuation ] - 812-813 punctuation } - 815-818 lang_ts {v} - 815-816 punctuation { - 817-818 punctuation } - 819-826 each {/each} - 819-820 punctuation { - 820-825 keyword /each - 825-826 punctuation } - 828-835 lang_ts {#if c} - 828-829 punctuation { - 830-832 special_keyword if - 834-835 punctuation } - 837-878 tag - 837-843 tag - 879-886 lang_ts {:else} - 879-880 punctuation { - 880-881 operator : - 881-885 special_keyword else - 885-886 punctuation } - 888-952 tag (c = !c)}> - 888-894 tag (c = !c)} - 935-936 punctuation { - 936-937 punctuation ( - 937-938 punctuation ) - 939-941 operator => - 942-943 punctuation ( - 945-946 operator = - 947-948 operator ! - 949-950 punctuation ) - 950-951 punctuation } - 951-952 punctuation > - 955-975 lang_ts {@render children()} - 955-956 punctuation { - 956-963 decorator @render - 956-957 at @ - 957-963 function render - 964-972 function children - 972-973 punctuation ( - 973-974 punctuation ) - 974-975 punctuation } - 977-985 tag - 977-984 tag - 986-991 lang_ts {/if} - 986-987 punctuation { - 987-988 operator / - 988-990 special_keyword if - 990-991 punctuation } -1001-1009 tag -1001-1008 tag -1017-1026 tag -1017-1025 tag -1030-1062 tag -1030-1036 tag -1064-1144 tag
    -1064-1068 tag
    -1166-1172 tag
    -1166-1171 tag
    -1174-1196 lang_ts {@render my_snippet()} -1174-1175 punctuation { -1175-1182 decorator @render -1175-1176 at @ -1176-1182 function render -1183-1193 function my_snippet -1193-1194 punctuation ( -1194-1195 punctuation ) -1195-1196 punctuation } -1198-1221 lang_ts {#snippet my_snippet()} -1198-1199 punctuation { -1208-1218 function my_snippet -1218-1219 punctuation ( -1219-1220 punctuation ) -1220-1221 punctuation } -1223-1241 tag -1254-1262 tag -1264-1274 lang_ts {/snippet} -1264-1265 punctuation { -1265-1266 operator / -1273-1274 punctuation } -1276-1317 tag
    -1276-1280 tag
    -1319-1322 tag

    -1319-1321 tag

    + 751-757 tag + 793-800 lang_ts {:else} + 793-794 punctuation { + 794-795 operator : + 795-799 special_keyword else + 799-800 punctuation } + 802-866 tag (c = !c)}> + 802-808 tag (c = !c)} + 849-850 punctuation { + 850-851 punctuation ( + 851-852 punctuation ) + 853-855 operator => + 856-857 punctuation ( + 859-860 operator = + 861-862 operator ! + 863-864 punctuation ) + 864-865 punctuation } + 865-866 punctuation > + 869-889 lang_ts {@render children()} + 869-870 punctuation { + 870-877 decorator @render + 870-871 at @ + 871-877 function render + 878-886 function children + 886-887 punctuation ( + 887-888 punctuation ) + 888-889 punctuation } + 891-899 tag + 891-898 tag + 900-905 lang_ts {/if} + 900-901 punctuation { + 901-902 operator / + 902-904 special_keyword if + 904-905 punctuation } + 915-923 tag + 915-922 tag + 931-940 tag + 931-939 tag + 944-976 tag + 944-950 tag + 978-1058 tag

    + 978-982 tag
    +1080-1086 tag
    +1080-1085 tag
    +1088-1110 lang_ts {@render my_snippet()} +1088-1089 punctuation { +1089-1096 decorator @render +1089-1090 at @ +1090-1096 function render +1097-1107 function my_snippet +1107-1108 punctuation ( +1108-1109 punctuation ) +1109-1110 punctuation } +1112-1135 lang_ts {#snippet my_snippet()} +1112-1113 punctuation { +1122-1132 function my_snippet +1132-1133 punctuation ( +1133-1134 punctuation ) +1134-1135 punctuation } +1137-1155 tag +1168-1176 tag +1178-1188 lang_ts {/snippet} +1178-1179 punctuation { +1179-1180 operator / +1187-1188 punctuation } +1190-1231 tag
    +1190-1194 tag
    +1233-1236 tag

    +1233-1235 tag

    +1248-1252 tag

    +1248-1251 tag

    +1253-1259 tag
    +1253-1258 tag
    +1261-1295 tag

    +1261-1263 tag

    +1302-1322 tag +1302-1307 tag +1326-1333 tag +1326-1332 tag 1334-1338 tag

    1334-1337 tag

    -1339-1345 tag
    -1339-1344 tag
    -1347-1381 tag

    -1347-1349 tag

    -1388-1408 tag -1388-1393 tag -1412-1419 tag -1412-1418 tag -1420-1424 tag

    -1420-1423 tag

    -1426-1457 tag -1467-1475 tag -1478-1515 comment -1516-1519 lang_ts {a} -1516-1517 punctuation { -1518-1519 punctuation } -1520-1523 lang_ts {b} -1520-1521 punctuation { -1522-1523 punctuation } -1524-1531 lang_ts {bound} -1524-1525 punctuation { -1530-1531 punctuation } -1533-1539 tag
    -1533-1536 tag
    -1541-1547 tag
    -1541-1544 tag
    -1549-1585 tag access -1549-1553 tag -1587-1591 tag
      -1587-1590 tag
        -1593-1597 tag
      • -1593-1596 tag
      • -1608-1613 tag
      • -1608-1612 tag -1615-1619 tag
      • -1615-1618 tag
      • -1630-1635 tag
      • -1630-1634 tag -1636-1641 tag
      -1636-1640 tag
    -1643-1686 comment -1687-1692 tag
    -1687-1691 tag
    -1694-1702 tag -1740-1748 tag -1751-1758 tag -1792-1799 tag -1801-1807 tag
    -1801-1806 tag
    -1809-1816 tag -2197-2204 tag +1340-1371 tag +1381-1389 tag +1392-1429 comment +1430-1433 lang_ts {a} +1430-1431 punctuation { +1432-1433 punctuation } +1434-1437 lang_ts {b} +1434-1435 punctuation { +1436-1437 punctuation } +1438-1445 lang_ts {bound} +1438-1439 punctuation { +1444-1445 punctuation } +1447-1453 tag
    +1447-1450 tag
    +1455-1461 tag
    +1455-1458 tag
    +1463-1499 tag access +1463-1467 tag +1501-1505 tag
      +1501-1504 tag
        +1507-1511 tag
      • +1507-1510 tag
      • +1522-1527 tag
      • +1522-1526 tag +1529-1533 tag
      • +1529-1532 tag
      • +1544-1549 tag
      • +1544-1548 tag +1550-1555 tag
      +1550-1554 tag
    +1557-1600 comment +1601-1606 tag
    +1601-1605 tag
    +1608-1616 tag +1654-1662 tag +1665-1672 tag +1706-1713 tag +1715-1721 tag
    +1715-1720 tag
    +1723-1730 tag +2111-2118 tag === STATS === -Total tokens: 578 -Sample length: 2206 characters +Total tokens: 558 +Sample length: 2120 characters Token types: - punctuation: 285 + punctuation: 275 tag: 86 - operator: 32 + operator: 33 lang_ts: 26 attr_name: 20 - keyword: 18 - function: 17 + keyword: 16 + function: 14 attr_value: 12 - special_keyword: 9 property: 9 + special_keyword: 8 string: 8 - builtin: 8 selector: 8 + builtin: 6 comment: 5 number: 4 script: 3 @@ -604,12 +584,12 @@ Token types: namespace: 3 constant: 2 boolean: 2 - type_annotation: 2 - :: 2 - type: 2 each: 2 style: 2 lang_css: 2 - type_name: 1 + type_annotation: 1 + :: 1 + type: 1 + function_variable: 1 atrule: 1 rule: 1 diff --git a/src/fixtures/helpers.ts b/src/fixtures/helpers.ts index 3f490173..7f37c887 100644 --- a/src/fixtures/helpers.ts +++ b/src/fixtures/helpers.ts @@ -50,7 +50,7 @@ export const discover_samples = (): Array => { /** * Get the fixture path for a given language and variant */ -export const get_fixture_path = (lang: string, variant: string, ext: 'json' | 'txt'): string => { +export const get_fixture_path = (lang: string, variant: string, ext: 'json' | 'txt' | 'html'): string => { return join('src/fixtures/generated', lang, `${lang}_${variant}.${ext}`); }; diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 2129bd7a..692402ec 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -65,11 +65,10 @@ div > p { @media (max-width: 600px) { body { - background-color: lightblue; + background-color: light-dark(lightblue, darkblue); } } -/* patterns in strings are not falsely detected */ .content::before { content: ' /* not a comment */'; } @@ -313,15 +312,12 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; let c: boolean = $state(true); - function attachment(param1: string, param2: number) { - return (_: HTMLElement) => { - console.log(param1, param2); - }; - } + const attachment = (_p1: string, _p2: number) => (_: HTMLElement) => { + element_ref; + }; let value = $state(''); - let element_ref: HTMLElement | undefined = undefined; - console.log(element_ref); + let element_ref: HTMLElement;

    hello {HELLO}!

    diff --git a/src/lib/samples/sample_complex.css b/src/lib/samples/sample_complex.css index a31ec572..6cb6a138 100644 --- a/src/lib/samples/sample_complex.css +++ b/src/lib/samples/sample_complex.css @@ -31,11 +31,10 @@ div > p { @media (max-width: 600px) { body { - background-color: lightblue; + background-color: light-dark(lightblue, darkblue); } } -/* patterns in strings are not falsely detected */ .content::before { content: ' /* not a comment */'; } diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index faab827f..0ceee38f 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -27,15 +27,12 @@ let c: boolean = $state(true); - function attachment(param1: string, param2: number) { - return (_: HTMLElement) => { - console.log(param1, param2); - }; - } + const attachment = (_p1: string, _p2: number) => (_: HTMLElement) => { + element_ref; + }; let value = $state(''); - let element_ref: HTMLElement | undefined = undefined; - console.log(element_ref); + let element_ref: HTMLElement;

    hello {HELLO}!

    @@ -138,7 +135,7 @@ @media (max-width: 600px) { :global(body) { - background-color: lightblue; + background-color: light-dark(lightblue, darkblue); } } From c2f58c122a05f5a065ddc7009473d2927d1e8f0e Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 17:16:43 -0400 Subject: [PATCH 23/49] wip --- .../generated/svelte/svelte_complex.json | 40 +++++++++-------- .../generated/svelte/svelte_complex.txt | 44 ++++++++++--------- src/lib/samples/all.ts | 2 +- 3 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.json b/src/fixtures/generated/svelte/svelte_complex.json index c7a54ab6..f56c182a 100644 --- a/src/fixtures/generated/svelte/svelte_complex.json +++ b/src/fixtures/generated/svelte/svelte_complex.json @@ -2,7 +2,7 @@ "sample": { "lang": "svelte", "variant": "complex", - "content": "\n\n\n\n

    hello {HELLO}!

    \n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n{@html 'raw html'}\n\n\n\n
    \n\tinteractive element\n
    \n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t\n{/snippet}\n\n
    \n\t

    hello world!

    \n
    \n\n

    \n\tsome text\n

    \n\n\n\n\n{a}\n{b}\n{bound}\n\n
    \n\n
    \n\n\"access\"\n\n
      \n\t
    • list item 1
    • \n\t
    • list item 2
    • \n
    \n\n\n
    \n\t\n\t\n
    \n\n\n", + "content": "\n\n\n\n

    hello {HELLO}!

    \n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n{@html 'raw html'}\n\n\n\n
    \n\tinteractive element\n
    \n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t\n{/snippet}\n\n
    \n\t

    hello world!

    \n
    \n\n

    \n\tsome text\n

    \n\n\n\n\n{a}\n{b}\n{bound}\n\n
    \n\n
    \n\n\"access\"\n\n
      \n\t
    • list item 1
    • \n\t
    • list item 2
    • \n
    \n\n\n
    \n\t\n\t\n
    \n\n\n", "filepath": "src/lib/samples/sample_complex.svelte" }, "tokens": [ @@ -499,8 +499,8 @@ {"type": "tag", "start": 1723, "end": 1729}, {"type": "punctuation", "start": 1723, "end": 1724}, {"type": "punctuation", "start": 1729, "end": 1730}, - {"type": "style", "start": 1730, "end": 2111}, - {"type": "lang_css", "start": 1730, "end": 2111}, + {"type": "style", "start": 1730, "end": 2133}, + {"type": "lang_css", "start": 1730, "end": 2133}, {"type": "selector", "start": 1732, "end": 1743}, {"type": "punctuation", "start": 1744, "end": 1745}, {"type": "property", "start": 1748, "end": 1753}, @@ -550,20 +550,24 @@ {"type": "punctuation", "start": 2026, "end": 2027}, {"type": "property", "start": 2031, "end": 2047}, {"type": "punctuation", "start": 2047, "end": 2048}, - {"type": "punctuation", "start": 2058, "end": 2059}, - {"type": "punctuation", "start": 2062, "end": 2063}, - {"type": "punctuation", "start": 2065, "end": 2066}, - {"type": "selector", "start": 2069, "end": 2085}, - {"type": "punctuation", "start": 2086, "end": 2087}, - {"type": "property", "start": 2090, "end": 2097}, - {"type": "punctuation", "start": 2097, "end": 2098}, - {"type": "string", "start": 2099, "end": 2106}, - {"type": "punctuation", "start": 2106, "end": 2107}, - {"type": "punctuation", "start": 2109, "end": 2110}, - {"type": "tag", "start": 2111, "end": 2119}, - {"type": "tag", "start": 2111, "end": 2118}, - {"type": "punctuation", "start": 2111, "end": 2113}, - {"type": "punctuation", "start": 2118, "end": 2119} + {"type": "function", "start": 2049, "end": 2059}, + {"type": "punctuation", "start": 2059, "end": 2060}, + {"type": "punctuation", "start": 2069, "end": 2070}, + {"type": "punctuation", "start": 2079, "end": 2080}, + {"type": "punctuation", "start": 2080, "end": 2081}, + {"type": "punctuation", "start": 2084, "end": 2085}, + {"type": "punctuation", "start": 2087, "end": 2088}, + {"type": "selector", "start": 2091, "end": 2107}, + {"type": "punctuation", "start": 2108, "end": 2109}, + {"type": "property", "start": 2112, "end": 2119}, + {"type": "punctuation", "start": 2119, "end": 2120}, + {"type": "string", "start": 2121, "end": 2128}, + {"type": "punctuation", "start": 2128, "end": 2129}, + {"type": "punctuation", "start": 2131, "end": 2132}, + {"type": "tag", "start": 2133, "end": 2141}, + {"type": "tag", "start": 2133, "end": 2140}, + {"type": "punctuation", "start": 2133, "end": 2135}, + {"type": "punctuation", "start": 2140, "end": 2141} ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: lightblue;\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" + "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: light-dark(lightblue, darkblue);\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" } diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 213c7481..be10637b 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -492,8 +492,8 @@ 1723-1729 tag -2111-2118 tag +2049-2059 function light-dark +2059-2060 punctuation ( +2069-2070 punctuation , +2079-2080 punctuation ) +2080-2081 punctuation ; +2084-2085 punctuation } +2087-2088 punctuation } +2091-2107 selector .special::before +2108-2109 punctuation { +2112-2119 property content +2119-2120 punctuation : +2121-2128 string '< & >' +2128-2129 punctuation ; +2131-2132 punctuation } +2133-2141 tag +2133-2140 tag === STATS === -Total tokens: 558 -Sample length: 2120 characters +Total tokens: 562 +Sample length: 2142 characters Token types: - punctuation: 275 + punctuation: 278 tag: 86 operator: 33 lang_ts: 26 attr_name: 20 keyword: 16 - function: 14 + function: 15 attr_value: 12 property: 9 special_keyword: 8 diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 692402ec..ff7e6797 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -420,7 +420,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; @media (max-width: 600px) { :global(body) { - background-color: lightblue; + background-color: light-dark(lightblue, darkblue); } } From 05af0aa8a5157dc96849d6cfca6e910305425929 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 17:22:23 -0400 Subject: [PATCH 24/49] wip --- src/fixtures/check.test.ts | 33 +- src/fixtures/generated/css/css_complex.html | 44 ++ src/fixtures/generated/css/css_complex.json | 85 --- src/fixtures/generated/css/css_complex.txt | 30 +- src/fixtures/generated/html/html_complex.html | 42 ++ src/fixtures/generated/html/html_complex.json | 243 ------- src/fixtures/generated/html/html_complex.txt | 44 +- src/fixtures/generated/json/json_complex.html | 14 + src/fixtures/generated/json/json_complex.json | 94 --- src/fixtures/generated/json/json_complex.txt | 26 +- .../generated/svelte/svelte_complex.html | 145 ++++ .../generated/svelte/svelte_complex.json | 573 ---------------- .../generated/svelte/svelte_complex.txt | 72 +- src/fixtures/generated/ts/ts_complex.html | 150 +++++ src/fixtures/generated/ts/ts_complex.json | 630 ------------------ src/fixtures/generated/ts/ts_complex.txt | 66 +- src/fixtures/helpers.ts | 33 +- src/fixtures/update.task.ts | 11 +- src/lib/theme.css | 10 +- 19 files changed, 553 insertions(+), 1792 deletions(-) create mode 100644 src/fixtures/generated/css/css_complex.html delete mode 100644 src/fixtures/generated/css/css_complex.json create mode 100644 src/fixtures/generated/html/html_complex.html delete mode 100644 src/fixtures/generated/html/html_complex.json create mode 100644 src/fixtures/generated/json/json_complex.html delete mode 100644 src/fixtures/generated/json/json_complex.json create mode 100644 src/fixtures/generated/svelte/svelte_complex.html delete mode 100644 src/fixtures/generated/svelte/svelte_complex.json create mode 100644 src/fixtures/generated/ts/ts_complex.html delete mode 100644 src/fixtures/generated/ts/ts_complex.json diff --git a/src/fixtures/check.test.ts b/src/fixtures/check.test.ts index 93c73bbf..0c014b45 100644 --- a/src/fixtures/check.test.ts +++ b/src/fixtures/check.test.ts @@ -4,7 +4,6 @@ import { discover_samples, process_sample, get_fixture_path, - type Generated_Output, } from './helpers.js'; import {sample_langs} from '$lib/code_sample.js'; @@ -28,13 +27,13 @@ describe('generated fixtures match runtime', () => { // Generate test for each sample for (const sample of samples) { describe(`${sample.lang}_${sample.variant}`, () => { - const fixture_path = get_fixture_path(sample.lang, sample.variant, 'json'); + const html_fixture_path = get_fixture_path(sample.lang, sample.variant, 'html'); test('fixture file exists', () => { // Basic sanity check - fixtures must be generated before tests can run assert.ok( - existsSync(fixture_path), - `Fixture file missing: ${fixture_path}. Run 'npm run task src/fixtures/update' to generate.`, + existsSync(html_fixture_path), + `Fixture file missing: ${html_fixture_path}. Run 'npm run task src/fixtures/update' to generate.`, ); }); @@ -49,17 +48,17 @@ describe('generated fixtures match runtime', () => { * - No overlapping spans * - Performance metrics (time, memory) */ - if (!existsSync(fixture_path)) { - console.warn(`Skipping test - fixture missing: ${fixture_path}`); // eslint-disable-line no-console + if (!existsSync(html_fixture_path)) { + console.warn(`Skipping test - fixture missing: ${html_fixture_path}`); // eslint-disable-line no-console return; } - const fixture: Generated_Output = JSON.parse(readFileSync(fixture_path, 'utf-8')); + const fixture_html = readFileSync(html_fixture_path, 'utf-8'); const runtime_output = process_sample(sample); assert.strictEqual( runtime_output.html, - fixture.html, + fixture_html, `HTML output mismatch for ${sample.lang}_${sample.variant}`, ); @@ -114,7 +113,7 @@ describe('generated fixtures match runtime', () => { } }); - test('token data matches fixture', () => { + test('token data is deterministic', () => { /** * Ensures token positions are consistent between runs * @@ -123,18 +122,14 @@ describe('generated fixtures match runtime', () => { * - Token types are correctly identified * - Tokenization is deterministic */ - if (!existsSync(fixture_path)) { - console.warn(`Skipping test - fixture missing: ${fixture_path}`); // eslint-disable-line no-console - return; - } - - const fixture: Generated_Output = JSON.parse(readFileSync(fixture_path, 'utf-8')); - const runtime_output = process_sample(sample); + // Generate tokens twice and ensure they match + const runtime_output1 = process_sample(sample); + const runtime_output2 = process_sample(sample); assert.deepEqual( - runtime_output.tokens, - fixture.tokens, - `Token data mismatch for ${sample.lang}_${sample.variant}`, + runtime_output1.tokens, + runtime_output2.tokens, + `Token data not deterministic for ${sample.lang}_${sample.variant}`, ); }); }); diff --git a/src/fixtures/generated/css/css_complex.html b/src/fixtures/generated/css/css_complex.html new file mode 100644 index 00000000..efa53dce --- /dev/null +++ b/src/fixtures/generated/css/css_complex.html @@ -0,0 +1,44 @@ +.some_class { + color: red; +} + +.hypen-class { + font-size: 16px; +} + +p { + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +/* comment */ + +/* +multi +.line { + i: 100px + +</style> + +@media*/ + +#id { + background-color: blue; +} + +div > p { + margin: 10px; +} + +@media (max-width: 600px) { + body { + background-color: light-dark(lightblue, darkblue); + } +} + +.content::before { + content: '</style> /* not a comment */'; +} + +.attr[title='Click: here'] { + background-image: url('data:image/svg+xml...'); +} diff --git a/src/fixtures/generated/css/css_complex.json b/src/fixtures/generated/css/css_complex.json deleted file mode 100644 index d5804695..00000000 --- a/src/fixtures/generated/css/css_complex.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "sample": { - "lang": "css", - "variant": "complex", - "content": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: light-dark(lightblue, darkblue);\n\t}\n}\n\n.content::before {\n\tcontent: ' /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n", - "filepath": "src/lib/samples/sample_complex.css" - }, - "tokens": [ - {"type": "selector", "start": 0, "end": 11}, - {"type": "punctuation", "start": 12, "end": 13}, - {"type": "property", "start": 15, "end": 20}, - {"type": "punctuation", "start": 20, "end": 21}, - {"type": "punctuation", "start": 25, "end": 26}, - {"type": "punctuation", "start": 27, "end": 28}, - {"type": "selector", "start": 30, "end": 42}, - {"type": "punctuation", "start": 43, "end": 44}, - {"type": "property", "start": 46, "end": 55}, - {"type": "punctuation", "start": 55, "end": 56}, - {"type": "punctuation", "start": 61, "end": 62}, - {"type": "punctuation", "start": 63, "end": 64}, - {"type": "selector", "start": 66, "end": 67}, - {"type": "punctuation", "start": 68, "end": 69}, - {"type": "property", "start": 71, "end": 81}, - {"type": "punctuation", "start": 81, "end": 82}, - {"type": "function", "start": 92, "end": 96}, - {"type": "punctuation", "start": 96, "end": 97}, - {"type": "punctuation", "start": 98, "end": 99}, - {"type": "punctuation", "start": 101, "end": 102}, - {"type": "punctuation", "start": 104, "end": 105}, - {"type": "punctuation", "start": 109, "end": 110}, - {"type": "punctuation", "start": 110, "end": 111}, - {"type": "punctuation", "start": 112, "end": 113}, - {"type": "comment", "start": 115, "end": 128}, - {"type": "comment", "start": 130, "end": 176}, - {"type": "selector", "start": 178, "end": 181}, - {"type": "punctuation", "start": 182, "end": 183}, - {"type": "property", "start": 185, "end": 201}, - {"type": "punctuation", "start": 201, "end": 202}, - {"type": "punctuation", "start": 207, "end": 208}, - {"type": "punctuation", "start": 209, "end": 210}, - {"type": "selector", "start": 212, "end": 219}, - {"type": "punctuation", "start": 220, "end": 221}, - {"type": "property", "start": 223, "end": 229}, - {"type": "punctuation", "start": 229, "end": 230}, - {"type": "punctuation", "start": 235, "end": 236}, - {"type": "punctuation", "start": 237, "end": 238}, - {"type": "atrule", "start": 240, "end": 265}, - {"type": "rule", "start": 240, "end": 246}, - {"type": "punctuation", "start": 247, "end": 248}, - {"type": "property", "start": 248, "end": 257}, - {"type": "punctuation", "start": 257, "end": 258}, - {"type": "punctuation", "start": 264, "end": 265}, - {"type": "punctuation", "start": 266, "end": 267}, - {"type": "selector", "start": 269, "end": 273}, - {"type": "punctuation", "start": 274, "end": 275}, - {"type": "property", "start": 278, "end": 294}, - {"type": "punctuation", "start": 294, "end": 295}, - {"type": "function", "start": 296, "end": 306}, - {"type": "punctuation", "start": 306, "end": 307}, - {"type": "punctuation", "start": 316, "end": 317}, - {"type": "punctuation", "start": 326, "end": 327}, - {"type": "punctuation", "start": 327, "end": 328}, - {"type": "punctuation", "start": 330, "end": 331}, - {"type": "punctuation", "start": 332, "end": 333}, - {"type": "selector", "start": 335, "end": 351}, - {"type": "punctuation", "start": 352, "end": 353}, - {"type": "property", "start": 355, "end": 362}, - {"type": "punctuation", "start": 362, "end": 363}, - {"type": "string", "start": 364, "end": 394}, - {"type": "punctuation", "start": 394, "end": 395}, - {"type": "punctuation", "start": 396, "end": 397}, - {"type": "selector", "start": 399, "end": 425}, - {"type": "punctuation", "start": 426, "end": 427}, - {"type": "property", "start": 429, "end": 445}, - {"type": "punctuation", "start": 445, "end": 446}, - {"type": "url", "start": 447, "end": 475}, - {"type": "function", "start": 447, "end": 450}, - {"type": "punctuation", "start": 450, "end": 451}, - {"type": "string", "start": 451, "end": 474}, - {"type": "punctuation", "start": 474, "end": 475}, - {"type": "punctuation", "start": 475, "end": 476}, - {"type": "punctuation", "start": 477, "end": 478} - ], - "html": ".some_class {\n\tcolor: red;\n}\n\n.hypen-class {\n\tfont-size: 16px;\n}\n\np {\n\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n}\n\n/* comment */\n\n/*\nmulti\n.line {\n\ti: 100px\n\n</style>\n\n@media*/\n\n#id {\n\tbackground-color: blue;\n}\n\ndiv > p {\n\tmargin: 10px;\n}\n\n@media (max-width: 600px) {\n\tbody {\n\t\tbackground-color: light-dark(lightblue, darkblue);\n\t}\n}\n\n.content::before {\n\tcontent: '</style> /* not a comment */';\n}\n\n.attr[title='Click: here'] {\n\tbackground-image: url('data:image/svg+xml...');\n}\n" -} diff --git a/src/fixtures/generated/css/css_complex.txt b/src/fixtures/generated/css/css_complex.txt index 08d0b74b..97949433 100644 --- a/src/fixtures/generated/css/css_complex.txt +++ b/src/fixtures/generated/css/css_complex.txt @@ -1,3 +1,18 @@ +=== STATS === +Sample length: 479 characters +Total tokens: 74 + +Token types (9 unique): + punctuation: 47 + property: 9 + selector: 8 + function: 3 + comment: 2 + string: 2 + atrule: 1 + rule: 1 + url: 1 + === TOKENS === 0-11 selector .some_class 12-13 punctuation { @@ -73,18 +88,3 @@ 474-475 punctuation ) 475-476 punctuation ; 477-478 punctuation } - -=== STATS === -Total tokens: 74 -Sample length: 479 characters - -Token types: - punctuation: 47 - property: 9 - selector: 8 - function: 3 - comment: 2 - string: 2 - atrule: 1 - rule: 1 - url: 1 diff --git a/src/fixtures/generated/html/html_complex.html b/src/fixtures/generated/html/html_complex.html new file mode 100644 index 00000000..b5de0854 --- /dev/null +++ b/src/fixtures/generated/html/html_complex.html @@ -0,0 +1,42 @@ +<!doctype html> + +<div class="test"> + <p>hello world!</p> +</div> + +<p class="some_class hypen-class">some <span class="a b c">text</span></p> + +<button type="button" disabled>click me</button> + +<!-- comment <div>a<br /> b</div> <script> --> + +<br /> + +<hr /> + +<img src="image.jpg" alt="access" /> + +<ul> + <li>list item 1</li> + <li>list item 2</li> +</ul> + +<form action="/submit" method="post"> + <input type="text" name="username" placeholder="Enter name" /> + <select name="option" data-role="dropdown"> + <option value="1">First</option> + <option value="2">Second</option> + </select> +</form> + +<script type="text/javascript"> + const ok = '<style>'; +</script> + +<style type="text/css"> + .special::before { + content: '< & >'; + } +</style> + +<![CDATA[ if (a < 0) alert("b"); <not-a-tag> ]]> diff --git a/src/fixtures/generated/html/html_complex.json b/src/fixtures/generated/html/html_complex.json deleted file mode 100644 index 995d8e51..00000000 --- a/src/fixtures/generated/html/html_complex.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "sample": { - "lang": "html", - "variant": "complex", - "content": "\n\n
    \n\t

    hello world!

    \n
    \n\n

    some text

    \n\n\n\n\n\n
    \n\n
    \n\n\"access\"\n\n
      \n\t
    • list item 1
    • \n\t
    • list item 2
    • \n
    \n\n
    \n\t\n\t\n
    \n\n\n\n\n\n ]]>\n", - "filepath": "src/lib/samples/sample_complex.html" - }, - "tokens": [ - {"type": "doctype", "start": 0, "end": 15}, - {"type": "tag", "start": 17, "end": 35}, - {"type": "tag", "start": 17, "end": 21}, - {"type": "punctuation", "start": 17, "end": 18}, - {"type": "attr_name", "start": 22, "end": 27}, - {"type": "attr_value", "start": 27, "end": 34}, - {"type": "punctuation", "start": 27, "end": 28}, - {"type": "punctuation", "start": 28, "end": 29}, - {"type": "punctuation", "start": 33, "end": 34}, - {"type": "punctuation", "start": 34, "end": 35}, - {"type": "tag", "start": 37, "end": 40}, - {"type": "tag", "start": 37, "end": 39}, - {"type": "punctuation", "start": 37, "end": 38}, - {"type": "punctuation", "start": 39, "end": 40}, - {"type": "tag", "start": 52, "end": 56}, - {"type": "tag", "start": 52, "end": 55}, - {"type": "punctuation", "start": 52, "end": 54}, - {"type": "punctuation", "start": 55, "end": 56}, - {"type": "tag", "start": 57, "end": 63}, - {"type": "tag", "start": 57, "end": 62}, - {"type": "punctuation", "start": 57, "end": 59}, - {"type": "punctuation", "start": 62, "end": 63}, - {"type": "tag", "start": 65, "end": 99}, - {"type": "tag", "start": 65, "end": 67}, - {"type": "punctuation", "start": 65, "end": 66}, - {"type": "attr_name", "start": 68, "end": 73}, - {"type": "attr_value", "start": 73, "end": 98}, - {"type": "punctuation", "start": 73, "end": 74}, - {"type": "punctuation", "start": 74, "end": 75}, - {"type": "punctuation", "start": 97, "end": 98}, - {"type": "punctuation", "start": 98, "end": 99}, - {"type": "tag", "start": 104, "end": 124}, - {"type": "tag", "start": 104, "end": 109}, - {"type": "punctuation", "start": 104, "end": 105}, - {"type": "attr_name", "start": 110, "end": 115}, - {"type": "attr_value", "start": 115, "end": 123}, - {"type": "punctuation", "start": 115, "end": 116}, - {"type": "punctuation", "start": 116, "end": 117}, - {"type": "punctuation", "start": 122, "end": 123}, - {"type": "punctuation", "start": 123, "end": 124}, - {"type": "tag", "start": 128, "end": 135}, - {"type": "tag", "start": 128, "end": 134}, - {"type": "punctuation", "start": 128, "end": 130}, - {"type": "punctuation", "start": 134, "end": 135}, - {"type": "tag", "start": 135, "end": 139}, - {"type": "tag", "start": 135, "end": 138}, - {"type": "punctuation", "start": 135, "end": 137}, - {"type": "punctuation", "start": 138, "end": 139}, - {"type": "tag", "start": 141, "end": 172}, - {"type": "tag", "start": 141, "end": 148}, - {"type": "punctuation", "start": 141, "end": 142}, - {"type": "attr_name", "start": 149, "end": 153}, - {"type": "attr_value", "start": 153, "end": 162}, - {"type": "punctuation", "start": 153, "end": 154}, - {"type": "punctuation", "start": 154, "end": 155}, - {"type": "punctuation", "start": 161, "end": 162}, - {"type": "attr_name", "start": 163, "end": 171}, - {"type": "punctuation", "start": 171, "end": 172}, - {"type": "tag", "start": 180, "end": 189}, - {"type": "tag", "start": 180, "end": 188}, - {"type": "punctuation", "start": 180, "end": 182}, - {"type": "punctuation", "start": 188, "end": 189}, - {"type": "comment", "start": 191, "end": 237}, - {"type": "tag", "start": 239, "end": 245}, - {"type": "tag", "start": 239, "end": 242}, - {"type": "punctuation", "start": 239, "end": 240}, - {"type": "punctuation", "start": 243, "end": 245}, - {"type": "tag", "start": 247, "end": 253}, - {"type": "tag", "start": 247, "end": 250}, - {"type": "punctuation", "start": 247, "end": 248}, - {"type": "punctuation", "start": 251, "end": 253}, - {"type": "tag", "start": 255, "end": 291}, - {"type": "tag", "start": 255, "end": 259}, - {"type": "punctuation", "start": 255, "end": 256}, - {"type": "attr_name", "start": 260, "end": 263}, - {"type": "attr_value", "start": 263, "end": 275}, - {"type": "punctuation", "start": 263, "end": 264}, - {"type": "punctuation", "start": 264, "end": 265}, - {"type": "punctuation", "start": 274, "end": 275}, - {"type": "attr_name", "start": 276, "end": 279}, - {"type": "attr_value", "start": 279, "end": 288}, - {"type": "punctuation", "start": 279, "end": 280}, - {"type": "punctuation", "start": 280, "end": 281}, - {"type": "punctuation", "start": 287, "end": 288}, - {"type": "punctuation", "start": 289, "end": 291}, - {"type": "tag", "start": 293, "end": 297}, - {"type": "tag", "start": 293, "end": 296}, - {"type": "punctuation", "start": 293, "end": 294}, - {"type": "punctuation", "start": 296, "end": 297}, - {"type": "tag", "start": 299, "end": 303}, - {"type": "tag", "start": 299, "end": 302}, - {"type": "punctuation", "start": 299, "end": 300}, - {"type": "punctuation", "start": 302, "end": 303}, - {"type": "tag", "start": 314, "end": 319}, - {"type": "tag", "start": 314, "end": 318}, - {"type": "punctuation", "start": 314, "end": 316}, - {"type": "punctuation", "start": 318, "end": 319}, - {"type": "tag", "start": 321, "end": 325}, - {"type": "tag", "start": 321, "end": 324}, - {"type": "punctuation", "start": 321, "end": 322}, - {"type": "punctuation", "start": 324, "end": 325}, - {"type": "tag", "start": 336, "end": 341}, - {"type": "tag", "start": 336, "end": 340}, - {"type": "punctuation", "start": 336, "end": 338}, - {"type": "punctuation", "start": 340, "end": 341}, - {"type": "tag", "start": 342, "end": 347}, - {"type": "tag", "start": 342, "end": 346}, - {"type": "punctuation", "start": 342, "end": 344}, - {"type": "punctuation", "start": 346, "end": 347}, - {"type": "tag", "start": 349, "end": 386}, - {"type": "tag", "start": 349, "end": 354}, - {"type": "punctuation", "start": 349, "end": 350}, - {"type": "attr_name", "start": 355, "end": 361}, - {"type": "attr_value", "start": 361, "end": 371}, - {"type": "punctuation", "start": 361, "end": 362}, - {"type": "punctuation", "start": 362, "end": 363}, - {"type": "punctuation", "start": 370, "end": 371}, - {"type": "attr_name", "start": 372, "end": 378}, - {"type": "attr_value", "start": 378, "end": 385}, - {"type": "punctuation", "start": 378, "end": 379}, - {"type": "punctuation", "start": 379, "end": 380}, - {"type": "punctuation", "start": 384, "end": 385}, - {"type": "punctuation", "start": 385, "end": 386}, - {"type": "tag", "start": 388, "end": 450}, - {"type": "tag", "start": 388, "end": 394}, - {"type": "punctuation", "start": 388, "end": 389}, - {"type": "attr_name", "start": 395, "end": 399}, - {"type": "attr_value", "start": 399, "end": 406}, - {"type": "punctuation", "start": 399, "end": 400}, - {"type": "punctuation", "start": 400, "end": 401}, - {"type": "punctuation", "start": 405, "end": 406}, - {"type": "attr_name", "start": 407, "end": 411}, - {"type": "attr_value", "start": 411, "end": 422}, - {"type": "punctuation", "start": 411, "end": 412}, - {"type": "punctuation", "start": 412, "end": 413}, - {"type": "punctuation", "start": 421, "end": 422}, - {"type": "attr_name", "start": 423, "end": 434}, - {"type": "attr_value", "start": 434, "end": 447}, - {"type": "punctuation", "start": 434, "end": 435}, - {"type": "punctuation", "start": 435, "end": 436}, - {"type": "punctuation", "start": 446, "end": 447}, - {"type": "punctuation", "start": 448, "end": 450}, - {"type": "tag", "start": 452, "end": 495}, - {"type": "tag", "start": 452, "end": 459}, - {"type": "punctuation", "start": 452, "end": 453}, - {"type": "attr_name", "start": 460, "end": 464}, - {"type": "attr_value", "start": 464, "end": 473}, - {"type": "punctuation", "start": 464, "end": 465}, - {"type": "punctuation", "start": 465, "end": 466}, - {"type": "punctuation", "start": 472, "end": 473}, - {"type": "attr_name", "start": 474, "end": 483}, - {"type": "attr_value", "start": 483, "end": 494}, - {"type": "punctuation", "start": 483, "end": 484}, - {"type": "punctuation", "start": 484, "end": 485}, - {"type": "punctuation", "start": 493, "end": 494}, - {"type": "punctuation", "start": 494, "end": 495}, - {"type": "tag", "start": 498, "end": 516}, - {"type": "tag", "start": 498, "end": 505}, - {"type": "punctuation", "start": 498, "end": 499}, - {"type": "attr_name", "start": 506, "end": 511}, - {"type": "attr_value", "start": 511, "end": 515}, - {"type": "punctuation", "start": 511, "end": 512}, - {"type": "punctuation", "start": 512, "end": 513}, - {"type": "punctuation", "start": 514, "end": 515}, - {"type": "punctuation", "start": 515, "end": 516}, - {"type": "tag", "start": 521, "end": 530}, - {"type": "tag", "start": 521, "end": 529}, - {"type": "punctuation", "start": 521, "end": 523}, - {"type": "punctuation", "start": 529, "end": 530}, - {"type": "tag", "start": 533, "end": 551}, - {"type": "tag", "start": 533, "end": 540}, - {"type": "punctuation", "start": 533, "end": 534}, - {"type": "attr_name", "start": 541, "end": 546}, - {"type": "attr_value", "start": 546, "end": 550}, - {"type": "punctuation", "start": 546, "end": 547}, - {"type": "punctuation", "start": 547, "end": 548}, - {"type": "punctuation", "start": 549, "end": 550}, - {"type": "punctuation", "start": 550, "end": 551}, - {"type": "tag", "start": 557, "end": 566}, - {"type": "tag", "start": 557, "end": 565}, - {"type": "punctuation", "start": 557, "end": 559}, - {"type": "punctuation", "start": 565, "end": 566}, - {"type": "tag", "start": 568, "end": 577}, - {"type": "tag", "start": 568, "end": 576}, - {"type": "punctuation", "start": 568, "end": 570}, - {"type": "punctuation", "start": 576, "end": 577}, - {"type": "tag", "start": 578, "end": 585}, - {"type": "tag", "start": 578, "end": 584}, - {"type": "punctuation", "start": 578, "end": 580}, - {"type": "punctuation", "start": 584, "end": 585}, - {"type": "tag", "start": 587, "end": 618}, - {"type": "tag", "start": 587, "end": 594}, - {"type": "punctuation", "start": 587, "end": 588}, - {"type": "attr_name", "start": 595, "end": 599}, - {"type": "attr_value", "start": 599, "end": 617}, - {"type": "punctuation", "start": 599, "end": 600}, - {"type": "punctuation", "start": 600, "end": 601}, - {"type": "punctuation", "start": 616, "end": 617}, - {"type": "punctuation", "start": 617, "end": 618}, - {"type": "script", "start": 618, "end": 642}, - {"type": "lang_js", "start": 618, "end": 642}, - {"type": "keyword", "start": 620, "end": 625}, - {"type": "operator", "start": 629, "end": 630}, - {"type": "string", "start": 631, "end": 640}, - {"type": "punctuation", "start": 640, "end": 641}, - {"type": "tag", "start": 642, "end": 651}, - {"type": "tag", "start": 642, "end": 650}, - {"type": "punctuation", "start": 642, "end": 644}, - {"type": "punctuation", "start": 650, "end": 651}, - {"type": "tag", "start": 653, "end": 676}, - {"type": "tag", "start": 653, "end": 659}, - {"type": "punctuation", "start": 653, "end": 654}, - {"type": "attr_name", "start": 660, "end": 664}, - {"type": "attr_value", "start": 664, "end": 675}, - {"type": "punctuation", "start": 664, "end": 665}, - {"type": "punctuation", "start": 665, "end": 666}, - {"type": "punctuation", "start": 674, "end": 675}, - {"type": "punctuation", "start": 675, "end": 676}, - {"type": "style", "start": 676, "end": 720}, - {"type": "lang_css", "start": 676, "end": 720}, - {"type": "selector", "start": 678, "end": 694}, - {"type": "punctuation", "start": 695, "end": 696}, - {"type": "property", "start": 699, "end": 706}, - {"type": "punctuation", "start": 706, "end": 707}, - {"type": "string", "start": 708, "end": 715}, - {"type": "punctuation", "start": 715, "end": 716}, - {"type": "punctuation", "start": 718, "end": 719}, - {"type": "tag", "start": 720, "end": 728}, - {"type": "tag", "start": 720, "end": 727}, - {"type": "punctuation", "start": 720, "end": 722}, - {"type": "punctuation", "start": 727, "end": 728}, - {"type": "cdata", "start": 730, "end": 778} - ], - "html": "<!doctype html>\n\n<div class=\"test\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">some <span class=\"a b c\">text</span></p>\n\n<button type=\"button\" disabled>click me</button>\n\n<!-- comment <div>a<br /> b</div> <script> -->\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<form action=\"/submit\" method=\"post\">\n\t<input type=\"text\" name=\"username\" placeholder=\"Enter name\" />\n\t<select name=\"option\" data-role=\"dropdown\">\n\t\t<option value=\"1\">First</option>\n\t\t<option value=\"2\">Second</option>\n\t</select>\n</form>\n\n<script type=\"text/javascript\">\n\tconst ok = '<style>';\n</script>\n\n<style type=\"text/css\">\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n\n<![CDATA[ if (a < 0) alert(\"b\"); <not-a-tag> ]]>\n" -} diff --git a/src/fixtures/generated/html/html_complex.txt b/src/fixtures/generated/html/html_complex.txt index c249da77..8fd58eb9 100644 --- a/src/fixtures/generated/html/html_complex.txt +++ b/src/fixtures/generated/html/html_complex.txt @@ -1,3 +1,25 @@ +=== STATS === +Sample length: 779 characters +Total tokens: 232 + +Token types (16 unique): + punctuation: 120 + tag: 64 + attr_name: 18 + attr_value: 17 + string: 2 + doctype: 1 + comment: 1 + script: 1 + lang_js: 1 + keyword: 1 + operator: 1 + style: 1 + lang_css: 1 + selector: 1 + property: 1 + cdata: 1 + === TOKENS === 0-15 doctype 17-35 tag
    @@ -231,25 +253,3 @@ 720-722 punctuation 730-778 cdata ]]> - -=== STATS === -Total tokens: 232 -Sample length: 779 characters - -Token types: - punctuation: 120 - tag: 64 - attr_name: 18 - attr_value: 17 - string: 2 - doctype: 1 - comment: 1 - script: 1 - lang_js: 1 - keyword: 1 - operator: 1 - style: 1 - lang_css: 1 - selector: 1 - property: 1 - cdata: 1 diff --git a/src/fixtures/generated/json/json_complex.html b/src/fixtures/generated/json/json_complex.html new file mode 100644 index 00000000..7e3dd385 --- /dev/null +++ b/src/fixtures/generated/json/json_complex.html @@ -0,0 +1,14 @@ +{ + "string": "a string", + "number": 12345, + "boolean": true, + "null": null, + "empty": "", + "escaped": "quote: \"test\" and backslash: \\", + "object": { + "array": [1, "b", false], + "strings": ["1", "2", "3"], + "mixed": ["start", 123, true, "middle", null, "end"], + "nested": [["a", "str", ""], {"key": "nested value"}] + } +} diff --git a/src/fixtures/generated/json/json_complex.json b/src/fixtures/generated/json/json_complex.json deleted file mode 100644 index 2b43c70d..00000000 --- a/src/fixtures/generated/json/json_complex.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "sample": { - "lang": "json", - "variant": "complex", - "content": "{\n\t\"string\": \"a string\",\n\t\"number\": 12345,\n\t\"boolean\": true,\n\t\"null\": null,\n\t\"empty\": \"\",\n\t\"escaped\": \"quote: \\\"test\\\" and backslash: \\\\\",\n\t\"object\": {\n\t\t\"array\": [1, \"b\", false],\n\t\t\"strings\": [\"1\", \"2\", \"3\"],\n\t\t\"mixed\": [\"start\", 123, true, \"middle\", null, \"end\"],\n\t\t\"nested\": [[\"a\", \"str\", \"\"], {\"key\": \"nested value\"}]\n\t}\n}\n", - "filepath": "src/lib/samples/sample_complex.json" - }, - "tokens": [ - {"type": "punctuation", "start": 0, "end": 1}, - {"type": "property", "start": 3, "end": 11}, - {"type": "operator", "start": 11, "end": 12}, - {"type": "string", "start": 13, "end": 23}, - {"type": "punctuation", "start": 23, "end": 24}, - {"type": "property", "start": 26, "end": 34}, - {"type": "operator", "start": 34, "end": 35}, - {"type": "number", "start": 36, "end": 41}, - {"type": "punctuation", "start": 41, "end": 42}, - {"type": "property", "start": 44, "end": 53}, - {"type": "operator", "start": 53, "end": 54}, - {"type": "boolean", "start": 55, "end": 59}, - {"type": "punctuation", "start": 59, "end": 60}, - {"type": "property", "start": 62, "end": 68}, - {"type": "operator", "start": 68, "end": 69}, - {"type": "null", "start": 70, "end": 74}, - {"type": "punctuation", "start": 74, "end": 75}, - {"type": "property", "start": 77, "end": 84}, - {"type": "operator", "start": 84, "end": 85}, - {"type": "string", "start": 86, "end": 88}, - {"type": "punctuation", "start": 88, "end": 89}, - {"type": "property", "start": 91, "end": 100}, - {"type": "operator", "start": 100, "end": 101}, - {"type": "string", "start": 102, "end": 137}, - {"type": "punctuation", "start": 137, "end": 138}, - {"type": "property", "start": 140, "end": 148}, - {"type": "operator", "start": 148, "end": 149}, - {"type": "punctuation", "start": 150, "end": 151}, - {"type": "property", "start": 154, "end": 161}, - {"type": "operator", "start": 161, "end": 162}, - {"type": "punctuation", "start": 163, "end": 164}, - {"type": "number", "start": 164, "end": 165}, - {"type": "punctuation", "start": 165, "end": 166}, - {"type": "string", "start": 167, "end": 170}, - {"type": "punctuation", "start": 170, "end": 171}, - {"type": "boolean", "start": 172, "end": 177}, - {"type": "punctuation", "start": 177, "end": 178}, - {"type": "punctuation", "start": 178, "end": 179}, - {"type": "property", "start": 182, "end": 191}, - {"type": "operator", "start": 191, "end": 192}, - {"type": "punctuation", "start": 193, "end": 194}, - {"type": "string", "start": 194, "end": 197}, - {"type": "punctuation", "start": 197, "end": 198}, - {"type": "string", "start": 199, "end": 202}, - {"type": "punctuation", "start": 202, "end": 203}, - {"type": "string", "start": 204, "end": 207}, - {"type": "punctuation", "start": 207, "end": 208}, - {"type": "punctuation", "start": 208, "end": 209}, - {"type": "property", "start": 212, "end": 219}, - {"type": "operator", "start": 219, "end": 220}, - {"type": "punctuation", "start": 221, "end": 222}, - {"type": "string", "start": 222, "end": 229}, - {"type": "punctuation", "start": 229, "end": 230}, - {"type": "number", "start": 231, "end": 234}, - {"type": "punctuation", "start": 234, "end": 235}, - {"type": "boolean", "start": 236, "end": 240}, - {"type": "punctuation", "start": 240, "end": 241}, - {"type": "string", "start": 242, "end": 250}, - {"type": "punctuation", "start": 250, "end": 251}, - {"type": "null", "start": 252, "end": 256}, - {"type": "punctuation", "start": 256, "end": 257}, - {"type": "string", "start": 258, "end": 263}, - {"type": "punctuation", "start": 263, "end": 264}, - {"type": "punctuation", "start": 264, "end": 265}, - {"type": "property", "start": 268, "end": 276}, - {"type": "operator", "start": 276, "end": 277}, - {"type": "punctuation", "start": 278, "end": 279}, - {"type": "punctuation", "start": 279, "end": 280}, - {"type": "string", "start": 280, "end": 283}, - {"type": "punctuation", "start": 283, "end": 284}, - {"type": "string", "start": 285, "end": 290}, - {"type": "punctuation", "start": 290, "end": 291}, - {"type": "string", "start": 292, "end": 294}, - {"type": "punctuation", "start": 294, "end": 295}, - {"type": "punctuation", "start": 295, "end": 296}, - {"type": "punctuation", "start": 297, "end": 298}, - {"type": "property", "start": 298, "end": 303}, - {"type": "operator", "start": 303, "end": 304}, - {"type": "string", "start": 305, "end": 319}, - {"type": "punctuation", "start": 319, "end": 320}, - {"type": "punctuation", "start": 320, "end": 321}, - {"type": "punctuation", "start": 323, "end": 324}, - {"type": "punctuation", "start": 325, "end": 326} - ], - "html": "{\n\t\"string\": \"a string\",\n\t\"number\": 12345,\n\t\"boolean\": true,\n\t\"null\": null,\n\t\"empty\": \"\",\n\t\"escaped\": \"quote: \\\"test\\\" and backslash: \\\\\",\n\t\"object\": {\n\t\t\"array\": [1, \"b\", false],\n\t\t\"strings\": [\"1\", \"2\", \"3\"],\n\t\t\"mixed\": [\"start\", 123, true, \"middle\", null, \"end\"],\n\t\t\"nested\": [[\"a\", \"str\", \"\"], {\"key\": \"nested value\"}]\n\t}\n}\n" -} diff --git a/src/fixtures/generated/json/json_complex.txt b/src/fixtures/generated/json/json_complex.txt index 082fc2fa..e32ee2b3 100644 --- a/src/fixtures/generated/json/json_complex.txt +++ b/src/fixtures/generated/json/json_complex.txt @@ -1,3 +1,16 @@ +=== STATS === +Sample length: 327 characters +Total tokens: 83 + +Token types (7 unique): + punctuation: 37 + string: 14 + property: 12 + operator: 12 + number: 3 + boolean: 3 + null: 2 + === TOKENS === 0-1 punctuation { 3-11 property "string" @@ -82,16 +95,3 @@ 320-321 punctuation ] 323-324 punctuation } 325-326 punctuation } - -=== STATS === -Total tokens: 83 -Sample length: 327 characters - -Token types: - punctuation: 37 - string: 14 - property: 12 - operator: 12 - number: 3 - boolean: 3 - null: 2 diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html new file mode 100644 index 00000000..f0ea242f --- /dev/null +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -0,0 +1,145 @@ +<script lang="ts" module> + export const HELLO = 'world'; +</script> + +<script lang="ts"> + // @ts-expect-error + import Thing from '$lib/Thing.svelte'; + import type {Snippet} from 'svelte'; + + const { + thing, + bound = $bindable(true), + children, + onclick, + }: { + thing: Record<string, any>; + bound?: boolean; + children: Snippet; + onclick?: () => void; + } = $props(); + + const thing_keys = $derived(Object.keys(thing)); + + const a = 1; + + const b = 'b'; + + let c: boolean = $state(true); + + const attachment = (_p1: string, _p2: number) => (_: HTMLElement) => { + element_ref; + }; + + let value = $state(''); + let element_ref: HTMLElement; +</script> + +<h1>hello {HELLO}!</h1> + +{#each thing_keys as key (key)} + {@const v = thing[key]} + {v} +{/each} + +{#if c} + <Thing string_prop="a" number_prop={1} /> +{:else} + <Thing string_prop="b" number_prop={2} onthing={() => (c = !c)}> + {@render children()} + </Thing> +{/if} + +{@html '<strong>raw html</strong>'} + +<input bind:value type="text" /> + +<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}> + interactive element +</div> + +{@render my_snippet()} + +{#snippet my_snippet()} + <button {onclick}>click handler</button> +{/snippet} + +<div class="test special" id="unique_id"> + <p>hello world!</p> +</div> + +<p class="some_class hypen-class"> + some <span class="a b c">text</span> +</p> + +<button type="button" disabled> click me </button> + +<!-- comment <div>a<br /> b</div> --> +{a} +{b} +{bound} + +<br /> + +<hr /> + +<img src="image.jpg" alt="access" /> + +<ul> + <li>list item 1</li> + <li>list item 2</li> +</ul> + +<!-- embedded tags for boundary testing --> +<div> + <script> + const inline_js = 'no lang attr'; + </script> + <style> + .inline { + color: blue; + } + </style> +</div> + +<style> + .some_class { + color: red; + } + + .hypen-class { + font-size: 16px; + } + + p { + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + } + + /* comment */ + + /* + multi + line + + <comment> + + */ + + #unique_id { + background-color: blue; + } + + div > p { + margin: 10px; + } + + @media (max-width: 600px) { + :global(body) { + background-color: light-dark(lightblue, darkblue); + } + } + + .special::before { + content: '< & >'; + } +</style> diff --git a/src/fixtures/generated/svelte/svelte_complex.json b/src/fixtures/generated/svelte/svelte_complex.json deleted file mode 100644 index f56c182a..00000000 --- a/src/fixtures/generated/svelte/svelte_complex.json +++ /dev/null @@ -1,573 +0,0 @@ -{ - "sample": { - "lang": "svelte", - "variant": "complex", - "content": "\n\n\n\n

    hello {HELLO}!

    \n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t\n{:else}\n\t (c = !c)}>\n\t\t{@render children()}\n\t\n{/if}\n\n{@html 'raw html'}\n\n\n\n
    \n\tinteractive element\n
    \n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t\n{/snippet}\n\n
    \n\t

    hello world!

    \n
    \n\n

    \n\tsome text\n

    \n\n\n\n\n{a}\n{b}\n{bound}\n\n
    \n\n
    \n\n\"access\"\n\n
      \n\t
    • list item 1
    • \n\t
    • list item 2
    • \n
    \n\n\n
    \n\t\n\t\n
    \n\n\n", - "filepath": "src/lib/samples/sample_complex.svelte" - }, - "tokens": [ - {"type": "tag", "start": 0, "end": 25}, - {"type": "tag", "start": 0, "end": 7}, - {"type": "punctuation", "start": 0, "end": 1}, - {"type": "attr_name", "start": 8, "end": 12}, - {"type": "attr_value", "start": 12, "end": 17}, - {"type": "punctuation", "start": 12, "end": 13}, - {"type": "punctuation", "start": 13, "end": 14}, - {"type": "punctuation", "start": 16, "end": 17}, - {"type": "attr_name", "start": 18, "end": 24}, - {"type": "punctuation", "start": 24, "end": 25}, - {"type": "script", "start": 25, "end": 57}, - {"type": "lang_ts", "start": 25, "end": 57}, - {"type": "special_keyword", "start": 27, "end": 33}, - {"type": "keyword", "start": 34, "end": 39}, - {"type": "constant", "start": 40, "end": 45}, - {"type": "operator", "start": 46, "end": 47}, - {"type": "string", "start": 48, "end": 55}, - {"type": "punctuation", "start": 55, "end": 56}, - {"type": "tag", "start": 57, "end": 66}, - {"type": "tag", "start": 57, "end": 65}, - {"type": "punctuation", "start": 57, "end": 59}, - {"type": "punctuation", "start": 65, "end": 66}, - {"type": "tag", "start": 68, "end": 86}, - {"type": "tag", "start": 68, "end": 75}, - {"type": "punctuation", "start": 68, "end": 69}, - {"type": "attr_name", "start": 76, "end": 80}, - {"type": "attr_value", "start": 80, "end": 85}, - {"type": "punctuation", "start": 80, "end": 81}, - {"type": "punctuation", "start": 81, "end": 82}, - {"type": "punctuation", "start": 84, "end": 85}, - {"type": "punctuation", "start": 85, "end": 86}, - {"type": "script", "start": 86, "end": 635}, - {"type": "lang_ts", "start": 86, "end": 635}, - {"type": "comment", "start": 88, "end": 107}, - {"type": "special_keyword", "start": 109, "end": 115}, - {"type": "special_keyword", "start": 122, "end": 126}, - {"type": "string", "start": 127, "end": 146}, - {"type": "punctuation", "start": 146, "end": 147}, - {"type": "special_keyword", "start": 149, "end": 155}, - {"type": "keyword", "start": 156, "end": 160}, - {"type": "punctuation", "start": 161, "end": 162}, - {"type": "punctuation", "start": 169, "end": 170}, - {"type": "special_keyword", "start": 171, "end": 175}, - {"type": "string", "start": 176, "end": 184}, - {"type": "punctuation", "start": 184, "end": 185}, - {"type": "keyword", "start": 188, "end": 193}, - {"type": "punctuation", "start": 194, "end": 195}, - {"type": "punctuation", "start": 203, "end": 204}, - {"type": "operator", "start": 213, "end": 214}, - {"type": "function", "start": 215, "end": 224}, - {"type": "punctuation", "start": 224, "end": 225}, - {"type": "boolean", "start": 225, "end": 229}, - {"type": "punctuation", "start": 229, "end": 230}, - {"type": "punctuation", "start": 230, "end": 231}, - {"type": "punctuation", "start": 242, "end": 243}, - {"type": "punctuation", "start": 253, "end": 254}, - {"type": "punctuation", "start": 256, "end": 257}, - {"type": "operator", "start": 257, "end": 258}, - {"type": "punctuation", "start": 259, "end": 260}, - {"type": "operator", "start": 268, "end": 269}, - {"type": "operator", "start": 276, "end": 277}, - {"type": "builtin", "start": 277, "end": 283}, - {"type": "punctuation", "start": 283, "end": 284}, - {"type": "builtin", "start": 285, "end": 288}, - {"type": "operator", "start": 288, "end": 289}, - {"type": "punctuation", "start": 289, "end": 290}, - {"type": "operator", "start": 298, "end": 299}, - {"type": "operator", "start": 299, "end": 300}, - {"type": "builtin", "start": 301, "end": 308}, - {"type": "punctuation", "start": 308, "end": 309}, - {"type": "operator", "start": 320, "end": 321}, - {"type": "punctuation", "start": 329, "end": 330}, - {"type": "operator", "start": 340, "end": 341}, - {"type": "operator", "start": 341, "end": 342}, - {"type": "punctuation", "start": 343, "end": 344}, - {"type": "punctuation", "start": 344, "end": 345}, - {"type": "operator", "start": 346, "end": 348}, - {"type": "keyword", "start": 349, "end": 353}, - {"type": "punctuation", "start": 353, "end": 354}, - {"type": "punctuation", "start": 356, "end": 357}, - {"type": "operator", "start": 358, "end": 359}, - {"type": "function", "start": 360, "end": 366}, - {"type": "punctuation", "start": 366, "end": 367}, - {"type": "punctuation", "start": 367, "end": 368}, - {"type": "punctuation", "start": 368, "end": 369}, - {"type": "keyword", "start": 372, "end": 377}, - {"type": "operator", "start": 389, "end": 390}, - {"type": "function", "start": 391, "end": 399}, - {"type": "punctuation", "start": 399, "end": 400}, - {"type": "punctuation", "start": 406, "end": 407}, - {"type": "function", "start": 407, "end": 411}, - {"type": "punctuation", "start": 411, "end": 412}, - {"type": "punctuation", "start": 417, "end": 418}, - {"type": "punctuation", "start": 418, "end": 419}, - {"type": "punctuation", "start": 419, "end": 420}, - {"type": "keyword", "start": 423, "end": 428}, - {"type": "operator", "start": 431, "end": 432}, - {"type": "number", "start": 433, "end": 434}, - {"type": "punctuation", "start": 434, "end": 435}, - {"type": "keyword", "start": 438, "end": 443}, - {"type": "operator", "start": 446, "end": 447}, - {"type": "string", "start": 448, "end": 451}, - {"type": "punctuation", "start": 451, "end": 452}, - {"type": "keyword", "start": 455, "end": 458}, - {"type": "type_annotation", "start": 460, "end": 470}, - {"type": ":", "start": 460, "end": 461}, - {"type": "type", "start": 461, "end": 470}, - {"type": "builtin", "start": 462, "end": 469}, - {"type": "operator", "start": 470, "end": 471}, - {"type": "function", "start": 472, "end": 478}, - {"type": "punctuation", "start": 478, "end": 479}, - {"type": "boolean", "start": 479, "end": 483}, - {"type": "punctuation", "start": 483, "end": 484}, - {"type": "punctuation", "start": 484, "end": 485}, - {"type": "keyword", "start": 488, "end": 493}, - {"type": "function_variable", "start": 494, "end": 504}, - {"type": "operator", "start": 505, "end": 506}, - {"type": "punctuation", "start": 507, "end": 508}, - {"type": "operator", "start": 511, "end": 512}, - {"type": "builtin", "start": 513, "end": 519}, - {"type": "punctuation", "start": 519, "end": 520}, - {"type": "operator", "start": 524, "end": 525}, - {"type": "builtin", "start": 526, "end": 532}, - {"type": "punctuation", "start": 532, "end": 533}, - {"type": "operator", "start": 534, "end": 536}, - {"type": "punctuation", "start": 537, "end": 538}, - {"type": "operator", "start": 539, "end": 540}, - {"type": "punctuation", "start": 552, "end": 553}, - {"type": "operator", "start": 554, "end": 556}, - {"type": "punctuation", "start": 557, "end": 558}, - {"type": "punctuation", "start": 572, "end": 573}, - {"type": "punctuation", "start": 575, "end": 576}, - {"type": "punctuation", "start": 576, "end": 577}, - {"type": "keyword", "start": 580, "end": 583}, - {"type": "operator", "start": 590, "end": 591}, - {"type": "function", "start": 592, "end": 598}, - {"type": "punctuation", "start": 598, "end": 599}, - {"type": "string", "start": 599, "end": 601}, - {"type": "punctuation", "start": 601, "end": 602}, - {"type": "punctuation", "start": 602, "end": 603}, - {"type": "keyword", "start": 605, "end": 608}, - {"type": "operator", "start": 620, "end": 621}, - {"type": "punctuation", "start": 633, "end": 634}, - {"type": "tag", "start": 635, "end": 644}, - {"type": "tag", "start": 635, "end": 643}, - {"type": "punctuation", "start": 635, "end": 637}, - {"type": "punctuation", "start": 643, "end": 644}, - {"type": "tag", "start": 646, "end": 650}, - {"type": "tag", "start": 646, "end": 649}, - {"type": "punctuation", "start": 646, "end": 647}, - {"type": "punctuation", "start": 649, "end": 650}, - {"type": "lang_ts", "start": 656, "end": 663}, - {"type": "punctuation", "start": 656, "end": 657}, - {"type": "constant", "start": 657, "end": 662}, - {"type": "punctuation", "start": 662, "end": 663}, - {"type": "tag", "start": 664, "end": 669}, - {"type": "tag", "start": 664, "end": 668}, - {"type": "punctuation", "start": 664, "end": 666}, - {"type": "punctuation", "start": 668, "end": 669}, - {"type": "each", "start": 671, "end": 702}, - {"type": "punctuation", "start": 671, "end": 672}, - {"type": "keyword", "start": 672, "end": 677}, - {"type": "lang_ts", "start": 678, "end": 689}, - {"type": "keyword", "start": 689, "end": 691}, - {"type": "lang_ts", "start": 692, "end": 696}, - {"type": "lang_ts", "start": 696, "end": 701}, - {"type": "punctuation", "start": 696, "end": 697}, - {"type": "punctuation", "start": 700, "end": 701}, - {"type": "punctuation", "start": 701, "end": 702}, - {"type": "lang_ts", "start": 704, "end": 727}, - {"type": "punctuation", "start": 704, "end": 705}, - {"type": "keyword", "start": 706, "end": 711}, - {"type": "operator", "start": 714, "end": 715}, - {"type": "punctuation", "start": 721, "end": 722}, - {"type": "punctuation", "start": 725, "end": 726}, - {"type": "punctuation", "start": 726, "end": 727}, - {"type": "lang_ts", "start": 729, "end": 732}, - {"type": "punctuation", "start": 729, "end": 730}, - {"type": "punctuation", "start": 731, "end": 732}, - {"type": "each", "start": 733, "end": 740}, - {"type": "punctuation", "start": 733, "end": 734}, - {"type": "keyword", "start": 734, "end": 739}, - {"type": "punctuation", "start": 739, "end": 740}, - {"type": "lang_ts", "start": 742, "end": 749}, - {"type": "punctuation", "start": 742, "end": 743}, - {"type": "special_keyword", "start": 744, "end": 746}, - {"type": "punctuation", "start": 748, "end": 749}, - {"type": "tag", "start": 751, "end": 792}, - {"type": "tag", "start": 751, "end": 757}, - {"type": "punctuation", "start": 751, "end": 752}, - {"type": "attr_name", "start": 758, "end": 769}, - {"type": "attr_value", "start": 769, "end": 773}, - {"type": "punctuation", "start": 769, "end": 770}, - {"type": "punctuation", "start": 770, "end": 771}, - {"type": "punctuation", "start": 772, "end": 773}, - {"type": "attr_name", "start": 774, "end": 786}, - {"type": "lang_ts", "start": 786, "end": 789}, - {"type": "punctuation", "start": 786, "end": 787}, - {"type": "number", "start": 787, "end": 788}, - {"type": "punctuation", "start": 788, "end": 789}, - {"type": "punctuation", "start": 790, "end": 792}, - {"type": "lang_ts", "start": 793, "end": 800}, - {"type": "punctuation", "start": 793, "end": 794}, - {"type": "operator", "start": 794, "end": 795}, - {"type": "special_keyword", "start": 795, "end": 799}, - {"type": "punctuation", "start": 799, "end": 800}, - {"type": "tag", "start": 802, "end": 866}, - {"type": "tag", "start": 802, "end": 808}, - {"type": "punctuation", "start": 802, "end": 803}, - {"type": "attr_name", "start": 809, "end": 820}, - {"type": "attr_value", "start": 820, "end": 824}, - {"type": "punctuation", "start": 820, "end": 821}, - {"type": "punctuation", "start": 821, "end": 822}, - {"type": "punctuation", "start": 823, "end": 824}, - {"type": "attr_name", "start": 825, "end": 837}, - {"type": "lang_ts", "start": 837, "end": 840}, - {"type": "punctuation", "start": 837, "end": 838}, - {"type": "number", "start": 838, "end": 839}, - {"type": "punctuation", "start": 839, "end": 840}, - {"type": "attr_name", "start": 841, "end": 849}, - {"type": "lang_ts", "start": 849, "end": 865}, - {"type": "punctuation", "start": 849, "end": 850}, - {"type": "punctuation", "start": 850, "end": 851}, - {"type": "punctuation", "start": 851, "end": 852}, - {"type": "operator", "start": 853, "end": 855}, - {"type": "punctuation", "start": 856, "end": 857}, - {"type": "operator", "start": 859, "end": 860}, - {"type": "operator", "start": 861, "end": 862}, - {"type": "punctuation", "start": 863, "end": 864}, - {"type": "punctuation", "start": 864, "end": 865}, - {"type": "punctuation", "start": 865, "end": 866}, - {"type": "lang_ts", "start": 869, "end": 889}, - {"type": "punctuation", "start": 869, "end": 870}, - {"type": "decorator", "start": 870, "end": 877}, - {"type": "at", "start": 870, "end": 871}, - {"type": "function", "start": 871, "end": 877}, - {"type": "function", "start": 878, "end": 886}, - {"type": "punctuation", "start": 886, "end": 887}, - {"type": "punctuation", "start": 887, "end": 888}, - {"type": "punctuation", "start": 888, "end": 889}, - {"type": "tag", "start": 891, "end": 899}, - {"type": "tag", "start": 891, "end": 898}, - {"type": "punctuation", "start": 891, "end": 893}, - {"type": "punctuation", "start": 898, "end": 899}, - {"type": "lang_ts", "start": 900, "end": 905}, - {"type": "punctuation", "start": 900, "end": 901}, - {"type": "operator", "start": 901, "end": 902}, - {"type": "special_keyword", "start": 902, "end": 904}, - {"type": "punctuation", "start": 904, "end": 905}, - {"type": "tag", "start": 915, "end": 923}, - {"type": "tag", "start": 915, "end": 922}, - {"type": "punctuation", "start": 915, "end": 916}, - {"type": "punctuation", "start": 922, "end": 923}, - {"type": "tag", "start": 931, "end": 940}, - {"type": "tag", "start": 931, "end": 939}, - {"type": "punctuation", "start": 931, "end": 933}, - {"type": "punctuation", "start": 939, "end": 940}, - {"type": "tag", "start": 944, "end": 976}, - {"type": "tag", "start": 944, "end": 950}, - {"type": "punctuation", "start": 944, "end": 945}, - {"type": "attr_name", "start": 951, "end": 961}, - {"type": "namespace", "start": 951, "end": 956}, - {"type": "attr_name", "start": 962, "end": 966}, - {"type": "attr_value", "start": 966, "end": 973}, - {"type": "punctuation", "start": 966, "end": 967}, - {"type": "punctuation", "start": 967, "end": 968}, - {"type": "punctuation", "start": 972, "end": 973}, - {"type": "punctuation", "start": 974, "end": 976}, - {"type": "tag", "start": 978, "end": 1058}, - {"type": "tag", "start": 978, "end": 982}, - {"type": "punctuation", "start": 978, "end": 979}, - {"type": "attr_name", "start": 983, "end": 993}, - {"type": "namespace", "start": 983, "end": 988}, - {"type": "lang_ts", "start": 993, "end": 1006}, - {"type": "punctuation", "start": 993, "end": 994}, - {"type": "punctuation", "start": 1005, "end": 1006}, - {"type": "attr_name", "start": 1007, "end": 1020}, - {"type": "namespace", "start": 1007, "end": 1013}, - {"type": "lang_ts", "start": 1020, "end": 1023}, - {"type": "punctuation", "start": 1020, "end": 1021}, - {"type": "punctuation", "start": 1022, "end": 1023}, - {"type": "lang_ts", "start": 1024, "end": 1057}, - {"type": "punctuation", "start": 1024, "end": 1025}, - {"type": "decorator", "start": 1025, "end": 1032}, - {"type": "at", "start": 1025, "end": 1026}, - {"type": "function", "start": 1026, "end": 1032}, - {"type": "function", "start": 1033, "end": 1043}, - {"type": "punctuation", "start": 1043, "end": 1044}, - {"type": "string", "start": 1044, "end": 1051}, - {"type": "punctuation", "start": 1051, "end": 1052}, - {"type": "number", "start": 1053, "end": 1055}, - {"type": "punctuation", "start": 1055, "end": 1056}, - {"type": "punctuation", "start": 1056, "end": 1057}, - {"type": "punctuation", "start": 1057, "end": 1058}, - {"type": "tag", "start": 1080, "end": 1086}, - {"type": "tag", "start": 1080, "end": 1085}, - {"type": "punctuation", "start": 1080, "end": 1082}, - {"type": "punctuation", "start": 1085, "end": 1086}, - {"type": "lang_ts", "start": 1088, "end": 1110}, - {"type": "punctuation", "start": 1088, "end": 1089}, - {"type": "decorator", "start": 1089, "end": 1096}, - {"type": "at", "start": 1089, "end": 1090}, - {"type": "function", "start": 1090, "end": 1096}, - {"type": "function", "start": 1097, "end": 1107}, - {"type": "punctuation", "start": 1107, "end": 1108}, - {"type": "punctuation", "start": 1108, "end": 1109}, - {"type": "punctuation", "start": 1109, "end": 1110}, - {"type": "lang_ts", "start": 1112, "end": 1135}, - {"type": "punctuation", "start": 1112, "end": 1113}, - {"type": "function", "start": 1122, "end": 1132}, - {"type": "punctuation", "start": 1132, "end": 1133}, - {"type": "punctuation", "start": 1133, "end": 1134}, - {"type": "punctuation", "start": 1134, "end": 1135}, - {"type": "tag", "start": 1137, "end": 1155}, - {"type": "tag", "start": 1137, "end": 1144}, - {"type": "punctuation", "start": 1137, "end": 1138}, - {"type": "lang_ts", "start": 1145, "end": 1154}, - {"type": "punctuation", "start": 1145, "end": 1146}, - {"type": "punctuation", "start": 1153, "end": 1154}, - {"type": "punctuation", "start": 1154, "end": 1155}, - {"type": "tag", "start": 1168, "end": 1177}, - {"type": "tag", "start": 1168, "end": 1176}, - {"type": "punctuation", "start": 1168, "end": 1170}, - {"type": "punctuation", "start": 1176, "end": 1177}, - {"type": "lang_ts", "start": 1178, "end": 1188}, - {"type": "punctuation", "start": 1178, "end": 1179}, - {"type": "operator", "start": 1179, "end": 1180}, - {"type": "punctuation", "start": 1187, "end": 1188}, - {"type": "tag", "start": 1190, "end": 1231}, - {"type": "tag", "start": 1190, "end": 1194}, - {"type": "punctuation", "start": 1190, "end": 1191}, - {"type": "attr_name", "start": 1195, "end": 1200}, - {"type": "attr_value", "start": 1200, "end": 1215}, - {"type": "punctuation", "start": 1200, "end": 1201}, - {"type": "punctuation", "start": 1201, "end": 1202}, - {"type": "punctuation", "start": 1214, "end": 1215}, - {"type": "attr_name", "start": 1216, "end": 1218}, - {"type": "attr_value", "start": 1218, "end": 1230}, - {"type": "punctuation", "start": 1218, "end": 1219}, - {"type": "punctuation", "start": 1219, "end": 1220}, - {"type": "punctuation", "start": 1229, "end": 1230}, - {"type": "punctuation", "start": 1230, "end": 1231}, - {"type": "tag", "start": 1233, "end": 1236}, - {"type": "tag", "start": 1233, "end": 1235}, - {"type": "punctuation", "start": 1233, "end": 1234}, - {"type": "punctuation", "start": 1235, "end": 1236}, - {"type": "tag", "start": 1248, "end": 1252}, - {"type": "tag", "start": 1248, "end": 1251}, - {"type": "punctuation", "start": 1248, "end": 1250}, - {"type": "punctuation", "start": 1251, "end": 1252}, - {"type": "tag", "start": 1253, "end": 1259}, - {"type": "tag", "start": 1253, "end": 1258}, - {"type": "punctuation", "start": 1253, "end": 1255}, - {"type": "punctuation", "start": 1258, "end": 1259}, - {"type": "tag", "start": 1261, "end": 1295}, - {"type": "tag", "start": 1261, "end": 1263}, - {"type": "punctuation", "start": 1261, "end": 1262}, - {"type": "attr_name", "start": 1264, "end": 1269}, - {"type": "attr_value", "start": 1269, "end": 1294}, - {"type": "punctuation", "start": 1269, "end": 1270}, - {"type": "punctuation", "start": 1270, "end": 1271}, - {"type": "punctuation", "start": 1293, "end": 1294}, - {"type": "punctuation", "start": 1294, "end": 1295}, - {"type": "tag", "start": 1302, "end": 1322}, - {"type": "tag", "start": 1302, "end": 1307}, - {"type": "punctuation", "start": 1302, "end": 1303}, - {"type": "attr_name", "start": 1308, "end": 1313}, - {"type": "attr_value", "start": 1313, "end": 1321}, - {"type": "punctuation", "start": 1313, "end": 1314}, - {"type": "punctuation", "start": 1314, "end": 1315}, - {"type": "punctuation", "start": 1320, "end": 1321}, - {"type": "punctuation", "start": 1321, "end": 1322}, - {"type": "tag", "start": 1326, "end": 1333}, - {"type": "tag", "start": 1326, "end": 1332}, - {"type": "punctuation", "start": 1326, "end": 1328}, - {"type": "punctuation", "start": 1332, "end": 1333}, - {"type": "tag", "start": 1334, "end": 1338}, - {"type": "tag", "start": 1334, "end": 1337}, - {"type": "punctuation", "start": 1334, "end": 1336}, - {"type": "punctuation", "start": 1337, "end": 1338}, - {"type": "tag", "start": 1340, "end": 1371}, - {"type": "tag", "start": 1340, "end": 1347}, - {"type": "punctuation", "start": 1340, "end": 1341}, - {"type": "attr_name", "start": 1348, "end": 1352}, - {"type": "attr_value", "start": 1352, "end": 1361}, - {"type": "punctuation", "start": 1352, "end": 1353}, - {"type": "punctuation", "start": 1353, "end": 1354}, - {"type": "punctuation", "start": 1360, "end": 1361}, - {"type": "attr_name", "start": 1362, "end": 1370}, - {"type": "punctuation", "start": 1370, "end": 1371}, - {"type": "tag", "start": 1381, "end": 1390}, - {"type": "tag", "start": 1381, "end": 1389}, - {"type": "punctuation", "start": 1381, "end": 1383}, - {"type": "punctuation", "start": 1389, "end": 1390}, - {"type": "comment", "start": 1392, "end": 1429}, - {"type": "lang_ts", "start": 1430, "end": 1433}, - {"type": "punctuation", "start": 1430, "end": 1431}, - {"type": "punctuation", "start": 1432, "end": 1433}, - {"type": "lang_ts", "start": 1434, "end": 1437}, - {"type": "punctuation", "start": 1434, "end": 1435}, - {"type": "punctuation", "start": 1436, "end": 1437}, - {"type": "lang_ts", "start": 1438, "end": 1445}, - {"type": "punctuation", "start": 1438, "end": 1439}, - {"type": "punctuation", "start": 1444, "end": 1445}, - {"type": "tag", "start": 1447, "end": 1453}, - {"type": "tag", "start": 1447, "end": 1450}, - {"type": "punctuation", "start": 1447, "end": 1448}, - {"type": "punctuation", "start": 1451, "end": 1453}, - {"type": "tag", "start": 1455, "end": 1461}, - {"type": "tag", "start": 1455, "end": 1458}, - {"type": "punctuation", "start": 1455, "end": 1456}, - {"type": "punctuation", "start": 1459, "end": 1461}, - {"type": "tag", "start": 1463, "end": 1499}, - {"type": "tag", "start": 1463, "end": 1467}, - {"type": "punctuation", "start": 1463, "end": 1464}, - {"type": "attr_name", "start": 1468, "end": 1471}, - {"type": "attr_value", "start": 1471, "end": 1483}, - {"type": "punctuation", "start": 1471, "end": 1472}, - {"type": "punctuation", "start": 1472, "end": 1473}, - {"type": "punctuation", "start": 1482, "end": 1483}, - {"type": "attr_name", "start": 1484, "end": 1487}, - {"type": "attr_value", "start": 1487, "end": 1496}, - {"type": "punctuation", "start": 1487, "end": 1488}, - {"type": "punctuation", "start": 1488, "end": 1489}, - {"type": "punctuation", "start": 1495, "end": 1496}, - {"type": "punctuation", "start": 1497, "end": 1499}, - {"type": "tag", "start": 1501, "end": 1505}, - {"type": "tag", "start": 1501, "end": 1504}, - {"type": "punctuation", "start": 1501, "end": 1502}, - {"type": "punctuation", "start": 1504, "end": 1505}, - {"type": "tag", "start": 1507, "end": 1511}, - {"type": "tag", "start": 1507, "end": 1510}, - {"type": "punctuation", "start": 1507, "end": 1508}, - {"type": "punctuation", "start": 1510, "end": 1511}, - {"type": "tag", "start": 1522, "end": 1527}, - {"type": "tag", "start": 1522, "end": 1526}, - {"type": "punctuation", "start": 1522, "end": 1524}, - {"type": "punctuation", "start": 1526, "end": 1527}, - {"type": "tag", "start": 1529, "end": 1533}, - {"type": "tag", "start": 1529, "end": 1532}, - {"type": "punctuation", "start": 1529, "end": 1530}, - {"type": "punctuation", "start": 1532, "end": 1533}, - {"type": "tag", "start": 1544, "end": 1549}, - {"type": "tag", "start": 1544, "end": 1548}, - {"type": "punctuation", "start": 1544, "end": 1546}, - {"type": "punctuation", "start": 1548, "end": 1549}, - {"type": "tag", "start": 1550, "end": 1555}, - {"type": "tag", "start": 1550, "end": 1554}, - {"type": "punctuation", "start": 1550, "end": 1552}, - {"type": "punctuation", "start": 1554, "end": 1555}, - {"type": "comment", "start": 1557, "end": 1600}, - {"type": "tag", "start": 1601, "end": 1606}, - {"type": "tag", "start": 1601, "end": 1605}, - {"type": "punctuation", "start": 1601, "end": 1602}, - {"type": "punctuation", "start": 1605, "end": 1606}, - {"type": "tag", "start": 1608, "end": 1616}, - {"type": "tag", "start": 1608, "end": 1615}, - {"type": "punctuation", "start": 1608, "end": 1609}, - {"type": "punctuation", "start": 1615, "end": 1616}, - {"type": "script", "start": 1616, "end": 1654}, - {"type": "lang_ts", "start": 1616, "end": 1654}, - {"type": "keyword", "start": 1619, "end": 1624}, - {"type": "operator", "start": 1635, "end": 1636}, - {"type": "string", "start": 1637, "end": 1651}, - {"type": "punctuation", "start": 1651, "end": 1652}, - {"type": "tag", "start": 1654, "end": 1663}, - {"type": "tag", "start": 1654, "end": 1662}, - {"type": "punctuation", "start": 1654, "end": 1656}, - {"type": "punctuation", "start": 1662, "end": 1663}, - {"type": "tag", "start": 1665, "end": 1672}, - {"type": "tag", "start": 1665, "end": 1671}, - {"type": "punctuation", "start": 1665, "end": 1666}, - {"type": "punctuation", "start": 1671, "end": 1672}, - {"type": "style", "start": 1672, "end": 1706}, - {"type": "lang_css", "start": 1672, "end": 1706}, - {"type": "selector", "start": 1675, "end": 1682}, - {"type": "punctuation", "start": 1683, "end": 1684}, - {"type": "property", "start": 1688, "end": 1693}, - {"type": "punctuation", "start": 1693, "end": 1694}, - {"type": "punctuation", "start": 1699, "end": 1700}, - {"type": "punctuation", "start": 1703, "end": 1704}, - {"type": "tag", "start": 1706, "end": 1714}, - {"type": "tag", "start": 1706, "end": 1713}, - {"type": "punctuation", "start": 1706, "end": 1708}, - {"type": "punctuation", "start": 1713, "end": 1714}, - {"type": "tag", "start": 1715, "end": 1721}, - {"type": "tag", "start": 1715, "end": 1720}, - {"type": "punctuation", "start": 1715, "end": 1717}, - {"type": "punctuation", "start": 1720, "end": 1721}, - {"type": "tag", "start": 1723, "end": 1730}, - {"type": "tag", "start": 1723, "end": 1729}, - {"type": "punctuation", "start": 1723, "end": 1724}, - {"type": "punctuation", "start": 1729, "end": 1730}, - {"type": "style", "start": 1730, "end": 2133}, - {"type": "lang_css", "start": 1730, "end": 2133}, - {"type": "selector", "start": 1732, "end": 1743}, - {"type": "punctuation", "start": 1744, "end": 1745}, - {"type": "property", "start": 1748, "end": 1753}, - {"type": "punctuation", "start": 1753, "end": 1754}, - {"type": "punctuation", "start": 1758, "end": 1759}, - {"type": "punctuation", "start": 1761, "end": 1762}, - {"type": "selector", "start": 1765, "end": 1777}, - {"type": "punctuation", "start": 1778, "end": 1779}, - {"type": "property", "start": 1782, "end": 1791}, - {"type": "punctuation", "start": 1791, "end": 1792}, - {"type": "punctuation", "start": 1797, "end": 1798}, - {"type": "punctuation", "start": 1800, "end": 1801}, - {"type": "selector", "start": 1804, "end": 1805}, - {"type": "punctuation", "start": 1806, "end": 1807}, - {"type": "property", "start": 1810, "end": 1820}, - {"type": "punctuation", "start": 1820, "end": 1821}, - {"type": "function", "start": 1831, "end": 1835}, - {"type": "punctuation", "start": 1835, "end": 1836}, - {"type": "punctuation", "start": 1837, "end": 1838}, - {"type": "punctuation", "start": 1840, "end": 1841}, - {"type": "punctuation", "start": 1843, "end": 1844}, - {"type": "punctuation", "start": 1848, "end": 1849}, - {"type": "punctuation", "start": 1849, "end": 1850}, - {"type": "punctuation", "start": 1852, "end": 1853}, - {"type": "comment", "start": 1856, "end": 1869}, - {"type": "comment", "start": 1872, "end": 1904}, - {"type": "selector", "start": 1907, "end": 1917}, - {"type": "punctuation", "start": 1918, "end": 1919}, - {"type": "property", "start": 1922, "end": 1938}, - {"type": "punctuation", "start": 1938, "end": 1939}, - {"type": "punctuation", "start": 1944, "end": 1945}, - {"type": "punctuation", "start": 1947, "end": 1948}, - {"type": "selector", "start": 1951, "end": 1958}, - {"type": "punctuation", "start": 1959, "end": 1960}, - {"type": "property", "start": 1963, "end": 1969}, - {"type": "punctuation", "start": 1969, "end": 1970}, - {"type": "punctuation", "start": 1975, "end": 1976}, - {"type": "punctuation", "start": 1978, "end": 1979}, - {"type": "atrule", "start": 1982, "end": 2007}, - {"type": "rule", "start": 1982, "end": 1988}, - {"type": "punctuation", "start": 1989, "end": 1990}, - {"type": "property", "start": 1990, "end": 1999}, - {"type": "punctuation", "start": 1999, "end": 2000}, - {"type": "punctuation", "start": 2006, "end": 2007}, - {"type": "punctuation", "start": 2008, "end": 2009}, - {"type": "selector", "start": 2012, "end": 2025}, - {"type": "punctuation", "start": 2026, "end": 2027}, - {"type": "property", "start": 2031, "end": 2047}, - {"type": "punctuation", "start": 2047, "end": 2048}, - {"type": "function", "start": 2049, "end": 2059}, - {"type": "punctuation", "start": 2059, "end": 2060}, - {"type": "punctuation", "start": 2069, "end": 2070}, - {"type": "punctuation", "start": 2079, "end": 2080}, - {"type": "punctuation", "start": 2080, "end": 2081}, - {"type": "punctuation", "start": 2084, "end": 2085}, - {"type": "punctuation", "start": 2087, "end": 2088}, - {"type": "selector", "start": 2091, "end": 2107}, - {"type": "punctuation", "start": 2108, "end": 2109}, - {"type": "property", "start": 2112, "end": 2119}, - {"type": "punctuation", "start": 2119, "end": 2120}, - {"type": "string", "start": 2121, "end": 2128}, - {"type": "punctuation", "start": 2128, "end": 2129}, - {"type": "punctuation", "start": 2131, "end": 2132}, - {"type": "tag", "start": 2133, "end": 2141}, - {"type": "tag", "start": 2133, "end": 2140}, - {"type": "punctuation", "start": 2133, "end": 2135}, - {"type": "punctuation", "start": 2140, "end": 2141} - ], - "html": "<script lang=\"ts\" module>\n\texport const HELLO = 'world';\n</script>\n\n<script lang=\"ts\">\n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record<string, any>;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n</script>\n\n<h1>hello {HELLO}!</h1>\n\n{#each thing_keys as key (key)}\n\t{@const v = thing[key]}\n\t{v}\n{/each}\n\n{#if c}\n\t<Thing string_prop=\"a\" number_prop={1} />\n{:else}\n\t<Thing string_prop=\"b\" number_prop={2} onthing={() => (c = !c)}>\n\t\t{@render children()}\n\t</Thing>\n{/if}\n\n{@html '<strong>raw html</strong>'}\n\n<input bind:value type=\"text\" />\n\n<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}>\n\tinteractive element\n</div>\n\n{@render my_snippet()}\n\n{#snippet my_snippet()}\n\t<button {onclick}>click handler</button>\n{/snippet}\n\n<div class=\"test special\" id=\"unique_id\">\n\t<p>hello world!</p>\n</div>\n\n<p class=\"some_class hypen-class\">\n\tsome <span class=\"a b c\">text</span>\n</p>\n\n<button type=\"button\" disabled> click me </button>\n\n<!-- comment <div>a<br /> b</div> -->\n{a}\n{b}\n{bound}\n\n<br />\n\n<hr />\n\n<img src=\"image.jpg\" alt=\"access\" />\n\n<ul>\n\t<li>list item 1</li>\n\t<li>list item 2</li>\n</ul>\n\n<!-- embedded tags for boundary testing -->\n<div>\n\t<script>\n\t\tconst inline_js = 'no lang attr';\n\t</script>\n\t<style>\n\t\t.inline {\n\t\t\tcolor: blue;\n\t\t}\n\t</style>\n</div>\n\n<style>\n\t.some_class {\n\t\tcolor: red;\n\t}\n\n\t.hypen-class {\n\t\tfont-size: 16px;\n\t}\n\n\tp {\n\t\tbox-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\t}\n\n\t/* comment */\n\n\t/*\n\tmulti\n\tline\n\n\t<comment>\n\n\t*/\n\n\t#unique_id {\n\t\tbackground-color: blue;\n\t}\n\n\tdiv > p {\n\t\tmargin: 10px;\n\t}\n\n\t@media (max-width: 600px) {\n\t\t:global(body) {\n\t\t\tbackground-color: light-dark(lightblue, darkblue);\n\t\t}\n\t}\n\n\t.special::before {\n\t\tcontent: '< & >';\n\t}\n</style>\n" -} diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index be10637b..c8f34c15 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -1,3 +1,39 @@ +=== STATS === +Sample length: 2142 characters +Total tokens: 562 + +Token types (30 unique): + punctuation: 278 + tag: 86 + operator: 33 + lang_ts: 26 + attr_name: 20 + keyword: 16 + function: 15 + attr_value: 12 + property: 9 + special_keyword: 8 + string: 8 + selector: 8 + builtin: 6 + comment: 5 + number: 4 + script: 3 + decorator: 3 + at: 3 + namespace: 3 + constant: 2 + boolean: 2 + each: 2 + style: 2 + lang_css: 2 + type_annotation: 1 + :: 1 + type: 1 + function_variable: 1 + atrule: 1 + rule: 1 + === TOKENS === 0-25 tag 635-643 tag const c = true; -export type Some_Type = 1 | 'b' | true; +export type Some_Type = 1 | 'b' | true; declare const some_decorator: any; -abstract class Base { +abstract class Base { abstract abstract_method(): void; } @some_decorator -class D extends Base { +class D extends Base { readonly d1: string = 'd'; d2: number; d3 = $state(null); @@ -69,7 +69,7 @@ }; #private_method(a2: number, c2: any) { - throw new Error(`${this.d1} + throw new Error(`${this.d1} multiline etc ${a2 + c2} `); @@ -80,16 +80,16 @@ yield* [2, 3]; } - async *async_generator() { - yield await Promise.resolve(4); + async *async_generator() { + yield await Promise.resolve(4); } - protected async protected_method(): Promise<void> { + protected async protected_method(): Promise<void> { try { - await new Promise((resolve) => setTimeout(resolve, 100)); - if (Math.random() > 0.5) { - console.log(new Date()); // eslint-disable-line no-console - } else if (Math.random() > 0.2) { + await new Promise((resolve) => setTimeout(resolve, 100)); + if (Math.random() > 0.5) { + console.log(new Date()); // eslint-disable-line no-console + } else if (Math.random() > 0.2) { console.log('else if branch'); } else { console.log('else branch'); @@ -114,14 +114,14 @@ * JSDoc comment */ -import {sample_langs, type Sample_Lang} from '../code_sample.js'; +import {sample_langs, type Sample_Lang} from '../code_sample.js'; import * as A from '../code_sample.js'; export {a, A, b, c, D}; -sample_langs as unknown as Sample_Lang satisfies Sample_Lang; +sample_langs as unknown as Sample_Lang satisfies Sample_Lang; -export interface Some_E<T = null> { +export interface Some_E<T = null> { name: string; age: number; t?: T; @@ -129,7 +129,7 @@ const e: {name: string; age: number} = {name: 'A. H.', age: 100}; const v = [['', e]] as const; -export const some_e: Map<string, Some_E> = new Map(v); +export const some_e: Map<string, Some_E> = new Map(v); export function add(x: number, y: number): number { return x + y; diff --git a/src/fixtures/generated/ts/ts_complex.txt b/src/fixtures/generated/ts/ts_complex.txt index 03edb36a..e0d4c1a5 100644 --- a/src/fixtures/generated/ts/ts_complex.txt +++ b/src/fixtures/generated/ts/ts_complex.txt @@ -1,19 +1,19 @@ === STATS === Sample length: 2821 characters -Total tokens: 611 +Total tokens: 616 Token types (27 unique): punctuation: 233 operator: 81 - keyword: 54 + keyword: 55 special_keyword: 48 - builtin: 34 + builtin: 31 function: 26 string: 25 + capitalized_identifier: 17 number: 14 class_name: 11 comment: 11 - type_name: 10 interpolation_punctuation: 8 constant: 7 template_punctuation: 6 @@ -51,7 +51,7 @@ Token types (27 unique): 55-61 special_keyword export 62-66 keyword type 67-76 class_name Some_Type - 67-76 type_name Some_Type + 67-76 capitalized_identifier Some_Type 77-78 operator = 79-80 number 1 81-82 operator | @@ -67,7 +67,7 @@ Token types (27 unique): 132-140 keyword abstract 141-146 keyword class 147-151 class_name Base - 147-151 type_name Base + 147-151 capitalized_identifier Base 152-153 punctuation { 155-163 keyword abstract 164-179 function abstract_method @@ -85,7 +85,7 @@ Token types (27 unique): 214-215 constant D 216-223 keyword extends 224-228 class_name Base - 224-228 type_name Base + 224-228 capitalized_identifier Base 229-230 punctuation { 232-240 keyword readonly 243-252 type_annotation : string @@ -303,7 +303,7 @@ Token types (27 unique): 1123-1128 special_keyword throw 1129-1132 keyword new 1133-1138 class_name Error -1133-1138 type_name Error +1133-1138 capitalized_identifier Error 1138-1139 punctuation ( 1139-1185 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` 1139-1140 template_punctuation ` @@ -339,6 +339,7 @@ Token types (27 unique): 1233-1234 punctuation ] 1234-1235 punctuation ; 1237-1238 punctuation } +1241-1246 keyword async 1247-1248 operator * 1248-1263 function async_generator 1263-1264 punctuation ( @@ -346,7 +347,7 @@ Token types (27 unique): 1266-1267 punctuation { 1270-1275 special_keyword yield 1276-1281 special_keyword await -1282-1289 builtin Promise +1282-1289 capitalized_identifier Promise 1289-1290 punctuation . 1290-1297 function resolve 1297-1298 punctuation ( @@ -360,7 +361,7 @@ Token types (27 unique): 1339-1340 punctuation ( 1340-1341 punctuation ) 1341-1342 operator : -1343-1350 builtin Promise +1343-1350 capitalized_identifier Promise 1350-1351 operator < 1351-1355 keyword void 1355-1356 operator > @@ -370,7 +371,7 @@ Token types (27 unique): 1370-1375 special_keyword await 1376-1379 keyword new 1380-1387 class_name Promise -1380-1387 builtin Promise +1380-1387 capitalized_identifier Promise 1387-1388 punctuation ( 1388-1389 punctuation ( 1396-1397 punctuation ) @@ -384,6 +385,7 @@ Token types (27 unique): 1426-1427 punctuation ; 1431-1433 special_keyword if 1434-1435 punctuation ( +1435-1439 capitalized_identifier Math 1439-1440 punctuation . 1440-1446 function random 1446-1447 punctuation ( @@ -398,7 +400,7 @@ Token types (27 unique): 1473-1474 punctuation ( 1474-1477 keyword new 1478-1482 class_name Date -1478-1482 type_name Date +1478-1482 capitalized_identifier Date 1482-1483 punctuation ( 1483-1484 punctuation ) 1484-1485 punctuation ) @@ -408,6 +410,7 @@ Token types (27 unique): 1526-1530 special_keyword else 1531-1533 special_keyword if 1534-1535 punctuation ( +1535-1539 capitalized_identifier Math 1539-1540 punctuation . 1540-1546 function random 1546-1547 punctuation ( @@ -468,7 +471,7 @@ Token types (27 unique): 1856-1857 punctuation , 1858-1862 keyword type 1863-1874 class_name Sample_Lang -1863-1874 type_name Sample_Lang +1863-1874 capitalized_identifier Sample_Lang 1874-1875 punctuation } 1876-1880 special_keyword from 1881-1900 string '../code_sample.js' @@ -493,12 +496,14 @@ Token types (27 unique): 1981-1983 special_keyword as 1984-1991 builtin unknown 1992-1994 special_keyword as +1995-2006 capitalized_identifier Sample_Lang 2007-2016 keyword satisfies +2017-2028 capitalized_identifier Sample_Lang 2028-2029 punctuation ; 2031-2037 special_keyword export 2038-2047 keyword interface 2048-2064 class_name Some_E -2048-2054 type_name Some_E +2048-2054 capitalized_identifier Some_E 2054-2055 operator < 2055-2056 constant T 2057-2058 operator = @@ -550,16 +555,16 @@ Token types (27 unique): 2222-2244 type_annotation : Map 2222-2223 : : 2223-2244 type Map -2224-2227 type_name Map +2224-2227 capitalized_identifier Map 2227-2228 operator < 2228-2234 builtin string 2234-2235 punctuation , -2236-2242 type_name Some_E +2236-2242 capitalized_identifier Some_E 2242-2243 operator > 2244-2245 operator = 2246-2249 keyword new 2250-2253 class_name Map -2250-2253 type_name Map +2250-2253 capitalized_identifier Map 2253-2254 punctuation ( 2255-2256 punctuation ) 2256-2257 punctuation ; diff --git a/src/lib/grammar_js.ts b/src/lib/grammar_js.ts index 71371047..827681c4 100644 --- a/src/lib/grammar_js.ts +++ b/src/lib/grammar_js.ts @@ -24,7 +24,7 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { keyword: [ { pattern: - /(^|[^.]|\.\.\.\s*)\b(?:assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|class|const|debugger|delete|enum|extends|function|(?:get|set)(?=\s*(?:[#[$\w\xA0-\uFFFF]|$))|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with)\b/, + /(^|[^.]|\.\.\.\s*)\b(?:assert(?=\s*\{)|async(?=\s*(?:function\b|\*|\(|[$\w\xA0-\uFFFF]|$))|class|const|debugger|delete|enum|extends|function|(?:get|set)(?=\s*(?:[#[$\w\xA0-\uFFFF]|$))|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with)\b/, lookbehind: true, }, ], @@ -137,6 +137,11 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { }, ], constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/, + // Heuristic: treat capitalized identifiers as class names when not already matched + capitalized_identifier: { + pattern: /\b[A-Z][\w]*\b/, + alias: 'class_name', + }, }); syntax_styler.grammar_insert_before('js', 'string', { diff --git a/src/lib/grammar_ts.ts b/src/lib/grammar_ts.ts index 017b2d29..5d2dd53b 100644 --- a/src/lib/grammar_ts.ts +++ b/src/lib/grammar_ts.ts @@ -54,6 +54,11 @@ export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { (grammar_ts.class_name as Syntax_Grammar_Token).inside = type_inside; syntax_styler.grammar_insert_before('ts', 'function', { + type_assertion: { + pattern: /(\b(?:as|satisfies)\s+)(?!\s)[_$A-Za-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/, + lookbehind: true, + alias: 'class_name', + }, import_type_keyword: { pattern: /(\b(?:import|export)\s+)type\b|(\b(?:import|export)\s*\{[^}]*,\s*)type\b/, lookbehind: true, From 68f6a91affc9eee7eeb5120b96161be2ba96f28f Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 20:44:24 -0400 Subject: [PATCH 30/49] wip --- src/lib/highlight_priorities.ts | 12 ++++++------ src/lib/theme.css | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/highlight_priorities.ts b/src/lib/highlight_priorities.ts index ae69970c..9015f071 100644 --- a/src/lib/highlight_priorities.ts +++ b/src/lib/highlight_priorities.ts @@ -26,11 +26,11 @@ export type Highlight_Token_Name = | 'regex' | 'important' | 'variable' + | 'atrule' | 'attr_name' | 'property' | 'decorator' | 'decorator_name' - | 'atrule' | 'rule' | 'bold' | 'italic' @@ -66,11 +66,11 @@ export const highlight_priorities: Record = { regex: 8, important: 8, variable: 8, - attr_name: 9, - property: 9, - decorator: 9, - decorator_name: 9, - atrule: 10, + atrule: 9, + attr_name: 10, + property: 10, + decorator: 10, + decorator_name: 10, rule: 11, bold: 12, italic: 13, diff --git a/src/lib/theme.css b/src/lib/theme.css index 781056f1..444a52cb 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -74,6 +74,11 @@ color: var(--color_e_5); } +.token.atrule, +::highlight(atrule) { + color: var(--color_f_5); +} + .token.attr_name, ::highlight(attr_name), .token.property, @@ -85,11 +90,6 @@ color: var(--color_i_5); } -.token.atrule, -::highlight(atrule) { - color: var(--color_f_5); -} - .token.rule, ::highlight(rule) { color: var(--color_g_5); From 8666d02baa442c85c9d77674dfd770f480add913 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 20:45:35 -0400 Subject: [PATCH 31/49] wip --- src/lib/theme.css | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/theme.css b/src/lib/theme.css index 444a52cb..b6c9aa01 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -79,6 +79,11 @@ color: var(--color_f_5); } +.token.rule, +::highlight(rule) { + color: var(--color_g_5); +} + .token.attr_name, ::highlight(attr_name), .token.property, @@ -90,11 +95,6 @@ color: var(--color_i_5); } -.token.rule, -::highlight(rule) { - color: var(--color_g_5); -} - .token.important, ::highlight(important), .token.bold, From 9d1781fe6daadc1694d9078889c05563b743d363 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 21:08:15 -0400 Subject: [PATCH 32/49] wip --- .../generated/svelte/svelte_complex.html | 20 +- .../generated/svelte/svelte_complex.txt | 754 +++++++++--------- src/lib/grammar_svelte.ts | 24 +- src/lib/highlight_priorities.ts | 12 +- src/lib/samples/all.ts | 2 + src/lib/samples/sample_complex.svelte | 2 + 6 files changed, 417 insertions(+), 397 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index e24ceafd..54001237 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -37,18 +37,20 @@ <h1>hello {HELLO}!</h1> -{#each thing_keys as key (key)} - {@const v = thing[key]} +{#each thing_keys as key (key)} + {@const v = thing[key]} {v} -{/each} +{/each} -{#if c} +{#if c} <Thing string_prop="a" number_prop={1} /> +{:else if a > 0} + bigger {:else} <Thing string_prop="b" number_prop={2} onthing={() => (c = !c)}> - {@render children()} + {@render children()} </Thing> -{/if} +{/if} {@html '<strong>raw html</strong>'} @@ -58,11 +60,11 @@ interactive element </div> -{@render my_snippet()} +{@render my_snippet()} -{#snippet my_snippet()} +{#snippet my_snippet()} <button {onclick}>click handler</button> -{/snippet} +{/snippet} <div class="test special" id="unique_id"> <p>hello world!</p> diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index ab8f4274..2c846d33 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -1,27 +1,27 @@ === STATS === -Sample length: 2142 characters -Total tokens: 569 +Sample length: 2167 characters +Total tokens: 565 -Token types (31 unique): - punctuation: 278 +Token types (33 unique): + punctuation: 274 tag: 86 - operator: 33 - lang_ts: 26 + operator: 31 + lang_ts: 22 attr_name: 20 keyword: 16 - function: 15 + special_keyword: 13 attr_value: 12 + function: 11 property: 9 - special_keyword: 8 string: 8 selector: 8 capitalized_identifier: 7 builtin: 6 comment: 5 - number: 4 + number: 5 + block: 5 script: 3 - decorator: 3 - at: 3 + at_directive: 3 namespace: 3 constant: 2 boolean: 2 @@ -32,6 +32,8 @@ Token types (31 unique): :: 1 type: 1 function_variable: 1 + decorator: 1 + at: 1 atrule: 1 rule: 1 @@ -204,7 +206,7 @@ Token types (31 unique): 668-669 punctuation > 671-702 each {#each thing_keys as key (key)} 671-672 punctuation { - 672-677 keyword #each + 672-677 special_keyword #each 678-689 lang_ts thing_keys 689-691 keyword as 692-696 lang_ts key @@ -212,23 +214,21 @@ Token types (31 unique): 696-697 punctuation ( 700-701 punctuation ) 701-702 punctuation } - 704-727 lang_ts {@const v = thing[key]} + 704-727 at_directive {@const v = thing[key]} 704-705 punctuation { - 706-711 keyword const - 714-715 operator = - 721-722 punctuation [ - 725-726 punctuation ] + 705-711 keyword @const 726-727 punctuation } 729-732 lang_ts {v} 729-730 punctuation { 731-732 punctuation } 733-740 each {/each} 733-734 punctuation { - 734-739 keyword /each + 734-739 special_keyword /each 739-740 punctuation } - 742-749 lang_ts {#if c} + 742-749 block {#if c} 742-743 punctuation { - 744-746 special_keyword if + 743-746 special_keyword #if + 746-748 lang_ts c 748-749 punctuation } 751-792 tag 751-757 tag - 793-800 lang_ts {:else} + 793-809 block {:else if a > 0} 793-794 punctuation { - 794-795 operator : - 795-799 special_keyword else - 799-800 punctuation } - 802-866 tag (c = !c)}> - 802-808 tag (c = !c)} - 849-850 punctuation { - 850-851 punctuation ( - 851-852 punctuation ) - 853-855 operator => - 856-857 punctuation ( - 859-860 operator = - 861-862 operator ! - 863-864 punctuation ) + 794-802 special_keyword :else if + 802-808 lang_ts a > 0 + 805-806 operator > + 807-808 number 0 + 808-809 punctuation } + 818-825 lang_ts {:else} + 818-819 punctuation { + 819-820 operator : + 820-824 special_keyword else + 824-825 punctuation } + 827-891 tag (c = !c)}> + 827-833 tag - 869-889 lang_ts {@render children()} - 869-870 punctuation { - 870-877 decorator @render - 870-871 at @ - 871-877 function render - 878-886 function children - 886-887 punctuation ( - 887-888 punctuation ) - 888-889 punctuation } - 891-899 tag - 891-898 tag - 900-905 lang_ts {/if} - 900-901 punctuation { - 901-902 operator / - 902-904 special_keyword if - 904-905 punctuation } - 915-923 tag - 915-922 tag - 931-940 tag - 931-939 tag - 944-976 tag - 944-950 tag - 978-1058 tag
    - 978-982 tag
    -1080-1086 tag
    -1080-1085 tag
    -1088-1110 lang_ts {@render my_snippet()} -1088-1089 punctuation { -1089-1096 decorator @render -1089-1090 at @ -1090-1096 function render -1097-1107 function my_snippet -1107-1108 punctuation ( -1108-1109 punctuation ) -1109-1110 punctuation } -1112-1135 lang_ts {#snippet my_snippet()} -1112-1113 punctuation { -1122-1132 function my_snippet -1132-1133 punctuation ( -1133-1134 punctuation ) + 866-874 attr_name onthing= + 874-890 lang_ts {() => (c = !c)} + 874-875 punctuation { + 875-876 punctuation ( + 876-877 punctuation ) + 878-880 operator => + 881-882 punctuation ( + 884-885 operator = + 886-887 operator ! + 888-889 punctuation ) + 889-890 punctuation } + 890-891 punctuation > + 894-914 at_directive {@render children()} + 894-895 punctuation { + 895-902 keyword @render + 913-914 punctuation } + 916-924 tag
    + 916-923 tag
    + 925-930 block {/if} + 925-926 punctuation { + 926-929 special_keyword /if + 929-930 punctuation } + 940-948 tag + 940-947 tag + 956-965 tag + 956-964 tag + 969-1001 tag + 969-975 tag +1003-1083 tag
    +1003-1007 tag
    +1105-1111 tag
    +1105-1110 tag
    +1113-1135 at_directive {@render my_snippet()} +1113-1114 punctuation { +1114-1121 keyword @render 1134-1135 punctuation } -1137-1155 tag -1168-1176 tag -1178-1188 lang_ts {/snippet} -1178-1179 punctuation { -1179-1180 operator / -1187-1188 punctuation } -1190-1231 tag
    -1190-1194 tag
    -1233-1236 tag

    -1233-1235 tag

    -1248-1252 tag

    -1248-1251 tag

    -1253-1259 tag
    -1253-1258 tag
    -1261-1295 tag

    -1261-1263 tag

    -1302-1322 tag -1302-1307 tag -1326-1333 tag -1326-1332 tag -1334-1338 tag

    -1334-1337 tag

    -1340-1371 tag -1381-1389 tag -1392-1429 comment -1430-1433 lang_ts {a} -1430-1431 punctuation { -1432-1433 punctuation } -1434-1437 lang_ts {b} -1434-1435 punctuation { -1436-1437 punctuation } -1438-1445 lang_ts {bound} -1438-1439 punctuation { -1444-1445 punctuation } -1447-1453 tag
    -1447-1450 tag
    -1455-1461 tag
    -1455-1458 tag
    -1463-1499 tag access -1463-1467 tag -1501-1505 tag
      -1501-1504 tag
        -1507-1511 tag
      • -1507-1510 tag
      • -1522-1527 tag
      • -1522-1526 tag -1529-1533 tag
      • -1529-1532 tag
      • -1544-1549 tag
      • -1544-1548 tag -1550-1555 tag
      -1550-1554 tag
    -1557-1600 comment -1601-1606 tag
    -1601-1605 tag
    -1608-1616 tag -1654-1662 tag -1665-1672 tag -1706-1713 tag -1715-1721 tag
    -1715-1720 tag
    -1723-1730 tag -2133-2140 tag +1137-1160 block {#snippet my_snippet()} +1137-1138 punctuation { +1138-1146 special_keyword #snippet +1146-1159 lang_ts my_snippet() +1147-1157 function my_snippet +1157-1158 punctuation ( +1158-1159 punctuation ) +1159-1160 punctuation } +1162-1180 tag +1193-1201 tag +1203-1213 block {/snippet} +1203-1204 punctuation { +1204-1212 special_keyword /snippet +1212-1213 punctuation } +1215-1256 tag
    +1215-1219 tag
    +1258-1261 tag

    +1258-1260 tag

    +1273-1277 tag

    +1273-1276 tag

    +1278-1284 tag
    +1278-1283 tag
    +1286-1320 tag

    +1286-1288 tag

    +1327-1347 tag +1327-1332 tag +1351-1358 tag +1351-1357 tag +1359-1363 tag

    +1359-1362 tag

    +1365-1396 tag +1406-1414 tag +1417-1454 comment +1455-1458 lang_ts {a} +1455-1456 punctuation { +1457-1458 punctuation } +1459-1462 lang_ts {b} +1459-1460 punctuation { +1461-1462 punctuation } +1463-1470 lang_ts {bound} +1463-1464 punctuation { +1469-1470 punctuation } +1472-1478 tag
    +1472-1475 tag
    +1480-1486 tag
    +1480-1483 tag
    +1488-1524 tag access +1488-1492 tag +1526-1530 tag
      +1526-1529 tag
        +1532-1536 tag
      • +1532-1535 tag
      • +1547-1552 tag
      • +1547-1551 tag +1554-1558 tag
      • +1554-1557 tag
      • +1569-1574 tag
      • +1569-1573 tag +1575-1580 tag
      +1575-1579 tag
    +1582-1625 comment +1626-1631 tag
    +1626-1630 tag
    +1633-1641 tag +1679-1687 tag +1690-1697 tag +1731-1738 tag +1740-1746 tag
    +1740-1745 tag
    +1748-1755 tag +2158-2165 tag diff --git a/src/lib/grammar_svelte.ts b/src/lib/grammar_svelte.ts index 4cecce67..4bc970e2 100644 --- a/src/lib/grammar_svelte.ts +++ b/src/lib/grammar_svelte.ts @@ -1,7 +1,7 @@ import type {Add_Syntax_Grammar, Syntax_Grammar_Token, Syntax_Styler} from '$lib/syntax_styler.js'; import {grammar_markup_add_inlined} from '$lib/grammar_markup.js'; -const blocks = '(if|else if|await|then|catch|each|html|debug)'; +const blocks = '(if|else if|await|then|catch|each|html|debug|snippet)'; /** * Based on `prism-svelte` (https://github.com/pngwn/prism-svelte) @@ -14,7 +14,21 @@ const blocks = '(if|else if|await|then|catch|each|html|debug)'; export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { const grammar_ts = syntax_styler.get_lang('ts'); + // TODO double check this is correct + grammar_ts.svelte_at_directive = { + pattern: /@(?:render|html|const|debug|attach)\b/, + alias: 'keyword', + }; + const grammar_svelte = syntax_styler.add_extended_lang('markup', 'svelte', { + // TODO double check this is correct + at_directive: { + pattern: /{@(?:render|html|const|debug|attach)\b[^}]*}/, + inside: { + keyword: /@(?:render|html|const|debug|attach)/, + punctuation: /{|}/, + }, + }, each: { pattern: /{[#/]each(?:(?:\{(?:(?:\{(?:[^{}])*\})|(?:[^{}]))*\})|(?:[^{}]))*}/, inside: { @@ -35,17 +49,19 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { inside: grammar_ts, }, ], - keyword: /[#/]each|as/, + special_keyword: /[#/]each/, + keyword: /as/, punctuation: /{|}/, }, }, block: { pattern: new RegExp( - '{[#:/@]/s' + blocks + '(?:(?:\\{(?:(?:\\{(?:[^{}])*\\})|(?:[^{}]))*\\})|(?:[^{}]))*}', + '{[#:/@]\\s*' + blocks + '(?:(?:\\{(?:(?:\\{(?:[^{}])*\\})|(?:[^{}]))*\\})|(?:[^{}]))*}', ), inside: { punctuation: /^{|}$/, - keyword: [new RegExp('[#:/@]' + blocks + '( )*'), /as/, /then/], + special_keyword: new RegExp('[#:/@]' + blocks), + keyword: [/as/, /then/], lang_ts: { pattern: /[\s\S]*/, inside: grammar_ts, diff --git a/src/lib/highlight_priorities.ts b/src/lib/highlight_priorities.ts index 9015f071..4ff99978 100644 --- a/src/lib/highlight_priorities.ts +++ b/src/lib/highlight_priorities.ts @@ -27,11 +27,11 @@ export type Highlight_Token_Name = | 'important' | 'variable' | 'atrule' + | 'rule' | 'attr_name' | 'property' | 'decorator' | 'decorator_name' - | 'rule' | 'bold' | 'italic' | 'attr_equals' @@ -67,11 +67,11 @@ export const highlight_priorities: Record = { important: 8, variable: 8, atrule: 9, - attr_name: 10, - property: 10, - decorator: 10, - decorator_name: 10, - rule: 11, + rule: 10, + attr_name: 11, + property: 11, + decorator: 11, + decorator_name: 11, bold: 12, italic: 13, attr_equals: 14, diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 9b6a8451..ec85e34a 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -330,6 +330,8 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; {#if c} +{:else if a > 0} + bigger {:else} (c = !c)}> {@render children()} diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index 0ceee38f..3fd99f0e 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -44,6 +44,8 @@ {#if c} +{:else if a > 0} + bigger {:else} (c = !c)}> {@render children()} From e48eebe2a3bf90f27bff247a505483e4314c785a Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Wed, 24 Sep 2025 21:11:46 -0400 Subject: [PATCH 33/49] wip --- .../generated/svelte/svelte_complex.html | 8 +- .../generated/svelte/svelte_complex.txt | 862 +++++++++--------- src/lib/grammar_svelte.ts | 13 +- src/lib/samples/all.ts | 2 +- src/lib/samples/sample_complex.svelte | 2 +- 5 files changed, 450 insertions(+), 437 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index 54001237..417c84fb 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -31,14 +31,14 @@ element_ref; }; - let value = $state(''); + let value = $state(thing['']); let element_ref: HTMLElement;
    </script> <h1>hello {HELLO}!</h1> {#each thing_keys as key (key)} - {@const v = thing[key]} + {@const v = thing[key]} {v} {/each} @@ -48,7 +48,7 @@ bigger {:else} <Thing string_prop="b" number_prop={2} onthing={() => (c = !c)}> - {@render children()} + {@render children()} </Thing> {/if} @@ -60,7 +60,7 @@ interactive element </div> -{@render my_snippet()} +{@render my_snippet()} {#snippet my_snippet()} <button {onclick}>click handler</button> diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 2c846d33..5e9d8bd0 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -1,17 +1,17 @@ === STATS === -Sample length: 2167 characters -Total tokens: 565 +Sample length: 2174 characters +Total tokens: 579 Token types (33 unique): - punctuation: 274 + punctuation: 282 tag: 86 - operator: 31 - lang_ts: 22 + operator: 32 + lang_ts: 25 attr_name: 20 keyword: 16 special_keyword: 13 + function: 13 attr_value: 12 - function: 11 property: 9 string: 8 selector: 8 @@ -69,8 +69,8 @@ Token types (33 unique): 81-82 punctuation " 84-85 punctuation " 85-86 punctuation > - 86-635 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n - 86-635 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state('');\n\tlet element_ref: HTMLElement;\n + 86-642 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n + 86-642 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n 88-107 comment // @ts-expect-error 109-115 special_keyword import 116-121 capitalized_identifier Thing @@ -181,425 +181,439 @@ Token types (33 unique): 590-591 operator = 592-598 function $state 598-599 punctuation ( - 599-601 string '' - 601-602 punctuation ) - 602-603 punctuation ; - 605-608 keyword let - 620-621 operator : - 622-633 capitalized_identifier HTMLElement - 633-634 punctuation ; - 635-644 tag - 635-643 tag - 646-650 tag

    - 646-649 tag

    - 656-663 lang_ts {HELLO} - 656-657 punctuation { - 657-662 constant HELLO - 662-663 punctuation } - 664-669 tag

    - 664-668 tag - 671-702 each {#each thing_keys as key (key)} - 671-672 punctuation { - 672-677 special_keyword #each - 678-689 lang_ts thing_keys - 689-691 keyword as - 692-696 lang_ts key - 696-701 lang_ts (key) - 696-697 punctuation ( - 700-701 punctuation ) - 701-702 punctuation } - 704-727 at_directive {@const v = thing[key]} - 704-705 punctuation { - 705-711 keyword @const - 726-727 punctuation } - 729-732 lang_ts {v} - 729-730 punctuation { - 731-732 punctuation } - 733-740 each {/each} - 733-734 punctuation { - 734-739 special_keyword /each - 739-740 punctuation } - 742-749 block {#if c} - 742-743 punctuation { - 743-746 special_keyword #if - 746-748 lang_ts c - 748-749 punctuation } - 751-792 tag - 751-757 tag - 793-809 block {:else if a > 0} + 604-605 punctuation [ + 605-607 string '' + 607-608 punctuation ] + 608-609 punctuation ) + 609-610 punctuation ; + 612-615 keyword let + 627-628 operator : + 629-640 capitalized_identifier HTMLElement + 640-641 punctuation ; + 642-651 tag + 642-650 tag + 653-657 tag

    + 653-656 tag

    + 663-670 lang_ts {HELLO} + 663-664 punctuation { + 664-669 constant HELLO + 669-670 punctuation } + 671-676 tag

    + 671-675 tag + 678-709 each {#each thing_keys as key (key)} + 678-679 punctuation { + 679-684 special_keyword #each + 685-696 lang_ts thing_keys + 696-698 keyword as + 699-703 lang_ts key + 703-708 lang_ts (key) + 703-704 punctuation ( + 707-708 punctuation ) + 708-709 punctuation } + 711-734 at_directive {@const v = thing[key]} + 711-712 punctuation { + 712-718 keyword @const + 719-733 lang_ts v = thing[key] + 721-722 operator = + 728-729 punctuation [ + 732-733 punctuation ] + 733-734 punctuation } + 736-739 lang_ts {v} + 736-737 punctuation { + 738-739 punctuation } + 740-747 each {/each} + 740-741 punctuation { + 741-746 special_keyword /each + 746-747 punctuation } + 749-756 block {#if c} + 749-750 punctuation { + 750-753 special_keyword #if + 753-755 lang_ts c + 755-756 punctuation } + 758-799 tag + 758-764 tag 0 - 805-806 operator > - 807-808 number 0 - 808-809 punctuation } - 818-825 lang_ts {:else} - 818-819 punctuation { - 819-820 operator : - 820-824 special_keyword else - 824-825 punctuation } - 827-891 tag (c = !c)}> - 827-833 tag (c = !c)} - 874-875 punctuation { - 875-876 punctuation ( - 876-877 punctuation ) - 878-880 operator => - 881-882 punctuation ( - 884-885 operator = - 886-887 operator ! - 888-889 punctuation ) - 889-890 punctuation } - 890-891 punctuation > - 894-914 at_directive {@render children()} - 894-895 punctuation { - 895-902 keyword @render - 913-914 punctuation } - 916-924 tag - 916-923 tag - 925-930 block {/if} - 925-926 punctuation { - 926-929 special_keyword /if - 929-930 punctuation } - 940-948 tag - 940-947 tag - 956-965 tag - 956-964 tag - 969-1001 tag - 969-975 tag -1003-1083 tag
    -1003-1007 tag
    -1105-1111 tag
    -1105-1110 tag
    -1113-1135 at_directive {@render my_snippet()} -1113-1114 punctuation { -1114-1121 keyword @render -1134-1135 punctuation } -1137-1160 block {#snippet my_snippet()} -1137-1138 punctuation { -1138-1146 special_keyword #snippet -1146-1159 lang_ts my_snippet() -1147-1157 function my_snippet -1157-1158 punctuation ( -1158-1159 punctuation ) -1159-1160 punctuation } -1162-1180 tag -1193-1201 tag -1203-1213 block {/snippet} -1203-1204 punctuation { -1204-1212 special_keyword /snippet -1212-1213 punctuation } -1215-1256 tag
    -1215-1219 tag
    -1258-1261 tag

    -1258-1260 tag

    -1273-1277 tag

    -1273-1276 tag

    -1278-1284 tag
    -1278-1283 tag
    + 800-816 block {:else if a > 0} + 800-801 punctuation { + 801-809 special_keyword :else if + 809-815 lang_ts a > 0 + 812-813 operator > + 814-815 number 0 + 815-816 punctuation } + 825-832 lang_ts {:else} + 825-826 punctuation { + 826-827 operator : + 827-831 special_keyword else + 831-832 punctuation } + 834-898 tag (c = !c)}> + 834-840 tag (c = !c)} + 881-882 punctuation { + 882-883 punctuation ( + 883-884 punctuation ) + 885-887 operator => + 888-889 punctuation ( + 891-892 operator = + 893-894 operator ! + 895-896 punctuation ) + 896-897 punctuation } + 897-898 punctuation > + 901-921 at_directive {@render children()} + 901-902 punctuation { + 902-909 keyword @render + 910-920 lang_ts children() + 910-918 function children + 918-919 punctuation ( + 919-920 punctuation ) + 920-921 punctuation } + 923-931 tag + 923-930 tag + 932-937 block {/if} + 932-933 punctuation { + 933-936 special_keyword /if + 936-937 punctuation } + 947-955 tag + 947-954 tag + 963-972 tag + 963-971 tag + 976-1008 tag + 976-982 tag +1010-1090 tag
    +1010-1014 tag
    +1112-1118 tag
    +1112-1117 tag
    +1120-1142 at_directive {@render my_snippet()} +1120-1121 punctuation { +1121-1128 keyword @render +1129-1141 lang_ts my_snippet() +1129-1139 function my_snippet +1139-1140 punctuation ( +1140-1141 punctuation ) +1141-1142 punctuation } +1144-1167 block {#snippet my_snippet()} +1144-1145 punctuation { +1145-1153 special_keyword #snippet +1153-1166 lang_ts my_snippet() +1154-1164 function my_snippet +1164-1165 punctuation ( +1165-1166 punctuation ) +1166-1167 punctuation } +1169-1187 tag +1200-1208 tag +1210-1220 block {/snippet} +1210-1211 punctuation { +1211-1219 special_keyword /snippet +1219-1220 punctuation } +1222-1263 tag
    +1222-1226 tag
    +1265-1268 tag

    +1265-1267 tag

    +1280-1284 tag

    +1280-1283 tag

    -1286-1320 tag

    -1286-1288 tag

    -1327-1347 tag -1327-1332 tag -1351-1358 tag -1351-1357 tag -1359-1363 tag

    -1359-1362 tag

    -1365-1396 tag
    +1293-1327 tag

    +1293-1295 tag

    +1334-1354 tag +1334-1339 tag +1358-1365 tag +1358-1364 tag +1366-1370 tag

    +1366-1369 tag

    +1372-1403 tag -1406-1414 tag -1417-1454 comment -1455-1458 lang_ts {a} -1455-1456 punctuation { -1457-1458 punctuation } -1459-1462 lang_ts {b} -1459-1460 punctuation { -1461-1462 punctuation } -1463-1470 lang_ts {bound} -1463-1464 punctuation { -1469-1470 punctuation } -1472-1478 tag
    -1472-1475 tag
    -1480-1486 tag
    -1480-1483 tag
    -1488-1524 tag access -1488-1492 tag +1413-1422 tag +1413-1421 tag +1424-1461 comment +1462-1465 lang_ts {a} +1462-1463 punctuation { +1464-1465 punctuation } +1466-1469 lang_ts {b} +1466-1467 punctuation { +1468-1469 punctuation } +1470-1477 lang_ts {bound} +1470-1471 punctuation { +1476-1477 punctuation } +1479-1485 tag
    +1479-1482 tag
    +1487-1493 tag
    +1487-1490 tag
    +1495-1531 tag access +1495-1499 tag -1526-1530 tag
      -1526-1529 tag
        -1532-1536 tag
      • -1532-1535 tag
      • -1547-1552 tag
      • -1547-1551 tag -1554-1558 tag
      • -1554-1557 tag
      • -1569-1574 tag
      • -1569-1573 tag -1575-1580 tag
      -1575-1579 tag
    -1582-1625 comment -1626-1631 tag
    -1626-1630 tag
    -1633-1641 tag -1679-1687 tag -1690-1697 tag -1731-1738 tag -1740-1746 tag
    -1740-1745 tag
    +1640-1648 tag +1686-1694 tag +1697-1704 tag +1738-1745 tag -1748-1755 tag -2158-2165 tag +1747-1753 tag
    +1747-1752 tag
    +1755-1762 tag +2165-2172 tag diff --git a/src/lib/grammar_svelte.ts b/src/lib/grammar_svelte.ts index 4bc970e2..e7d151bd 100644 --- a/src/lib/grammar_svelte.ts +++ b/src/lib/grammar_svelte.ts @@ -14,17 +14,16 @@ const blocks = '(if|else if|await|then|catch|each|html|debug|snippet)'; export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { const grammar_ts = syntax_styler.get_lang('ts'); - // TODO double check this is correct - grammar_ts.svelte_at_directive = { - pattern: /@(?:render|html|const|debug|attach)\b/, - alias: 'keyword', - }; const grammar_svelte = syntax_styler.add_extended_lang('markup', 'svelte', { - // TODO double check this is correct at_directive: { - pattern: /{@(?:render|html|const|debug|attach)\b[^}]*}/, + pattern: /{@(?:render|html|const|debug|attach)\b(?:(?:\{(?:(?:\{(?:[^{}])*\})|(?:[^{}]))*\})|(?:[^{}]))*}/, inside: { + lang_ts: { + pattern: /(@(?:render|html|const|debug|attach)\s+)[\s\S]*(?=\s*\})/, + lookbehind: true, + inside: grammar_ts, + }, keyword: /@(?:render|html|const|debug|attach)/, punctuation: /{|}/, }, diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index ec85e34a..3ff31736 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -317,7 +317,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; element_ref; }; - let value = $state(''); + let value = $state(thing['']); let element_ref: HTMLElement; diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index 3fd99f0e..e1135718 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -31,7 +31,7 @@ element_ref; }; - let value = $state(''); + let value = $state(thing['']); let element_ref: HTMLElement; From 97a43f91be7cdf5d1ddf1671d5adc725b32e1839 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Thu, 25 Sep 2025 06:45:17 -0400 Subject: [PATCH 34/49] wip --- src/lib/samples/sample_complex.svelte | 30 +++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index e1135718..e7bcce1f 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -19,7 +19,7 @@ onclick?: () => void; } = $props(); - const thing_keys = $derived(Object.keys(thing)); + const thing_keys = $derived(Object.entries(thing)); const a = 1; @@ -27,18 +27,18 @@ let c: boolean = $state(true); - const attachment = (_p1: string, _p2: number) => (_: HTMLElement) => { - element_ref; + const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { + element_ref !== el; }; let value = $state(thing['']); let element_ref: HTMLElement; -

    hello {HELLO}!

    +

    hello {HELLO}!

    -{#each thing_keys as key (key)} - {@const v = thing[key]} +{#each thing_keys as [k, { t, u }] (k)} + {@const v = Math.round(t[k + u])} {v} {/each} @@ -47,18 +47,16 @@ {:else if a > 0} bigger {:else} - (c = !c)}> + (c = !c)}> {@render children()} {/if} {@html 'raw html'} - + -
    - interactive element -
    +... {@render my_snippet()} @@ -66,11 +64,7 @@ {/snippet} -
    -

    hello world!

    -
    - -

    +

    some text

    @@ -131,10 +125,6 @@ background-color: blue; } - div > p { - margin: 10px; - } - @media (max-width: 600px) { :global(body) { background-color: light-dark(lightblue, darkblue); From 01f68790cfb329a09bbb8ca3b96e25140c4f4e94 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Thu, 25 Sep 2025 12:23:57 -0400 Subject: [PATCH 35/49] wip --- src/lib/samples/sample_complex.svelte | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index e7bcce1f..eca55b13 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -27,6 +27,8 @@ let c: boolean = $state(true); + const f = (p: any) => p; + const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { element_ref !== el; }; @@ -37,14 +39,14 @@

    hello {HELLO}!

    -{#each thing_keys as [k, { t, u }] (k)} +{#each thing_keys as [k, { t, u }] (f(k))} {@const v = Math.round(t[k + u])} {v} {/each} -{#if c} +{#if f(c)} -{:else if a > 0} +{:else if f(a > 0)} bigger {:else} (c = !c)}> @@ -58,10 +60,10 @@ ... -{@render my_snippet()} +{@render my_snippet('p')} -{#snippet my_snippet()} - +{#snippet my_snippet(p: string)} + {/snippet}

    From 1ee5eb3a8159f8af6b1dadaea309eddca29bf4d3 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 06:13:47 -0400 Subject: [PATCH 36/49] wip --- .../generated/svelte/svelte_complex.html | 67 +- .../generated/svelte/svelte_complex.txt | 1054 +++++++++-------- src/lib/grammar_svelte.ts | 87 +- src/lib/samples/all.ts | 53 +- src/lib/samples/sample_complex.svelte | 17 +- 5 files changed, 664 insertions(+), 614 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index 417c84fb..cda897c1 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -19,7 +19,7 @@ onclick?: () => void; } = $props(); - const thing_keys = $derived(Object.keys(thing)); + const thing_keys = $derived(Object.entries(thing)); const a = 1; @@ -27,59 +27,54 @@ let c: boolean = $state(true); - const attachment = (_p1: string, _p2: number) => (_: HTMLElement) => { - element_ref; + const f = (p: any) => p; + + const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { + element_ref !== el; }; let value = $state(thing['']); let element_ref: HTMLElement; </script> -<h1>hello {HELLO}!</h1> +<h1 bind:this={element_ref}>hello {HELLO}!</h1> -{#each thing_keys as key (key)} - {@const v = thing[key]} - {v} -{/each} +{#each thing_keys as [k, { t, u }] (f(k))} + {@const v = Math.round(t[k + f(u)])} + {f(v)} +{/each} -{#if c} - <Thing string_prop="a" number_prop={1} /> -{:else if a > 0} +{#if f(c)} + <Thing string_prop="a {f('s')} b" number_prop={f(1)} /> +{:else if f(a > 0)} bigger -{:else} - <Thing string_prop="b" number_prop={2} onthing={() => (c = !c)}> - {@render children()} +{:else} + <Thing string_prop="b" onthing={() => (c = f(!c))}> + {@render children()} </Thing> -{/if} - -{@html '<strong>raw html</strong>'} +{/if} -<input bind:value type="text" /> +{@html '<strong>raw html</strong>'} -<div bind:this={element_ref} class:active={c} {@attach attachment('param', 42)}> - interactive element -</div> +<input bind:value type="text" class:active={c} /> -{@render my_snippet()} +<span {@attach attachment('param', f(42))}>...</span> -{#snippet my_snippet()} - <button {onclick}>click handler</button> -{/snippet} +{@render my_snippet('p')} -<div class="test special" id="unique_id"> - <p>hello world!</p> -</div> +{#snippet my_snippet(p: string)} + <button {onclick}>{p}</button> +{/snippet} -<p class="some_class hypen-class"> +<p class="some_class hypen-class" id="unique_id"> some <span class="a b c">text</span> </p> <button type="button" disabled> click me </button> -<!-- comment <div>a<br /> b</div> --> -{a} -{b} -{bound} +<!-- comment <div>a<br /> {b}</div> --> +{b.repeat(2)} +{bound} <br /> @@ -131,17 +126,13 @@ background-color: blue; } - div > p { - margin: 10px; - } - @media (max-width: 600px) { :global(body) { background-color: light-dark(lightblue, darkblue); } } - .special::before { + :global(.escapehatch)::before { content: '< & >'; } </style> diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 5e9d8bd0..81e55ec6 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -1,39 +1,38 @@ === STATS === -Sample length: 2174 characters -Total tokens: 579 +Sample length: 2168 characters +Total tokens: 624 -Token types (33 unique): - punctuation: 282 - tag: 86 - operator: 32 +Token types (32 unique): + punctuation: 295 + tag: 74 + operator: 38 lang_ts: 25 - attr_name: 20 - keyword: 16 + svelte_expression: 24 + function: 22 + attr_name: 19 + keyword: 19 special_keyword: 13 - function: 13 - attr_value: 12 - property: 9 - string: 8 - selector: 8 - capitalized_identifier: 7 - builtin: 6 + string: 11 + attr_value: 10 + capitalized_identifier: 8 + builtin: 8 + property: 8 + selector: 7 + block: 6 comment: 5 number: 5 - block: 5 + at_directive: 5 script: 3 - at_directive: 3 namespace: 3 constant: 2 boolean: 2 - each: 2 + function_variable: 2 style: 2 lang_css: 2 type_annotation: 1 :: 1 type: 1 - function_variable: 1 - decorator: 1 - at: 1 + each: 1 atrule: 1 rule: 1 @@ -69,8 +68,8 @@ Token types (33 unique): 81-82 punctuation " 84-85 punctuation " 85-86 punctuation > - 86-642 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n - 86-642 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.keys(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst attachment = (_p1: string, _p2: number) => (_: HTMLElement) => {\n\t\telement_ref;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n + 86-680 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n + 86-680 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n 88-107 comment // @ts-expect-error 109-115 special_keyword import 116-121 capitalized_identifier Thing @@ -133,487 +132,532 @@ Token types (33 unique): 399-400 punctuation ( 400-406 capitalized_identifier Object 406-407 punctuation . - 407-411 function keys - 411-412 punctuation ( - 417-418 punctuation ) - 418-419 punctuation ) - 419-420 punctuation ; - 423-428 keyword const - 431-432 operator = - 433-434 number 1 - 434-435 punctuation ; - 438-443 keyword const - 446-447 operator = - 448-451 string 'b' - 451-452 punctuation ; - 455-458 keyword let - 460-470 type_annotation : boolean - 460-461 : : - 461-470 type boolean - 462-469 builtin boolean - 470-471 operator = - 472-478 function $state - 478-479 punctuation ( - 479-483 boolean true - 483-484 punctuation ) - 484-485 punctuation ; - 488-493 keyword const - 494-504 function_variable attachment - 505-506 operator = - 507-508 punctuation ( - 511-512 operator : - 513-519 builtin string - 519-520 punctuation , - 524-525 operator : - 526-532 builtin number - 532-533 punctuation ) - 534-536 operator => + 407-414 function entries + 414-415 punctuation ( + 420-421 punctuation ) + 421-422 punctuation ) + 422-423 punctuation ; + 426-431 keyword const + 434-435 operator = + 436-437 number 1 + 437-438 punctuation ; + 441-446 keyword const + 449-450 operator = + 451-454 string 'b' + 454-455 punctuation ; + 458-461 keyword let + 463-473 type_annotation : boolean + 463-464 : : + 464-473 type boolean + 465-472 builtin boolean + 473-474 operator = + 475-481 function $state + 481-482 punctuation ( + 482-486 boolean true + 486-487 punctuation ) + 487-488 punctuation ; + 491-496 keyword const + 497-498 function_variable f + 499-500 operator = + 501-502 punctuation ( + 503-504 operator : + 505-508 builtin any + 508-509 punctuation ) + 510-512 operator => + 514-515 punctuation ; + 518-523 keyword const + 524-534 function_variable attachment + 535-536 operator = 537-538 punctuation ( - 539-540 operator : - 541-552 capitalized_identifier HTMLElement - 552-553 punctuation ) - 554-556 operator => - 557-558 punctuation { - 572-573 punctuation ; - 575-576 punctuation } - 576-577 punctuation ; - 580-583 keyword let - 590-591 operator = - 592-598 function $state - 598-599 punctuation ( - 604-605 punctuation [ - 605-607 string '' - 607-608 punctuation ] - 608-609 punctuation ) - 609-610 punctuation ; - 612-615 keyword let - 627-628 operator : - 629-640 capitalized_identifier HTMLElement - 640-641 punctuation ; - 642-651 tag - 642-650 tag - 653-657 tag

    - 653-656 tag

    - 663-670 lang_ts {HELLO} - 663-664 punctuation { - 664-669 constant HELLO - 669-670 punctuation } - 671-676 tag

    - 671-675 tag - 678-709 each {#each thing_keys as key (key)} - 678-679 punctuation { - 679-684 special_keyword #each - 685-696 lang_ts thing_keys - 696-698 keyword as - 699-703 lang_ts key - 703-708 lang_ts (key) - 703-704 punctuation ( - 707-708 punctuation ) - 708-709 punctuation } - 711-734 at_directive {@const v = thing[key]} - 711-712 punctuation { - 712-718 keyword @const - 719-733 lang_ts v = thing[key] - 721-722 operator = - 728-729 punctuation [ - 732-733 punctuation ] - 733-734 punctuation } - 736-739 lang_ts {v} - 736-737 punctuation { - 738-739 punctuation } - 740-747 each {/each} + 541-542 operator : + 543-549 builtin string + 549-550 punctuation , + 554-555 operator : + 556-562 builtin number + 562-563 punctuation ) + 564-566 operator => + 567-568 punctuation ( + 570-571 operator : + 572-583 capitalized_identifier HTMLElement + 583-584 punctuation ) + 585-587 operator => + 588-589 punctuation { + 604-607 operator !== + 610-611 punctuation ; + 613-614 punctuation } + 614-615 punctuation ; + 618-621 keyword let + 628-629 operator = + 630-636 function $state + 636-637 punctuation ( + 642-643 punctuation [ + 643-645 string '' + 645-646 punctuation ] + 646-647 punctuation ) + 647-648 punctuation ; + 650-653 keyword let + 665-666 operator : + 667-678 capitalized_identifier HTMLElement + 678-679 punctuation ; + 680-689 tag + 680-688 tag + 691-719 tag

    + 691-694 tag

    + 725-732 svelte_expression {HELLO} + 725-726 punctuation { + 726-731 lang_ts HELLO + 726-731 constant HELLO + 731-732 punctuation } + 733-738 tag

    + 733-737 tag + 740-782 svelte_expression {#each thing_keys as [k, { t, u }] (f(k))} + 740-782 each {#each thing_keys as [k, { t, u }] (f(k))} 740-741 punctuation { - 741-746 special_keyword /each - 746-747 punctuation } - 749-756 block {#if c} - 749-750 punctuation { - 750-753 special_keyword #if - 753-755 lang_ts c - 755-756 punctuation } - 758-799 tag - 758-764 tag - 800-816 block {:else if a > 0} - 800-801 punctuation { - 801-809 special_keyword :else if - 809-815 lang_ts a > 0 - 812-813 operator > - 814-815 number 0 - 815-816 punctuation } - 825-832 lang_ts {:else} - 825-826 punctuation { - 826-827 operator : - 827-831 special_keyword else - 831-832 punctuation } - 834-898 tag (c = !c)}> - 834-840 tag (c = !c)} - 881-882 punctuation { - 882-883 punctuation ( - 883-884 punctuation ) - 885-887 operator => - 888-889 punctuation ( - 891-892 operator = - 893-894 operator ! - 895-896 punctuation ) - 896-897 punctuation } - 897-898 punctuation > - 901-921 at_directive {@render children()} - 901-902 punctuation { - 902-909 keyword @render - 910-920 lang_ts children() - 910-918 function children - 918-919 punctuation ( - 919-920 punctuation ) - 920-921 punctuation } - 923-931 tag - 923-930 tag - 932-937 block {/if} - 932-933 punctuation { - 933-936 special_keyword /if - 936-937 punctuation } - 947-955 tag - 947-954 tag - 963-972 tag - 963-971 tag - 976-1008 tag - 976-982 tag -1010-1090 tag
    -1010-1014 tag
    -1112-1118 tag
    -1112-1117 tag
    -1120-1142 at_directive {@render my_snippet()} -1120-1121 punctuation { -1121-1128 keyword @render -1129-1141 lang_ts my_snippet() -1129-1139 function my_snippet -1139-1140 punctuation ( -1140-1141 punctuation ) -1141-1142 punctuation } -1144-1167 block {#snippet my_snippet()} -1144-1145 punctuation { -1145-1153 special_keyword #snippet -1153-1166 lang_ts my_snippet() -1154-1164 function my_snippet -1164-1165 punctuation ( -1165-1166 punctuation ) -1166-1167 punctuation } -1169-1187 tag -1200-1208 tag -1210-1220 block {/snippet} -1210-1211 punctuation { -1211-1219 special_keyword /snippet -1219-1220 punctuation } -1222-1263 tag
    -1222-1226 tag
    -1265-1268 tag

    -1265-1267 tag

    -1280-1284 tag

    -1280-1283 tag

    -1285-1291 tag
    -1285-1290 tag
    -1293-1327 tag

    -1293-1295 tag

    -1334-1354 tag -1334-1339 tag -1358-1365 tag -1358-1364 tag -1366-1370 tag

    -1366-1369 tag

    -1372-1403 tag -1413-1421 tag -1424-1461 comment -1462-1465 lang_ts {a} -1462-1463 punctuation { -1464-1465 punctuation } -1466-1469 lang_ts {b} -1466-1467 punctuation { -1468-1469 punctuation } -1470-1477 lang_ts {bound} -1470-1471 punctuation { -1476-1477 punctuation } -1479-1485 tag
    -1479-1482 tag
    -1487-1493 tag
    -1487-1490 tag
    -1495-1531 tag access -1495-1499 tag -1533-1537 tag
      -1533-1536 tag
        -1539-1543 tag
      • -1539-1542 tag
      • -1554-1559 tag
      • -1554-1558 tag -1561-1565 tag
      • -1561-1564 tag
      • -1576-1581 tag
      • -1576-1580 tag -1582-1587 tag
      -1582-1586 tag
    -1589-1632 comment -1633-1638 tag
    -1633-1637 tag
    -1640-1648 tag -1686-1694 tag -1697-1704 tag -1738-1745 tag -1747-1753 tag
    -1747-1752 tag
    -1755-1762 tag -2165-2172 tag + 741-746 special_keyword #each + 758-760 keyword as + 761-777 lang_ts [k, { t, u }] (f + 761-762 punctuation [ + 763-764 punctuation , + 765-766 punctuation { + 768-769 punctuation , + 772-773 punctuation } + 773-774 punctuation ] + 775-776 punctuation ( + 777-781 lang_ts (k)) + 777-778 punctuation ( + 779-780 punctuation ) + 780-781 punctuation ) + 781-782 punctuation } + 784-820 svelte_expression {@const v = Math.round(t[k + f(u)])} + 784-820 at_directive {@const v = Math.round(t[k + f(u)])} + 784-785 punctuation { + 785-791 keyword @const + 792-820 lang_ts v = Math.round(t[k + f(u)])} + 794-795 operator = + 796-800 capitalized_identifier Math + 800-801 punctuation . + 801-806 function round + 806-807 punctuation ( + 808-809 punctuation [ + 811-812 operator + + 813-814 function f + 814-815 punctuation ( + 816-817 punctuation ) + 817-818 punctuation ] + 818-819 punctuation ) + 819-820 punctuation } + 822-828 svelte_expression {f(v)} + 822-823 punctuation { + 823-827 lang_ts f(v) + 823-824 function f + 824-825 punctuation ( + 826-827 punctuation ) + 827-828 punctuation } + 829-836 svelte_expression {/each} + 829-836 block {/each} + 829-830 punctuation { + 830-835 special_keyword /each + 835-836 punctuation } + 838-848 svelte_expression {#if f(c)} + 838-848 block {#if f(c)} + 838-839 punctuation { + 839-842 special_keyword #if + 842-847 lang_ts f(c) + 843-844 function f + 844-845 punctuation ( + 846-847 punctuation ) + 847-848 punctuation } + 850-905 tag + 850-856 tag + 906-925 svelte_expression {:else if f(a > 0)} + 906-925 block {:else if f(a > 0)} + 906-907 punctuation { + 907-915 special_keyword :else if + 915-924 lang_ts f(a > 0) + 916-917 function f + 917-918 punctuation ( + 920-921 operator > + 922-923 number 0 + 923-924 punctuation ) + 924-925 punctuation } + 934-941 svelte_expression {:else} + 934-935 punctuation { + 935-940 lang_ts :else + 935-936 operator : + 936-940 special_keyword else + 940-941 punctuation } + 943-994 tag (c = f(!c))}> + 943-949 tag (c = f(!c))} + 974-975 punctuation { + 975-992 lang_ts () => (c = f(!c)) + 975-976 punctuation ( + 976-977 punctuation ) + 978-980 operator => + 981-982 punctuation ( + 984-985 operator = + 986-987 function f + 987-988 punctuation ( + 988-989 operator ! + 990-991 punctuation ) + 991-992 punctuation ) + 992-993 punctuation } + 993-994 punctuation > + 997-1017 svelte_expression {@render children()} + 997-1017 at_directive {@render children()} + 997-998 punctuation { + 998-1005 keyword @render +1006-1017 lang_ts children()} +1006-1014 function children +1014-1015 punctuation ( +1015-1016 punctuation ) +1016-1017 punctuation } +1019-1027 tag +1019-1026 tag +1028-1033 svelte_expression {/if} +1028-1033 block {/if} +1028-1029 punctuation { +1029-1032 special_keyword /if +1032-1033 punctuation } +1035-1070 svelte_expression {@html 'raw html'} +1035-1070 at_directive {@html 'raw html'} +1035-1036 punctuation { +1036-1041 keyword @html +1042-1070 lang_ts 'raw html'} +1042-1069 string 'raw html' +1069-1070 punctuation } +1072-1121 tag +1072-1078 tag +1123-1166 tag +1123-1128 tag +1169-1176 tag +1169-1175 tag +1178-1203 svelte_expression {@render my_snippet('p')} +1178-1203 at_directive {@render my_snippet('p')} +1178-1179 punctuation { +1179-1186 keyword @render +1187-1203 lang_ts my_snippet('p')} +1187-1197 function my_snippet +1197-1198 punctuation ( +1198-1201 string 'p' +1201-1202 punctuation ) +1202-1203 punctuation } +1205-1237 svelte_expression {#snippet my_snippet(p: string)} +1205-1237 block {#snippet my_snippet(p: string)} +1205-1206 punctuation { +1206-1214 special_keyword #snippet +1214-1236 lang_ts my_snippet(p: string) +1215-1225 function my_snippet +1225-1226 punctuation ( +1227-1228 operator : +1229-1235 builtin string +1235-1236 punctuation ) +1236-1237 punctuation } +1239-1257 tag +1260-1268 tag +1270-1280 svelte_expression {/snippet} +1270-1280 block {/snippet} +1270-1271 punctuation { +1271-1279 special_keyword /snippet +1279-1280 punctuation } +1282-1331 tag

    +1282-1284 tag

    +1338-1358 tag +1338-1343 tag +1362-1369 tag +1362-1368 tag +1370-1374 tag

    +1370-1373 tag

    +1376-1407 tag +1417-1425 tag +1428-1467 comment +1468-1481 svelte_expression {b.repeat(2)} +1468-1469 punctuation { +1469-1480 lang_ts b.repeat(2) +1470-1471 punctuation . +1471-1477 function repeat +1477-1478 punctuation ( +1478-1479 number 2 +1479-1480 punctuation ) +1480-1481 punctuation } +1482-1489 svelte_expression {bound} +1482-1483 punctuation { +1483-1488 lang_ts bound +1488-1489 punctuation } +1491-1497 tag
    +1491-1494 tag
    +1499-1505 tag
    +1499-1502 tag
    +1507-1543 tag access +1507-1511 tag +1545-1549 tag
      +1545-1548 tag
        +1551-1555 tag
      • +1551-1554 tag
      • +1566-1571 tag
      • +1566-1570 tag +1573-1577 tag
      • +1573-1576 tag
      • +1588-1593 tag
      • +1588-1592 tag +1594-1599 tag
      +1594-1598 tag
    +1601-1644 comment +1645-1650 tag
    +1645-1649 tag
    +1652-1660 tag +1698-1706 tag +1709-1716 tag +1750-1757 tag +1759-1765 tag
    +1759-1764 tag
    +1767-1774 tag +2159-2166 tag diff --git a/src/lib/grammar_svelte.ts b/src/lib/grammar_svelte.ts index e7d151bd..a5b97a50 100644 --- a/src/lib/grammar_svelte.ts +++ b/src/lib/grammar_svelte.ts @@ -14,23 +14,29 @@ const blocks = '(if|else if|await|then|catch|each|html|debug|snippet)'; export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { const grammar_ts = syntax_styler.get_lang('ts'); - - const grammar_svelte = syntax_styler.add_extended_lang('markup', 'svelte', { - at_directive: { - pattern: /{@(?:render|html|const|debug|attach)\b(?:(?:\{(?:(?:\{(?:[^{}])*\})|(?:[^{}]))*\})|(?:[^{}]))*}/, - inside: { - lang_ts: { - pattern: /(@(?:render|html|const|debug|attach)\s+)[\s\S]*(?=\s*\})/, - lookbehind: true, - inside: grammar_ts, - }, - keyword: /@(?:render|html|const|debug|attach)/, - punctuation: /{|}/, + // Define the at_directive pattern once for reuse (matches any @word) + const at_directive_pattern = { + pattern: /^{(@\w+)(\s+[\s\S]*)?}$/, + inside: { + lang_ts: { + pattern: /(@\w+\s+)([\s\S]+)/, // Fixed: removed incorrect (?=}$) + lookbehind: true, + inside: grammar_ts, }, + keyword: /@\w+/, + punctuation: /[{}]/, }, + }; + + // Full expression patterns for top-level contexts + const svelte_expression_inside_full = { + // Generic @ directive - matches any @word + at_directive: at_directive_pattern, + // {#each items as item} with special syntax each: { - pattern: /{[#/]each(?:(?:\{(?:(?:\{(?:[^{}])*\})|(?:[^{}]))*\})|(?:[^{}]))*}/, + pattern: /^{([#/]each)\s+([\s\S]*)}$/, inside: { + special_keyword: /[#/]each/, lang_ts: [ { pattern: /(as[\s\S]*)\([\s\S]*\)(?=\s*\})/, @@ -48,25 +54,49 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { inside: grammar_ts, }, ], - special_keyword: /[#/]each/, keyword: /as/, - punctuation: /{|}/, + punctuation: /[{}]/, }, }, + // {#block ...} and {/block} block: { - pattern: new RegExp( - '{[#:/@]\\s*' + blocks + '(?:(?:\\{(?:(?:\\{(?:[^{}])*\\})|(?:[^{}]))*\\})|(?:[^{}]))*}', - ), + pattern: new RegExp('^\\{([#:/@]\\s*' + blocks + ')\\s*([\\s\\S]*)\\}$'), inside: { - punctuation: /^{|}$/, special_keyword: new RegExp('[#:/@]' + blocks), keyword: [/as/, /then/], lang_ts: { - pattern: /[\s\S]*/, + pattern: /[\s\S]+(?=}$)/, inside: grammar_ts, }, + punctuation: /[{}]/, }, }, + // Default: plain TS expression + punctuation: /[{}]/, + lang_ts: { + pattern: /[\s\S]+/, + inside: grammar_ts, + }, + }; + + // Simplified patterns for tag contexts (no block directives) + const svelte_expression_inside_simple = { + // Generic @ directive + at_directive: at_directive_pattern, + // Default: plain TS expression + punctuation: /[{}]/, + lang_ts: { + pattern: /[\s\S]+/, + inside: grammar_ts, + }, + }; + + const grammar_svelte = syntax_styler.add_extended_lang('markup', 'svelte', { + svelte_expression: { + pattern: /\{(?:[^{}]|\{[^}]*\})*\}/, + greedy: true, + inside: svelte_expression_inside_full, + }, tag: { pattern: /<\/?(?!\d)[^\s>/=$<%]+(?:\s(?:\s*[^\s>/=]+(?:\s*=\s*(?:(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?:"[^"]*"|'[^']*'|{[\s\S]+?}(?=[\s/>])))|(?=[\s/>])))+)?\s*\/?>/i, @@ -79,9 +109,9 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { namespace: /^[^\s>/:]+:/, }, }, - lang_ts: { - pattern: /\{(?:(?:\{(?:(?:\{(?:[^{}])*\})|(?:[^{}]))*\})|(?:[^{}]))*\}/, - inside: grammar_ts, + svelte_expression: { + pattern: /\{(?:[^{}]|\{[^}]*\})*\}/, + inside: svelte_expression_inside_simple, }, attr_value: { pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i, @@ -93,9 +123,9 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { lookbehind: true, }, ], - lang_ts: { - pattern: /{[\s\S]+}/, - inside: grammar_ts, + svelte_expression: { + pattern: /\{(?:[^{}]|\{[^}]*\})*\}/, + inside: svelte_expression_inside_simple, }, }, }, @@ -108,11 +138,6 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { }, }, }, - lang_ts: { - pattern: /\{(?:(?:\{(?:(?:\{(?:[^{}])*\})|(?:[^{}]))*\})|(?:[^{}]))*\}/, - lookbehind: true, - inside: grammar_ts, - }, }); // oof lol diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 3ff31736..f8be4d47 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -305,7 +305,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; onclick?: () => void; } = $props(); - const thing_keys = $derived(Object.keys(thing)); + const thing_keys = $derived(Object.entries(thing)); const a = 1; @@ -313,58 +313,53 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; let c: boolean = $state(true); - const attachment = (_p1: string, _p2: number) => (_: HTMLElement) => { - element_ref; + const f = (p: any) => p; + + const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { + element_ref !== el; }; let value = $state(thing['']); let element_ref: HTMLElement; -

    hello {HELLO}!

    +

    hello {HELLO}!

    -{#each thing_keys as key (key)} - {@const v = thing[key]} - {v} +{#each thing_keys as [k, { t, u }] (f(k))} + {@const v = Math.round(t[k + f(u)])} + {f(v)} {/each} -{#if c} - -{:else if a > 0} +{#if f(c)} + +{:else if f(a > 0)} bigger {:else} - (c = !c)}> + (c = f(!c))}> {@render children()} {/if} {@html 'raw html'} - + -
    - interactive element -
    +... -{@render my_snippet()} +{@render my_snippet('p')} -{#snippet my_snippet()} - +{#snippet my_snippet(p: string)} + {/snippet} -
    -

    hello world!

    -
    - -

    +

    some text

    - -{a} -{b} + +{b.repeat(2)} {bound}
    @@ -417,17 +412,13 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; background-color: blue; } - div > p { - margin: 10px; - } - @media (max-width: 600px) { :global(body) { background-color: light-dark(lightblue, darkblue); } } - .special::before { + :global(.escapehatch)::before { content: '< & >'; } diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index eca55b13..a9c2feb8 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -40,16 +40,16 @@

    hello {HELLO}!

    {#each thing_keys as [k, { t, u }] (f(k))} - {@const v = Math.round(t[k + u])} - {v} + {@const v = Math.round(t[k + f(u)])} + {f(v)} {/each} {#if f(c)} - + {:else if f(a > 0)} bigger {:else} - (c = !c)}> + (c = f(!c))}> {@render children()} {/if} @@ -58,7 +58,7 @@ -... +... {@render my_snippet('p')} @@ -72,9 +72,8 @@ - -{a} -{b} + +{b.repeat(2)} {bound}
    @@ -133,7 +132,7 @@ } } - .special::before { + :global(.escapehatch)::before { content: '< & >'; } From 0e75ab6422ae6b47ac08f10a212f4d8e9f4559ac Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 06:20:37 -0400 Subject: [PATCH 37/49] wip --- .../generated/svelte/svelte_complex.html | 4 ++-- .../generated/svelte/svelte_complex.txt | 19 +++++++++---------- src/lib/grammar_svelte.ts | 11 +++-------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index cda897c1..be8c274a 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -39,7 +39,7 @@ <h1 bind:this={element_ref}>hello {HELLO}!</h1> -{#each thing_keys as [k, { t, u }] (f(k))} +{#each thing_keys as [k, { t, u }] (f(k))} {@const v = Math.round(t[k + f(u)])} {f(v)} {/each} @@ -48,7 +48,7 @@ <Thing string_prop="a {f('s')} b" number_prop={f(1)} /> {:else if f(a > 0)} bigger -{:else} +{:else} <Thing string_prop="b" onthing={() => (c = f(!c))}> {@render children()} </Thing> diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 81e55ec6..1476f6db 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -1,14 +1,14 @@ === STATS === Sample length: 2168 characters -Total tokens: 624 +Total tokens: 623 Token types (32 unique): punctuation: 295 tag: 74 - operator: 38 - lang_ts: 25 + operator: 37 svelte_expression: 24 - function: 22 + lang_ts: 23 + function: 23 attr_name: 19 keyword: 19 special_keyword: 13 @@ -17,8 +17,8 @@ Token types (32 unique): capitalized_identifier: 8 builtin: 8 property: 8 + block: 7 selector: 7 - block: 6 comment: 5 number: 5 at_directive: 5 @@ -227,7 +227,7 @@ Token types (32 unique): 740-741 punctuation { 741-746 special_keyword #each 758-760 keyword as - 761-777 lang_ts [k, { t, u }] (f + 761-782 lang_ts [k, { t, u }] (f(k))} 761-762 punctuation [ 763-764 punctuation , 765-766 punctuation { @@ -235,7 +235,7 @@ Token types (32 unique): 772-773 punctuation } 773-774 punctuation ] 775-776 punctuation ( - 777-781 lang_ts (k)) + 776-777 function f 777-778 punctuation ( 779-780 punctuation ) 780-781 punctuation ) @@ -314,10 +314,9 @@ Token types (32 unique): 923-924 punctuation ) 924-925 punctuation } 934-941 svelte_expression {:else} + 934-941 block {:else} 934-935 punctuation { - 935-940 lang_ts :else - 935-936 operator : - 936-940 special_keyword else + 935-940 special_keyword :else 940-941 punctuation } 943-994 tag (c = f(!c))}> 943-949 tag { special_keyword: /[#/]each/, lang_ts: [ { - pattern: /(as[\s\S]*)\([\s\S]*\)(?=\s*\})/, + pattern: /(#each\s+)[\s\S]+(?=\s+as)/, // Expression before 'as' lookbehind: true, inside: grammar_ts, }, { - pattern: /(as[\s]*)[\s\S]*(?=\s*)/, - lookbehind: true, - inside: grammar_ts, - }, - { - pattern: /(#each[\s]*)[\s\S]*(?=as)/, + pattern: /(as\s+)[\s\S]+/, // Everything after 'as' (including key) lookbehind: true, inside: grammar_ts, }, From 3460d72bce6989f0c7718b6fe2d6906818767f9a Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 06:55:41 -0400 Subject: [PATCH 38/49] wip --- src/fixtures/check.test.ts | 6 +- src/fixtures/generated/html/html_complex.html | 4 +- src/fixtures/generated/html/html_complex.txt | 328 +++++++++--------- src/lib/grammar_clike.ts | 5 +- src/lib/grammar_js.ts | 41 ++- src/lib/grammar_svelte.ts | 7 +- src/lib/grammar_ts.ts | 6 +- src/lib/samples/all.ts | 4 +- src/lib/samples/sample_complex.html | 4 +- src/routes/package.ts | 5 +- 10 files changed, 216 insertions(+), 194 deletions(-) diff --git a/src/fixtures/check.test.ts b/src/fixtures/check.test.ts index 0c014b45..8388ab86 100644 --- a/src/fixtures/check.test.ts +++ b/src/fixtures/check.test.ts @@ -1,10 +1,6 @@ import {test, assert, describe} from 'vitest'; import {readFileSync, existsSync} from 'node:fs'; -import { - discover_samples, - process_sample, - get_fixture_path, -} from './helpers.js'; +import {discover_samples, process_sample, get_fixture_path} from './helpers.js'; import {sample_langs} from '$lib/code_sample.js'; /** diff --git a/src/fixtures/generated/html/html_complex.html b/src/fixtures/generated/html/html_complex.html index 86ce0031..90084059 100644 --- a/src/fixtures/generated/html/html_complex.html +++ b/src/fixtures/generated/html/html_complex.html @@ -12,7 +12,7 @@ <br /> -<hr /> +<hr onclick="console.log('hi')" /> <img src="image.jpg" alt="access" /> @@ -29,7 +29,7 @@ </select> </form> -<script type="text/javascript"> +<script> const ok = '<style>'; </script> diff --git a/src/fixtures/generated/html/html_complex.txt b/src/fixtures/generated/html/html_complex.txt index 8fd58eb9..29f367a3 100644 --- a/src/fixtures/generated/html/html_complex.txt +++ b/src/fixtures/generated/html/html_complex.txt @@ -1,15 +1,18 @@ === STATS === -Sample length: 779 characters -Total tokens: 232 +Sample length: 784 characters +Total tokens: 239 -Token types (16 unique): - punctuation: 120 +Token types (19 unique): + punctuation: 123 tag: 64 attr_name: 18 attr_value: 17 - string: 2 + string: 3 doctype: 1 comment: 1 + special_attr: 1 + value: 1 + function: 1 script: 1 lang_js: 1 keyword: 1 @@ -88,168 +91,175 @@ Token types (16 unique): 239-242 tag
    - 247-253 tag
    + 247-281 tag
    247-250 tag
    - 255-291 tag access - 255-259 tag - 293-297 tag
      - 293-296 tag
        - 299-303 tag
      • - 299-302 tag
      • - 314-319 tag
      • - 314-318 tag - 321-325 tag
      • - 321-324 tag
      • + 283-319 tag access + 283-287 tag + 321-325 tag
          + 321-324 tag
            - 336-341 tag - 336-340 tag - 342-347 tag
          - 342-346 tag
        + 327-330 tag
      • + 342-347 tag
      • + 342-346 tag - 349-386 tag
        - 349-354 tag + 349-352 tag
      • - 388-450 tag - 388-394 tag + 364-369 tag
      • + 364-368 tag + 370-375 tag
      + 370-374 tag
    + 377-414 tag + 377-382 tag - 452-495 tag + 416-478 tag + 416-422 tag + 480-523 tag - 498-516 tag - 521-529 tag - 533-551 tag - 557-565 tag - 568-577 tag - 568-576 tag - 578-585 tag - 578-584 tag - 587-618 tag - 642-650 tag - 653-676 tag - 720-727 tag - 730-778 cdata ]]> + 521-522 punctuation " + 522-523 punctuation > + 526-544 tag + 549-557 tag + 561-579 tag + 585-593 tag + 596-605 tag + 596-604 tag + 606-613 tag + 606-612 tag + 615-623 tag + 647-655 tag + 658-681 tag + 725-732 tag + 735-783 cdata ]]> diff --git a/src/lib/grammar_clike.ts b/src/lib/grammar_clike.ts index 67f13066..d2de8257 100644 --- a/src/lib/grammar_clike.ts +++ b/src/lib/grammar_clike.ts @@ -1,5 +1,7 @@ import type {Add_Syntax_Grammar, Syntax_Grammar} from '$lib/syntax_styler.js'; +export const class_keywords = 'class|extends|implements|instanceof|interface|new'; + /** * Based on Prism (https://github.com/PrismJS/prism) * by Lea Verou (https://lea.verou.me/) @@ -27,8 +29,7 @@ export const add_grammar_clike: Add_Syntax_Grammar = (syntax_styler) => { greedy: true, }, class_name: { - pattern: - /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, + pattern: new RegExp(`(\\b(?:${class_keywords}|trait)\\s+|\\bcatch\\s+\\()[\\w.\\\\]+`, 'i'), lookbehind: true, inside: { punctuation: /[.\\]/, diff --git a/src/lib/grammar_js.ts b/src/lib/grammar_js.ts index 827681c4..cd0b9f84 100644 --- a/src/lib/grammar_js.ts +++ b/src/lib/grammar_js.ts @@ -1,5 +1,6 @@ import type {Add_Syntax_Grammar} from '$lib/syntax_styler.js'; import {grammar_markup_add_attribute, grammar_markup_add_inlined} from '$lib/grammar_markup.js'; +import {class_keywords} from '$lib/grammar_clike.js'; /** * Based on Prism (https://github.com/PrismJS/prism) @@ -12,6 +13,18 @@ import {grammar_markup_add_attribute, grammar_markup_add_inlined} from '$lib/gra export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { const grammar_clike = syntax_styler.get_lang('clike'); + // Main JS keywords (from keyword pattern, excluding those with special lookaheads) + const main_keywords = + 'class|const|debugger|delete|enum|extends|function|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with'; + + // Keywords that are treated specially (inserted before 'function') + const special_keywords = + 'as|await|break|case|catch|continue|default|do|else|export|finally|for|from|if|import|return|switch|throw|try|while|yield'; + + // All JS keywords (for negative lookahead in parameter pattern) + // Note: 'assert', 'async', 'get', 'set' have special lookahead requirements in the main keyword pattern + const all_js_keywords = `assert|async|${main_keywords}|get|set|${special_keywords}`; + const grammar_js = syntax_styler.add_extended_lang('clike', 'js', { class_name: [ grammar_clike.class_name, @@ -23,8 +36,9 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { ], keyword: [ { - pattern: - /(^|[^.]|\.\.\.\s*)\b(?:assert(?=\s*\{)|async(?=\s*(?:function\b|\*|\(|[$\w\xA0-\uFFFF]|$))|class|const|debugger|delete|enum|extends|function|(?:get|set)(?=\s*(?:[#[$\w\xA0-\uFFFF]|$))|implements|in|instanceof|interface|let|new|null|of|package|private|protected|public|static|super|this|typeof|undefined|var|void|with)\b/, + pattern: new RegExp( + `(^|[^.]|\\.\\.\\.\\s*)\\b(?:assert(?=\\s*\\{)|async(?=\\s*(?:function\\b|\\*|\\(|[$\\w\\xA0-\\uFFFF]|$))|${main_keywords}|(?:get|set)(?=\\s*(?:[#[$\\w\\xA0-\\uFFFF]|$)))\\b`, + ), lookbehind: true, }, ], @@ -62,12 +76,12 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/, }); - (grammar_js as any).class_name[0].pattern = - /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/; + (grammar_js as any).class_name[0].pattern = new RegExp( + `(\\b(?:${class_keywords})\\s+)[\\w.\\\\]+`, + ); syntax_styler.grammar_insert_before('js', 'function', { - special_keyword: - /\b(?:as|await|break|case|catch|continue|default|do|else|export|finally|for|from|if|import|return|switch|throw|try|while|yield)\b/, + special_keyword: new RegExp(`\\b(?:${special_keywords})\\b`), }); syntax_styler.grammar_insert_before('js', 'keyword', { @@ -129,9 +143,9 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { inside: grammar_js, }, { - pattern: - // TODO BLOCK fix with special_keyword - /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, + pattern: new RegExp( + `((?:\\b|\\s|^)(?!(?:${all_js_keywords})(?![$\\w\\xA0-\\uFFFF]))(?:(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*\\s*)\\(\\s*|\\]\\s*\\(\\s*)(?!\\s)(?:[^()\\s]|\\s+(?![\\s)])|\\([^()]*\\))+(?=\\s*\\)\\s*\\{)`, + ), lookbehind: true, inside: grammar_js, }, @@ -190,12 +204,7 @@ export const add_grammar_js: Add_Syntax_Grammar = (syntax_styler) => { grammar_markup_add_inlined(syntax_styler, 'script', 'js'); - // add attribute support for all DOM events. + // add attribute support for all DOM events (on* attributes) // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events - grammar_markup_add_attribute( - syntax_styler, - /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/ - .source, - 'js', - ); + grammar_markup_add_attribute(syntax_styler, 'on\\w+', 'js'); }; diff --git a/src/lib/grammar_svelte.ts b/src/lib/grammar_svelte.ts index 3ccdda58..2d10ae06 100644 --- a/src/lib/grammar_svelte.ts +++ b/src/lib/grammar_svelte.ts @@ -19,7 +19,7 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { pattern: /^{(@\w+)(\s+[\s\S]*)?}$/, inside: { lang_ts: { - pattern: /(@\w+\s+)([\s\S]+)/, // Fixed: removed incorrect (?=}$) + pattern: /(@\w+\s+)([\s\S]+)/, // Fixed: removed incorrect (?=}$) lookbehind: true, inside: grammar_ts, }, @@ -39,12 +39,12 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { special_keyword: /[#/]each/, lang_ts: [ { - pattern: /(#each\s+)[\s\S]+(?=\s+as)/, // Expression before 'as' + pattern: /(#each\s+)[\s\S]+(?=\s+as)/, // Expression before 'as' lookbehind: true, inside: grammar_ts, }, { - pattern: /(as\s+)[\s\S]+/, // Everything after 'as' (including key) + pattern: /(as\s+)[\s\S]+/, // Everything after 'as' (including key) lookbehind: true, inside: grammar_ts, }, @@ -141,6 +141,7 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { ).inside!.entity = grammar_svelte.entity; grammar_svelte_add_inlined(syntax_styler, 'style', 'css'); + // Assume TypeScript for all Svelte script tags (no plain JS) grammar_svelte_add_inlined(syntax_styler, 'script', 'ts'); }; diff --git a/src/lib/grammar_ts.ts b/src/lib/grammar_ts.ts index 5d2dd53b..d167d230 100644 --- a/src/lib/grammar_ts.ts +++ b/src/lib/grammar_ts.ts @@ -1,4 +1,5 @@ import type {Add_Syntax_Grammar, Syntax_Grammar_Token} from '$lib/syntax_styler.js'; +import {class_keywords} from '$lib/grammar_clike.js'; /** * Based on Prism (https://github.com/PrismJS/prism) @@ -11,8 +12,9 @@ import type {Add_Syntax_Grammar, Syntax_Grammar_Token} from '$lib/syntax_styler. export const add_grammar_ts: Add_Syntax_Grammar = (syntax_styler) => { const grammar_ts = syntax_styler.add_extended_lang('js', 'ts', { class_name: { - pattern: - /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/, + pattern: new RegExp( + `(\\b(?:${class_keywords}|type)\\s+)(?!keyof\\b)(?!\\s)[_$a-zA-Z\\xA0-\\uFFFF](?:(?!\\s)[$\\w\\xA0-\\uFFFF])*(?:\\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?`, + ), lookbehind: true, greedy: true, inside: null, // see below diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index f8be4d47..da58c8ed 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -251,7 +251,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;
    -
    +
    access @@ -268,7 +268,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; - diff --git a/src/lib/samples/sample_complex.html b/src/lib/samples/sample_complex.html index 9fbb527f..316483d3 100644 --- a/src/lib/samples/sample_complex.html +++ b/src/lib/samples/sample_complex.html @@ -12,7 +12,7 @@
    -
    +
    access @@ -29,7 +29,7 @@ - diff --git a/src/routes/package.ts b/src/routes/package.ts index 5cc25821..afc45e66 100644 --- a/src/routes/package.ts +++ b/src/routes/package.ts @@ -95,7 +95,10 @@ export const src_json: Src_Json = { }, './grammar_clike.js': { path: 'grammar_clike.ts', - declarations: [{name: 'add_grammar_clike', kind: 'function'}], + declarations: [ + {name: 'class_keywords', kind: 'variable'}, + {name: 'add_grammar_clike', kind: 'function'}, + ], }, './grammar_css.js': { path: 'grammar_css.ts', From db293a84752390b1fc62dc7d89ead8a2a9634c54 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:11:51 -0400 Subject: [PATCH 39/49] wip --- src/fixtures/generated/css/css_complex.html | 70 +- src/fixtures/generated/html/html_complex.html | 287 ++++++- src/fixtures/generated/json/json_complex.html | 56 +- .../generated/svelte/svelte_complex.html | 709 +++++++++++++++--- src/fixtures/generated/ts/ts_complex.html | 577 ++++++++++---- src/fixtures/update.task.ts | 6 +- 6 files changed, 1392 insertions(+), 313 deletions(-) diff --git a/src/fixtures/generated/css/css_complex.html b/src/fixtures/generated/css/css_complex.html index b6f51f53..0b7e5b10 100644 --- a/src/fixtures/generated/css/css_complex.html +++ b/src/fixtures/generated/css/css_complex.html @@ -1,45 +1,73 @@ .some_class { - color: red; +color: red; } .hypen-class { - font-size: 16px; +font-size: 16px; } p { - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +box-shadow: 0 0 10px +rgba(0, +0, 0, 0.1); } /* comment */ -/* -multi -.line { - i: 100px - -</style> - -@media*/ +/* multi .line { i: 100px </style> @media*/ #id { - background-color: blue; +background-color: blue; } div > p { - margin: 10px; +margin: 10px; } -@media (max-width: 600px) { - body { - background-color: light-dark(lightblue, darkblue); - } +@media (max-width: 600px) +{ body +{ background-color: light-dark(lightblue, +darkblue); +} } .content::before { - /* prettier-ignore */ - content: "</style> /* not a comment */"; +/* prettier-ignore */ +content: +"</style> /* not a comment */"; } -.attr[title='Click: here'] { - background-image: url('data:image/svg+xml...'); +.attr[title='Click: here'] +{ background-image: +url('data:image/svg+xml...'); } diff --git a/src/fixtures/generated/html/html_complex.html b/src/fixtures/generated/html/html_complex.html index 90084059..ce771067 100644 --- a/src/fixtures/generated/html/html_complex.html +++ b/src/fixtures/generated/html/html_complex.html @@ -1,42 +1,275 @@ <!doctype html> -<div class="test"> - <p>hello world!</p> -</div> +<div + class="test"> +<p>hello world!</p> +</div> -<p class="some_class hypen-class">some <span class="a b c">text</span></p> +<p + class="some_class hypen-class">some +<span + class="a b c">text</span></p> -<button type="button" disabled>click me</button> +<button + type="button" + disabled>click me</button> <!-- comment <div>a<br /> b</div> <script> --> -<br /> +<br + /> -<hr onclick="console.log('hi')" /> +<hr + onclick="console.log('hi')" + /> -<img src="image.jpg" alt="access" /> +<img + src="image.jpg" + alt="access" + /> -<ul> - <li>list item 1</li> - <li>list item 2</li> -</ul> +<ul> +<li>list item 1</li> +<li>list item 2</li> +</ul> -<form action="/submit" method="post"> - <input type="text" name="username" placeholder="Enter name" /> - <select name="option" data-role="dropdown"> - <option value="1">First</option> - <option value="2">Second</option> - </select> -</form> +<form + action="/submit" + method="post"> +<input + type="text" + name="username" + placeholder="Enter name" + /> +<select + name="option" + data-role="dropdown"> +<option + value="1">First</option> +<option + value="2">Second</option> +</select> +</form> -<script> - const ok = '<style>'; -</script> +<script> + const ok = + '<style>'; + </script> -<style type="text/css"> - .special::before { - content: '< & >'; - } -</style> +<style + type="text/css"> + .special::before { + content: + '< & >'; + } + </style> <![CDATA[ if (a < 0) alert("b"); <not-a-tag> ]]> diff --git a/src/fixtures/generated/json/json_complex.html b/src/fixtures/generated/json/json_complex.html index 7e3dd385..eb9f4e5b 100644 --- a/src/fixtures/generated/json/json_complex.html +++ b/src/fixtures/generated/json/json_complex.html @@ -1,14 +1,44 @@ -{ - "string": "a string", - "number": 12345, - "boolean": true, - "null": null, - "empty": "", - "escaped": "quote: \"test\" and backslash: \\", - "object": { - "array": [1, "b", false], - "strings": ["1", "2", "3"], - "mixed": ["start", 123, true, "middle", null, "end"], - "nested": [["a", "str", ""], {"key": "nested value"}] - } +{ "string": "a string", "number": 12345, "boolean": true, "null": null, "empty": "", "escaped": +"quote: \"test\" and backslash: \\", "object": { +"array": +[1, "b", false], +"strings": +["1", "2", "3"], +"mixed": +["start", 123, true, "middle", null, "end"], +"nested": +[["a", +"str", +""], {"key": +"nested value"}] +} } diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index be8c274a..abf33c33 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -1,138 +1,599 @@ -<script lang="ts" module> - export const HELLO = 'world'; -</script> - -<script lang="ts"> - // @ts-expect-error - import Thing from '$lib/Thing.svelte'; - import type {Snippet} from 'svelte'; - - const { - thing, - bound = $bindable(true), - children, - onclick, - }: { - thing: Record<string, any>; - bound?: boolean; - children: Snippet; - onclick?: () => void; - } = $props(); - - const thing_keys = $derived(Object.entries(thing)); - - const a = 1; - - const b = 'b'; - - let c: boolean = $state(true); - - const f = (p: any) => p; - - const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { - element_ref !== el; - }; - - let value = $state(thing['']); - let element_ref: HTMLElement; -</script> - -<h1 bind:this={element_ref}>hello {HELLO}!</h1> - -{#each thing_keys as [k, { t, u }] (f(k))} - {@const v = Math.round(t[k + f(u)])} - {f(v)} -{/each} - -{#if f(c)} - <Thing string_prop="a {f('s')} b" number_prop={f(1)} /> -{:else if f(a > 0)} - bigger -{:else} - <Thing string_prop="b" onthing={() => (c = f(!c))}> - {@render children()} - </Thing> -{/if} - -{@html '<strong>raw html</strong>'} - -<input bind:value type="text" class:active={c} /> - -<span {@attach attachment('param', f(42))}>...</span> - -{@render my_snippet('p')} - -{#snippet my_snippet(p: string)} - <button {onclick}>{p}</button> -{/snippet} - -<p class="some_class hypen-class" id="unique_id"> - some <span class="a b c">text</span> -</p> - -<button type="button" disabled> click me </button> +<script + lang="ts" + module> + export const + HELLO = + 'world'; + </script> + +<script + lang="ts"> + // @ts-expect-error + import + Thing + from + '$lib/Thing.svelte'; + import type + {Snippet} from + 'svelte'; + + const { thing, + bound = $bindable(true), children, + onclick, }: { thing: + Record<string, any>; bound?: boolean; children: + Snippet; onclick?: () => + void; + } = + $props(); + + const thing_keys = + $derived(Object.entries(thing)); + + const a = + 1; + + const b = + 'b'; + + let c: boolean = $state(true); + + const + f = + (p: + any) + => p; + + const + attachment + = (_p1: + string, _p2: + number) + => (el: + HTMLElement) => + { element_ref + !== el; + }; + + let value = + $state(thing['']); + let element_ref: + HTMLElement; + </script> + +<h1 + bind:this={element_ref}>hello +{HELLO}!</h1> + +{#each thing_keys + as + [k, + { t, u + }] + (f(k))} +{@const + v = + Math.round(t[k + + f(u)])} +{f(v)} +{/each} + +{#if + f(c)} +<Thing + string_prop="a + {f('s')} + b" number_prop={f(1)} + /> +{:else if + f(a + > 0)} +bigger +{:else} +<Thing + string_prop="b" + onthing={() + => (c + = f(!c))}> +{@render + children()} +</Thing> +{/if} + +{@html + '<strong>raw html</strong>'} + +<input + bind:value + type="text" + class:active={c} + /> + +<span + {@attach + attachment('param', + f(42))}>...</span> + +{@render + my_snippet('p')} + +{#snippet + my_snippet(p: + string)} +<button + {onclick}>{p}</button> +{/snippet} + +<p + class="some_class + hypen-class" + id="unique_id"> +some +<span + class="a b c">text</span> +</p> + +<button + type="button" + disabled> +click me +</button> <!-- comment <div>a<br /> {b}</div> --> -{b.repeat(2)} -{bound} - -<br /> - -<hr /> - -<img src="image.jpg" alt="access" /> - -<ul> - <li>list item 1</li> - <li>list item 2</li> -</ul> +{b.repeat(2)} +{bound} + +<br + /> + +<hr + /> + +<img + src="image.jpg" + alt="access" + /> + +<ul> +<li>list item 1</li> +<li>list item 2</li> +</ul> <!-- embedded tags for boundary testing --> -<div> - <script> - const inline_js = 'no lang attr'; - </script> - <style> +<div> +<script> + const inline_js = + 'no lang attr'; + </script> +<style> .inline { - color: blue; + color: blue; + } + </style> +</div> + +<style> + .some_class { + color: red; } - </style> -</div> - -<style> - .some_class { - color: red; - } - - .hypen-class { - font-size: 16px; - } - - p { - box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); - } - /* comment */ + .hypen-class { + font-size: 16px; + } - /* - multi - line + p { + box-shadow: 0 0 10px + rgba(0, + 0, 0, 0.1); + } - <comment> + /* comment */ - */ + /* multi line <comment> */ - #unique_id { - background-color: blue; - } + #unique_id { + background-color: blue; + } - @media (max-width: 600px) { - :global(body) { - background-color: light-dark(lightblue, darkblue); + @media (max-width: 600px) + { :global(body) + { background-color: light-dark(lightblue, + darkblue); + } } - } - :global(.escapehatch)::before { - content: '< & >'; - } -</style> + :global(.escapehatch)::before + { content: '< & >'; + } + </style> diff --git a/src/fixtures/generated/ts/ts_complex.html b/src/fixtures/generated/ts/ts_complex.html index 9faaf5ef..1d19ad06 100644 --- a/src/fixtures/generated/ts/ts_complex.html +++ b/src/fixtures/generated/ts/ts_complex.html @@ -1,150 +1,475 @@ -const a = 1; - -const b: string = 'b'; - -const c = true; - -export type Some_Type = 1 | 'b' | true; +const a = +1; + +const b: string = 'b'; + +const c = +true; + +export type +Some_Type += 1 +| 'b' +| true; + +declare +const some_decorator: +any; + +abstract class +Base +{ abstract +abstract_method(): +void; +} -declare const some_decorator: any; +@some_decorator +class +D +extends +Base +{ readonly d1: string = 'd'; d2: +number; d3 += $state(null); + +@some_decorator +decorated = true; + +constructor(d2: +number) +{ super(); this.d2 = d2; +} -abstract class Base { - abstract abstract_method(): void; +abstract_method(): +void { +// implementation } -@some_decorator -class D extends Base { - readonly d1: string = 'd'; - d2: number; - d3 = $state(null); - - @some_decorator - decorated = true; - - constructor(d2: number) { - super(); - this.d2 = d2; - } - - abstract_method(): void { - // implementation - } - - @some_decorator('example', {option: true}) - class_method(): string { - return `Hello, ${this.d1}`; - } - - instance_method = (): void => { - /* ... */ - let i = 0; - do { - i++; - } while (i < 3); - - for (const c2 of this.d1) { - if (c2 === 'd') continue; - if (!c2) break; - this.#private_method(a, c2); - } - - switch (this.d1) { - case 'a': - console.log('case a'); - break; - case 'b': - case 'c': - console.log('case b or c'); - break; - default: - console.log('default'); - } - - const obj: {has_d1?: boolean; is_d: boolean} = { - has_d1: 'd1' in this, - is_d: this instanceof D, - }; - delete obj.has_d1; - // foo - }; - - #private_method(a2: number, c2: any) { - throw new Error(`${this.d1} - multiline - etc ${a2 + c2} - `); - } - - *generator() { - yield 1; - yield* [2, 3]; - } - - async *async_generator() { - yield await Promise.resolve(4); - } - - protected async protected_method(): Promise<void> { - try { - await new Promise((resolve) => setTimeout(resolve, 100)); - if (Math.random() > 0.5) { - console.log(new Date()); // eslint-disable-line no-console - } else if (Math.random() > 0.2) { - console.log('else if branch'); - } else { - console.log('else branch'); - } - } catch (error: unknown) { - console.error(error); - } finally { - console.log('finally block'); - } - } +@some_decorator('example', {option: +true}) class_method(): string +{ return +`Hello, ${this.d1}`; } -// comment +instance_method += (): void => { +/* ... */ +let i = +0; +do { i++; } +while (i +< 3); + +for (const c2 of +this.d1) +{ if +(c2 === +'d') +continue; +if (!c2) +break; +this.#private_method(a, +c2); +} -/* -other comment +switch (this.d1) +{ case +'a': +console.log('case a'); break; case +'b': +case 'c': console.log('case b or c'); +break; +default: +console.log('default'); +} -const comment = false; -*/ +const obj: +{has_d1?: boolean; is_d: +boolean} += { has_d1: +'d1' in +this, is_d: +this instanceof +D, }; delete obj.has_d1; +// foo +}; + +#private_method(a2: +number, c2: +any) +{ throw +new +Error(`${this.d1} multiline etc ${a2 + + c2} `); +} -/** - * JSDoc comment - */ +*generator() +{ yield +1; +yield* +[2, 3]; +} -import {sample_langs, type Sample_Lang} from '../code_sample.js'; -import * as A from '../code_sample.js'; +async *async_generator() { +yield await +Promise.resolve(4); +} -export {a, A, b, c, D}; +protected async +protected_method(): +Promise<void> { +try { +await new +Promise((resolve) +=> setTimeout(resolve, +100)); +if (Math.random() +> 0.5) { +console.log(new +Date()); +// eslint-disable-line no-console +} else +if (Math.random() +> 0.2) { +console.log('else if branch'); } +else { +console.log('else branch'); +} +} catch +(error: +unknown) +{ console.error(error); } +finally { +console.log('finally block'); +} +} +} -sample_langs as unknown as Sample_Lang satisfies Sample_Lang; +// comment -export interface Some_E<T = null> { - name: string; - age: number; - t?: T; +/* other comment const comment = false; */ + +/** * JSDoc comment */ + +import +{sample_langs, +type +Sample_Lang} from +'../code_sample.js'; +import * +as A +from '../code_sample.js'; + +export {a, +A, b, +c, D}; + +sample_langs as +unknown as +Sample_Lang +satisfies +Sample_Lang; + +export interface +Some_E<T + = null> +{ name: +string; age: +number; t?: T; } -const e: {name: string; age: number} = {name: 'A. H.', age: 100}; -const v = [['', e]] as const; -export const some_e: Map<string, Some_E> = new Map(v); - -export function add(x: number, y: number): number { - return x + y; +const e: +{name: +string; age: +number} += {name: +'A. H.', age: +100}; const v += [['', e]] as +const; +export +const some_e: + Map<string, + Some_E> + = new +Map(v); + +export function +add(x: +number, y: +number): number +{ return x ++ y; } -export const plus = (a: any, b: any): any => a + b; +export const +plus = +(a: +any, b: +any): any => a + b; // boundary test cases -export const str_with_keywords = 'const class function string'; -export const str_with_comment = '// this is not a comment'; -export const template_with_expr = `Value: ${1 + 2}`; +export +const str_with_keywords = +'const class function string'; export +const str_with_comment = +'// this is not a comment'; export +const template_with_expr = +`Value: ${1 + + 2}`; // regex that looks like comment -export const regex = /\/\/.*/g; -export const complex_regex = /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/; +export const regex += +/\/\/.*/g; export +const complex_regex = +/^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/; // string in comment should not be highlighted as string // const commented = "this string is in a comment"; diff --git a/src/fixtures/update.task.ts b/src/fixtures/update.task.ts index a3b3cd1a..c6317f30 100644 --- a/src/fixtures/update.task.ts +++ b/src/fixtures/update.task.ts @@ -1,4 +1,5 @@ import type {Task} from '@ryanatkn/gro'; +import {format_file} from '@ryanatkn/gro/format_file.js'; import {writeFileSync, mkdirSync, rmSync, existsSync} from 'node:fs'; import {join, resolve} from 'node:path'; import { @@ -41,9 +42,10 @@ export const task: Task = { const dir = join(generated_fixtures_dir, sample.lang); mkdirSync(dir, {recursive: true}); - // Write HTML file (no formatting needed, already formatted) + // Write HTML file with formatting const html_path = get_fixture_path(sample.lang, sample.variant, 'html'); - writeFileSync(html_path, output.html); + const formatted_html = await format_file(output.html, {filepath: html_path}); + writeFileSync(html_path, formatted_html); console.log(` → ${html_path}`); // eslint-disable-line no-console // Generate and write debug text file From 59e0174d9436251b12eb2bccf2a2e722395e325b Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:21:58 -0400 Subject: [PATCH 40/49] wip --- package.json | 6 ++++++ src/routes/package.ts | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d3bc07a0..6f359d95 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,12 @@ "options": { "useTabs": false } + }, + { + "files": "src/fixtures/generated/**", + "options": { + "requirePragma": true + } } ] }, diff --git a/src/routes/package.ts b/src/routes/package.ts index afc45e66..46d5f6c6 100644 --- a/src/routes/package.ts +++ b/src/routes/package.ts @@ -64,7 +64,10 @@ export const package_json: Package_Json = { printWidth: 100, singleQuote: true, bracketSpacing: false, - overrides: [{files: 'package.json', options: {useTabs: false}}], + overrides: [ + {files: 'package.json', options: {useTabs: false}}, + {files: 'src/fixtures/generated/**', options: {requirePragma: true}}, + ], }, sideEffects: ['**/*.css'], files: ['dist', 'src/lib/**/*.ts', '!src/lib/**/*.test.*', '!dist/**/*.test.*'], From 3c8cf342f6cf16ae5d32793048af7fada364a0b4 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:23:37 -0400 Subject: [PATCH 41/49] wip --- src/fixtures/generated/css/css_complex.html | 70 +- src/fixtures/generated/html/html_complex.html | 287 +------ src/fixtures/generated/json/json_complex.html | 56 +- .../generated/svelte/svelte_complex.html | 709 +++--------------- src/fixtures/generated/ts/ts_complex.html | 577 ++++---------- src/fixtures/update.task.ts | 6 +- 6 files changed, 313 insertions(+), 1392 deletions(-) diff --git a/src/fixtures/generated/css/css_complex.html b/src/fixtures/generated/css/css_complex.html index 0b7e5b10..b6f51f53 100644 --- a/src/fixtures/generated/css/css_complex.html +++ b/src/fixtures/generated/css/css_complex.html @@ -1,73 +1,45 @@ .some_class { -color: red; + color: red; } .hypen-class { -font-size: 16px; + font-size: 16px; } p { -box-shadow: 0 0 10px -rgba(0, -0, 0, 0.1); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } /* comment */ -/* multi .line { i: 100px </style> @media*/ +/* +multi +.line { + i: 100px + +</style> + +@media*/ #id { -background-color: blue; + background-color: blue; } div > p { -margin: 10px; + margin: 10px; } -@media (max-width: 600px) -{ body -{ background-color: light-dark(lightblue, -darkblue); -} +@media (max-width: 600px) { + body { + background-color: light-dark(lightblue, darkblue); + } } .content::before { -/* prettier-ignore */ -content: -"</style> /* not a comment */"; + /* prettier-ignore */ + content: "</style> /* not a comment */"; } -.attr[title='Click: here'] -{ background-image: -url('data:image/svg+xml...'); +.attr[title='Click: here'] { + background-image: url('data:image/svg+xml...'); } diff --git a/src/fixtures/generated/html/html_complex.html b/src/fixtures/generated/html/html_complex.html index ce771067..90084059 100644 --- a/src/fixtures/generated/html/html_complex.html +++ b/src/fixtures/generated/html/html_complex.html @@ -1,275 +1,42 @@ <!doctype html> -<div - class="test"> -<p>hello world!</p> -</div> +<div class="test"> + <p>hello world!</p> +</div> -<p - class="some_class hypen-class">some -<span - class="a b c">text</span></p> +<p class="some_class hypen-class">some <span class="a b c">text</span></p> -<button - type="button" - disabled>click me</button> +<button type="button" disabled>click me</button> <!-- comment <div>a<br /> b</div> <script> --> -<br - /> +<br /> -<hr - onclick="console.log('hi')" - /> +<hr onclick="console.log('hi')" /> -<img - src="image.jpg" - alt="access" - /> +<img src="image.jpg" alt="access" /> -<ul> -<li>list item 1</li> -<li>list item 2</li> -</ul> +<ul> + <li>list item 1</li> + <li>list item 2</li> +</ul> -<form - action="/submit" - method="post"> -<input - type="text" - name="username" - placeholder="Enter name" - /> -<select - name="option" - data-role="dropdown"> -<option - value="1">First</option> -<option - value="2">Second</option> -</select> -</form> +<form action="/submit" method="post"> + <input type="text" name="username" placeholder="Enter name" /> + <select name="option" data-role="dropdown"> + <option value="1">First</option> + <option value="2">Second</option> + </select> +</form> -<script> - const ok = - '<style>'; - </script> +<script> + const ok = '<style>'; +</script> -<style - type="text/css"> - .special::before { - content: - '< & >'; - } - </style> +<style type="text/css"> + .special::before { + content: '< & >'; + } +</style> <![CDATA[ if (a < 0) alert("b"); <not-a-tag> ]]> diff --git a/src/fixtures/generated/json/json_complex.html b/src/fixtures/generated/json/json_complex.html index eb9f4e5b..7e3dd385 100644 --- a/src/fixtures/generated/json/json_complex.html +++ b/src/fixtures/generated/json/json_complex.html @@ -1,44 +1,14 @@ -{ "string": "a string", "number": 12345, "boolean": true, "null": null, "empty": "", "escaped": -"quote: \"test\" and backslash: \\", "object": { -"array": -[1, "b", false], -"strings": -["1", "2", "3"], -"mixed": -["start", 123, true, "middle", null, "end"], -"nested": -[["a", -"str", -""], {"key": -"nested value"}] -} +{ + "string": "a string", + "number": 12345, + "boolean": true, + "null": null, + "empty": "", + "escaped": "quote: \"test\" and backslash: \\", + "object": { + "array": [1, "b", false], + "strings": ["1", "2", "3"], + "mixed": ["start", 123, true, "middle", null, "end"], + "nested": [["a", "str", ""], {"key": "nested value"}] + } } diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index abf33c33..be8c274a 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -1,599 +1,138 @@ -<script - lang="ts" - module> - export const - HELLO = - 'world'; - </script> - -<script - lang="ts"> - // @ts-expect-error - import - Thing - from - '$lib/Thing.svelte'; - import type - {Snippet} from - 'svelte'; - - const { thing, - bound = $bindable(true), children, - onclick, }: { thing: - Record<string, any>; bound?: boolean; children: - Snippet; onclick?: () => - void; - } = - $props(); - - const thing_keys = - $derived(Object.entries(thing)); - - const a = - 1; - - const b = - 'b'; - - let c: boolean = $state(true); - - const - f = - (p: - any) - => p; - - const - attachment - = (_p1: - string, _p2: - number) - => (el: - HTMLElement) => - { element_ref - !== el; - }; - - let value = - $state(thing['']); - let element_ref: - HTMLElement; - </script> - -<h1 - bind:this={element_ref}>hello -{HELLO}!</h1> - -{#each thing_keys - as - [k, - { t, u - }] - (f(k))} -{@const - v = - Math.round(t[k - + f(u)])} -{f(v)} -{/each} - -{#if - f(c)} -<Thing - string_prop="a - {f('s')} - b" number_prop={f(1)} - /> -{:else if - f(a - > 0)} -bigger -{:else} -<Thing - string_prop="b" - onthing={() - => (c - = f(!c))}> -{@render - children()} -</Thing> -{/if} - -{@html - '<strong>raw html</strong>'} - -<input - bind:value - type="text" - class:active={c} - /> - -<span - {@attach - attachment('param', - f(42))}>...</span> - -{@render - my_snippet('p')} - -{#snippet - my_snippet(p: - string)} -<button - {onclick}>{p}</button> -{/snippet} - -<p - class="some_class - hypen-class" - id="unique_id"> -some -<span - class="a b c">text</span> -</p> - -<button - type="button" - disabled> -click me -</button> +<script lang="ts" module> + export const HELLO = 'world'; +</script> + +<script lang="ts"> + // @ts-expect-error + import Thing from '$lib/Thing.svelte'; + import type {Snippet} from 'svelte'; + + const { + thing, + bound = $bindable(true), + children, + onclick, + }: { + thing: Record<string, any>; + bound?: boolean; + children: Snippet; + onclick?: () => void; + } = $props(); + + const thing_keys = $derived(Object.entries(thing)); + + const a = 1; + + const b = 'b'; + + let c: boolean = $state(true); + + const f = (p: any) => p; + + const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { + element_ref !== el; + }; + + let value = $state(thing['']); + let element_ref: HTMLElement; +</script> + +<h1 bind:this={element_ref}>hello {HELLO}!</h1> + +{#each thing_keys as [k, { t, u }] (f(k))} + {@const v = Math.round(t[k + f(u)])} + {f(v)} +{/each} + +{#if f(c)} + <Thing string_prop="a {f('s')} b" number_prop={f(1)} /> +{:else if f(a > 0)} + bigger +{:else} + <Thing string_prop="b" onthing={() => (c = f(!c))}> + {@render children()} + </Thing> +{/if} + +{@html '<strong>raw html</strong>'} + +<input bind:value type="text" class:active={c} /> + +<span {@attach attachment('param', f(42))}>...</span> + +{@render my_snippet('p')} + +{#snippet my_snippet(p: string)} + <button {onclick}>{p}</button> +{/snippet} + +<p class="some_class hypen-class" id="unique_id"> + some <span class="a b c">text</span> +</p> + +<button type="button" disabled> click me </button> <!-- comment <div>a<br /> {b}</div> --> -{b.repeat(2)} -{bound} - -<br - /> - -<hr - /> - -<img - src="image.jpg" - alt="access" - /> - -<ul> -<li>list item 1</li> -<li>list item 2</li> -</ul> +{b.repeat(2)} +{bound} + +<br /> + +<hr /> + +<img src="image.jpg" alt="access" /> + +<ul> + <li>list item 1</li> + <li>list item 2</li> +</ul> <!-- embedded tags for boundary testing --> -<div> -<script> - const inline_js = - 'no lang attr'; - </script> -<style> +<div> + <script> + const inline_js = 'no lang attr'; + </script> + <style> .inline { - color: blue; - } - </style> -</div> - -<style> - .some_class { - color: red; + color: blue; } + </style> +</div> - .hypen-class { - font-size: 16px; - } +<style> + .some_class { + color: red; + } - p { - box-shadow: 0 0 10px - rgba(0, - 0, 0, 0.1); - } + .hypen-class { + font-size: 16px; + } - /* comment */ + p { + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + } - /* multi line <comment> */ + /* comment */ - #unique_id { - background-color: blue; - } + /* + multi + line - @media (max-width: 600px) - { :global(body) - { background-color: light-dark(lightblue, - darkblue); - } - } + <comment> + + */ - :global(.escapehatch)::before - { content: '< & >'; + #unique_id { + background-color: blue; + } + + @media (max-width: 600px) { + :global(body) { + background-color: light-dark(lightblue, darkblue); } - </style> + } + + :global(.escapehatch)::before { + content: '< & >'; + } +</style> diff --git a/src/fixtures/generated/ts/ts_complex.html b/src/fixtures/generated/ts/ts_complex.html index 1d19ad06..9faaf5ef 100644 --- a/src/fixtures/generated/ts/ts_complex.html +++ b/src/fixtures/generated/ts/ts_complex.html @@ -1,475 +1,150 @@ -const a = -1; - -const b: string = 'b'; - -const c = -true; - -export type -Some_Type -= 1 -| 'b' -| true; - -declare -const some_decorator: -any; - -abstract class -Base -{ abstract -abstract_method(): -void; -} +const a = 1; -@some_decorator -class -D -extends -Base -{ readonly d1: string = 'd'; d2: -number; d3 -= $state(null); - -@some_decorator -decorated = true; - -constructor(d2: -number) -{ super(); this.d2 = d2; -} +const b: string = 'b'; -abstract_method(): -void { -// implementation -} +const c = true; -@some_decorator('example', {option: -true}) class_method(): string -{ return -`Hello, ${this.d1}`; -} +export type Some_Type = 1 | 'b' | true; -instance_method -= (): void => { -/* ... */ -let i = -0; -do { i++; } -while (i -< 3); - -for (const c2 of -this.d1) -{ if -(c2 === -'d') -continue; -if (!c2) -break; -this.#private_method(a, -c2); -} +declare const some_decorator: any; -switch (this.d1) -{ case -'a': -console.log('case a'); break; case -'b': -case 'c': console.log('case b or c'); -break; -default: -console.log('default'); +abstract class Base { + abstract abstract_method(): void; } -const obj: -{has_d1?: boolean; is_d: -boolean} -= { has_d1: -'d1' in -this, is_d: -this instanceof -D, }; delete obj.has_d1; -// foo -}; - -#private_method(a2: -number, c2: -any) -{ throw -new -Error(`${this.d1} multiline etc ${a2 - + c2} `); +@some_decorator +class D extends Base { + readonly d1: string = 'd'; + d2: number; + d3 = $state(null); + + @some_decorator + decorated = true; + + constructor(d2: number) { + super(); + this.d2 = d2; + } + + abstract_method(): void { + // implementation + } + + @some_decorator('example', {option: true}) + class_method(): string { + return `Hello, ${this.d1}`; + } + + instance_method = (): void => { + /* ... */ + let i = 0; + do { + i++; + } while (i < 3); + + for (const c2 of this.d1) { + if (c2 === 'd') continue; + if (!c2) break; + this.#private_method(a, c2); + } + + switch (this.d1) { + case 'a': + console.log('case a'); + break; + case 'b': + case 'c': + console.log('case b or c'); + break; + default: + console.log('default'); + } + + const obj: {has_d1?: boolean; is_d: boolean} = { + has_d1: 'd1' in this, + is_d: this instanceof D, + }; + delete obj.has_d1; + // foo + }; + + #private_method(a2: number, c2: any) { + throw new Error(`${this.d1} + multiline + etc ${a2 + c2} + `); + } + + *generator() { + yield 1; + yield* [2, 3]; + } + + async *async_generator() { + yield await Promise.resolve(4); + } + + protected async protected_method(): Promise<void> { + try { + await new Promise((resolve) => setTimeout(resolve, 100)); + if (Math.random() > 0.5) { + console.log(new Date()); // eslint-disable-line no-console + } else if (Math.random() > 0.2) { + console.log('else if branch'); + } else { + console.log('else branch'); + } + } catch (error: unknown) { + console.error(error); + } finally { + console.log('finally block'); + } + } } -*generator() -{ yield -1; -yield* -[2, 3]; -} +// comment -async *async_generator() { -yield await -Promise.resolve(4); -} +/* +other comment -protected async -protected_method(): -Promise<void> { -try { -await new -Promise((resolve) -=> setTimeout(resolve, -100)); -if (Math.random() -> 0.5) { -console.log(new -Date()); -// eslint-disable-line no-console -} else -if (Math.random() -> 0.2) { -console.log('else if branch'); } -else { -console.log('else branch'); -} -} catch -(error: -unknown) -{ console.error(error); } -finally { -console.log('finally block'); -} -} -} +const comment = false; +*/ -// comment +/** + * JSDoc comment + */ -/* other comment const comment = false; */ - -/** * JSDoc comment */ - -import -{sample_langs, -type -Sample_Lang} from -'../code_sample.js'; -import * -as A -from '../code_sample.js'; - -export {a, -A, b, -c, D}; - -sample_langs as -unknown as -Sample_Lang -satisfies -Sample_Lang; - -export interface -Some_E<T - = null> -{ name: -string; age: -number; t?: T; +import {sample_langs, type Sample_Lang} from '../code_sample.js'; +import * as A from '../code_sample.js'; + +export {a, A, b, c, D}; + +sample_langs as unknown as Sample_Lang satisfies Sample_Lang; + +export interface Some_E<T = null> { + name: string; + age: number; + t?: T; } -const e: -{name: -string; age: -number} -= {name: -'A. H.', age: -100}; const v -= [['', e]] as -const; -export -const some_e: - Map<string, - Some_E> - = new -Map(v); - -export function -add(x: -number, y: -number): number -{ return x -+ y; +const e: {name: string; age: number} = {name: 'A. H.', age: 100}; +const v = [['', e]] as const; +export const some_e: Map<string, Some_E> = new Map(v); + +export function add(x: number, y: number): number { + return x + y; } -export const -plus = -(a: -any, b: -any): any => a + b; +export const plus = (a: any, b: any): any => a + b; // boundary test cases -export -const str_with_keywords = -'const class function string'; export -const str_with_comment = -'// this is not a comment'; export -const template_with_expr = -`Value: ${1 + - 2}`; +export const str_with_keywords = 'const class function string'; +export const str_with_comment = '// this is not a comment'; +export const template_with_expr = `Value: ${1 + 2}`; // regex that looks like comment -export const regex -= -/\/\/.*/g; export -const complex_regex = -/^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/; +export const regex = /\/\/.*/g; +export const complex_regex = /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/; // string in comment should not be highlighted as string // const commented = "this string is in a comment"; diff --git a/src/fixtures/update.task.ts b/src/fixtures/update.task.ts index c6317f30..a3b3cd1a 100644 --- a/src/fixtures/update.task.ts +++ b/src/fixtures/update.task.ts @@ -1,5 +1,4 @@ import type {Task} from '@ryanatkn/gro'; -import {format_file} from '@ryanatkn/gro/format_file.js'; import {writeFileSync, mkdirSync, rmSync, existsSync} from 'node:fs'; import {join, resolve} from 'node:path'; import { @@ -42,10 +41,9 @@ export const task: Task = { const dir = join(generated_fixtures_dir, sample.lang); mkdirSync(dir, {recursive: true}); - // Write HTML file with formatting + // Write HTML file (no formatting needed, already formatted) const html_path = get_fixture_path(sample.lang, sample.variant, 'html'); - const formatted_html = await format_file(output.html, {filepath: html_path}); - writeFileSync(html_path, formatted_html); + writeFileSync(html_path, output.html); console.log(` → ${html_path}`); // eslint-disable-line no-console // Generate and write debug text file From 0eb0f792e91de07e6362907013883af15d60ad5f Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:27:00 -0400 Subject: [PATCH 42/49] wip --- src/lib/highlight_priorities.gen.ts | 2 +- src/lib/highlight_priorities.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/highlight_priorities.gen.ts b/src/lib/highlight_priorities.gen.ts index 446cdec0..747b51b6 100644 --- a/src/lib/highlight_priorities.gen.ts +++ b/src/lib/highlight_priorities.gen.ts @@ -57,7 +57,7 @@ export const gen: Gen = ({origin_path}) => { export type Highlight_Token_Name = ${token_names}; -export const highlight_priorities: Record = { +export const highlight_priorities: Record = { ${priority_entries}, } as const; diff --git a/src/lib/highlight_priorities.ts b/src/lib/highlight_priorities.ts index 4ff99978..f48a6aff 100644 --- a/src/lib/highlight_priorities.ts +++ b/src/lib/highlight_priorities.ts @@ -40,7 +40,7 @@ export type Highlight_Token_Name = | 'cdata' | 'punctuation'; -export const highlight_priorities: Record = { +export const highlight_priorities: Record = { namespace: 1, tag: 2, constant: 2, From 9d89b5fe102d88c415194df15f159ddfc2df2cb9 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:34:56 -0400 Subject: [PATCH 43/49] wip --- .../generated/svelte/svelte_complex.html | 5 +- .../generated/svelte/svelte_complex.txt | 1056 +++++++-------- src/fixtures/generated/ts/ts_complex.html | 10 +- src/fixtures/generated/ts/ts_complex.txt | 1158 +++++++++-------- src/lib/highlight_priorities.gen.ts | 4 +- src/lib/samples/all.ts | 15 +- src/lib/samples/sample_complex.svelte | 5 +- src/lib/samples/sample_complex.ts | 10 +- 8 files changed, 1148 insertions(+), 1115 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index be8c274a..011b4782 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -21,7 +21,7 @@ const thing_keys = $derived(Object.entries(thing)); - const a = 1; + const a = 1 as number; const b = 'b'; @@ -54,6 +54,7 @@ </Thing> {/if} +<!-- eslint-disable-next-line svelte/no-at-html-tags --> {@html '<strong>raw html</strong>'} <input bind:value type="text" class:active={c} /> @@ -63,7 +64,7 @@ {@render my_snippet('p')} {#snippet my_snippet(p: string)} - <button {onclick}>{p}</button> + <button type="button" {onclick}>{p}</button> {/snippet} <p class="some_class hypen-class" id="unique_id"> diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 1476f6db..26048b81 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -1,25 +1,25 @@ === STATS === -Sample length: 2168 characters -Total tokens: 623 +Sample length: 2249 characters +Total tokens: 631 Token types (32 unique): - punctuation: 295 + punctuation: 298 tag: 74 operator: 37 svelte_expression: 24 lang_ts: 23 function: 23 - attr_name: 19 + attr_name: 20 keyword: 19 - special_keyword: 13 + special_keyword: 14 + attr_value: 11 string: 11 - attr_value: 10 + builtin: 9 capitalized_identifier: 8 - builtin: 8 property: 8 block: 7 selector: 7 - comment: 5 + comment: 6 number: 5 at_directive: 5 script: 3 @@ -68,8 +68,8 @@ Token types (32 unique): 81-82 punctuation " 84-85 punctuation " 85-86 punctuation > - 86-680 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n - 86-680 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n + 86-690 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1 as number;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n + 86-690 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1 as number;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n 88-107 comment // @ts-expect-error 109-115 special_keyword import 116-121 capitalized_identifier Thing @@ -140,523 +140,531 @@ Token types (32 unique): 426-431 keyword const 434-435 operator = 436-437 number 1 - 437-438 punctuation ; - 441-446 keyword const - 449-450 operator = - 451-454 string 'b' - 454-455 punctuation ; - 458-461 keyword let - 463-473 type_annotation : boolean - 463-464 : : - 464-473 type boolean - 465-472 builtin boolean - 473-474 operator = - 475-481 function $state - 481-482 punctuation ( - 482-486 boolean true - 486-487 punctuation ) - 487-488 punctuation ; - 491-496 keyword const - 497-498 function_variable f - 499-500 operator = - 501-502 punctuation ( - 503-504 operator : - 505-508 builtin any - 508-509 punctuation ) - 510-512 operator => - 514-515 punctuation ; - 518-523 keyword const - 524-534 function_variable attachment - 535-536 operator = - 537-538 punctuation ( - 541-542 operator : - 543-549 builtin string - 549-550 punctuation , - 554-555 operator : - 556-562 builtin number - 562-563 punctuation ) - 564-566 operator => - 567-568 punctuation ( - 570-571 operator : - 572-583 capitalized_identifier HTMLElement - 583-584 punctuation ) - 585-587 operator => - 588-589 punctuation { - 604-607 operator !== - 610-611 punctuation ; - 613-614 punctuation } - 614-615 punctuation ; - 618-621 keyword let - 628-629 operator = - 630-636 function $state - 636-637 punctuation ( - 642-643 punctuation [ - 643-645 string '' - 645-646 punctuation ] - 646-647 punctuation ) - 647-648 punctuation ; - 650-653 keyword let - 665-666 operator : - 667-678 capitalized_identifier HTMLElement - 678-679 punctuation ; - 680-689 tag - 680-688 tag - 691-719 tag

    - 691-694 tag

    - 725-732 svelte_expression {HELLO} - 725-726 punctuation { - 726-731 lang_ts HELLO - 726-731 constant HELLO - 731-732 punctuation } - 733-738 tag

    - 733-737 tag - 740-782 svelte_expression {#each thing_keys as [k, { t, u }] (f(k))} - 740-782 each {#each thing_keys as [k, { t, u }] (f(k))} - 740-741 punctuation { - 741-746 special_keyword #each - 758-760 keyword as - 761-782 lang_ts [k, { t, u }] (f(k))} - 761-762 punctuation [ - 763-764 punctuation , - 765-766 punctuation { - 768-769 punctuation , - 772-773 punctuation } - 773-774 punctuation ] - 775-776 punctuation ( - 776-777 function f - 777-778 punctuation ( - 779-780 punctuation ) - 780-781 punctuation ) - 781-782 punctuation } - 784-820 svelte_expression {@const v = Math.round(t[k + f(u)])} - 784-820 at_directive {@const v = Math.round(t[k + f(u)])} - 784-785 punctuation { - 785-791 keyword @const - 792-820 lang_ts v = Math.round(t[k + f(u)])} - 794-795 operator = - 796-800 capitalized_identifier Math - 800-801 punctuation . - 801-806 function round - 806-807 punctuation ( - 808-809 punctuation [ - 811-812 operator + - 813-814 function f - 814-815 punctuation ( - 816-817 punctuation ) - 817-818 punctuation ] - 818-819 punctuation ) - 819-820 punctuation } - 822-828 svelte_expression {f(v)} - 822-823 punctuation { - 823-827 lang_ts f(v) + 438-440 special_keyword as + 441-447 builtin number + 447-448 punctuation ; + 451-456 keyword const + 459-460 operator = + 461-464 string 'b' + 464-465 punctuation ; + 468-471 keyword let + 473-483 type_annotation : boolean + 473-474 : : + 474-483 type boolean + 475-482 builtin boolean + 483-484 operator = + 485-491 function $state + 491-492 punctuation ( + 492-496 boolean true + 496-497 punctuation ) + 497-498 punctuation ; + 501-506 keyword const + 507-508 function_variable f + 509-510 operator = + 511-512 punctuation ( + 513-514 operator : + 515-518 builtin any + 518-519 punctuation ) + 520-522 operator => + 524-525 punctuation ; + 528-533 keyword const + 534-544 function_variable attachment + 545-546 operator = + 547-548 punctuation ( + 551-552 operator : + 553-559 builtin string + 559-560 punctuation , + 564-565 operator : + 566-572 builtin number + 572-573 punctuation ) + 574-576 operator => + 577-578 punctuation ( + 580-581 operator : + 582-593 capitalized_identifier HTMLElement + 593-594 punctuation ) + 595-597 operator => + 598-599 punctuation { + 614-617 operator !== + 620-621 punctuation ; + 623-624 punctuation } + 624-625 punctuation ; + 628-631 keyword let + 638-639 operator = + 640-646 function $state + 646-647 punctuation ( + 652-653 punctuation [ + 653-655 string '' + 655-656 punctuation ] + 656-657 punctuation ) + 657-658 punctuation ; + 660-663 keyword let + 675-676 operator : + 677-688 capitalized_identifier HTMLElement + 688-689 punctuation ; + 690-699 tag + 690-698 tag + 701-729 tag

    + 701-704 tag

    + 735-742 svelte_expression {HELLO} + 735-736 punctuation { + 736-741 lang_ts HELLO + 736-741 constant HELLO + 741-742 punctuation } + 743-748 tag

    + 743-747 tag + 750-792 svelte_expression {#each thing_keys as [k, { t, u }] (f(k))} + 750-792 each {#each thing_keys as [k, { t, u }] (f(k))} + 750-751 punctuation { + 751-756 special_keyword #each + 768-770 keyword as + 771-792 lang_ts [k, { t, u }] (f(k))} + 771-772 punctuation [ + 773-774 punctuation , + 775-776 punctuation { + 778-779 punctuation , + 782-783 punctuation } + 783-784 punctuation ] + 785-786 punctuation ( + 786-787 function f + 787-788 punctuation ( + 789-790 punctuation ) + 790-791 punctuation ) + 791-792 punctuation } + 794-830 svelte_expression {@const v = Math.round(t[k + f(u)])} + 794-830 at_directive {@const v = Math.round(t[k + f(u)])} + 794-795 punctuation { + 795-801 keyword @const + 802-830 lang_ts v = Math.round(t[k + f(u)])} + 804-805 operator = + 806-810 capitalized_identifier Math + 810-811 punctuation . + 811-816 function round + 816-817 punctuation ( + 818-819 punctuation [ + 821-822 operator + 823-824 function f 824-825 punctuation ( 826-827 punctuation ) - 827-828 punctuation } - 829-836 svelte_expression {/each} - 829-836 block {/each} - 829-830 punctuation { - 830-835 special_keyword /each - 835-836 punctuation } - 838-848 svelte_expression {#if f(c)} - 838-848 block {#if f(c)} - 838-839 punctuation { - 839-842 special_keyword #if - 842-847 lang_ts f(c) - 843-844 function f - 844-845 punctuation ( - 846-847 punctuation ) - 847-848 punctuation } - 850-905 tag - 850-856 tag - 906-925 svelte_expression {:else if f(a > 0)} - 906-925 block {:else if f(a > 0)} + 827-828 punctuation ] + 828-829 punctuation ) + 829-830 punctuation } + 832-838 svelte_expression {f(v)} + 832-833 punctuation { + 833-837 lang_ts f(v) + 833-834 function f + 834-835 punctuation ( + 836-837 punctuation ) + 837-838 punctuation } + 839-846 svelte_expression {/each} + 839-846 block {/each} + 839-840 punctuation { + 840-845 special_keyword /each + 845-846 punctuation } + 848-858 svelte_expression {#if f(c)} + 848-858 block {#if f(c)} + 848-849 punctuation { + 849-852 special_keyword #if + 852-857 lang_ts f(c) + 853-854 function f + 854-855 punctuation ( + 856-857 punctuation ) + 857-858 punctuation } + 860-915 tag + 860-866 tag 0) - 916-917 function f - 917-918 punctuation ( - 920-921 operator > - 922-923 number 0 - 923-924 punctuation ) - 924-925 punctuation } - 934-941 svelte_expression {:else} - 934-941 block {:else} - 934-935 punctuation { - 935-940 special_keyword :else - 940-941 punctuation } - 943-994 tag (c = f(!c))}> - 943-949 tag (c = f(!c))} - 974-975 punctuation { - 975-992 lang_ts () => (c = f(!c)) - 975-976 punctuation ( - 976-977 punctuation ) - 978-980 operator => - 981-982 punctuation ( - 984-985 operator = - 986-987 function f - 987-988 punctuation ( - 988-989 operator ! - 990-991 punctuation ) - 991-992 punctuation ) - 992-993 punctuation } - 993-994 punctuation > - 997-1017 svelte_expression {@render children()} - 997-1017 at_directive {@render children()} - 997-998 punctuation { - 998-1005 keyword @render -1006-1017 lang_ts children()} -1006-1014 function children -1014-1015 punctuation ( -1015-1016 punctuation ) -1016-1017 punctuation } -1019-1027 tag -1019-1026 tag -1028-1033 svelte_expression {/if} -1028-1033 block {/if} -1028-1029 punctuation { -1029-1032 special_keyword /if -1032-1033 punctuation } -1035-1070 svelte_expression {@html 'raw html'} -1035-1070 at_directive {@html 'raw html'} -1035-1036 punctuation { -1036-1041 keyword @html -1042-1070 lang_ts 'raw html'} -1042-1069 string 'raw html' -1069-1070 punctuation } -1072-1121 tag -1072-1078 tag -1123-1166 tag -1123-1128 tag -1169-1176 tag -1169-1175 tag -1178-1203 svelte_expression {@render my_snippet('p')} -1178-1203 at_directive {@render my_snippet('p')} -1178-1179 punctuation { -1179-1186 keyword @render -1187-1203 lang_ts my_snippet('p')} -1187-1197 function my_snippet -1197-1198 punctuation ( -1198-1201 string 'p' -1201-1202 punctuation ) -1202-1203 punctuation } -1205-1237 svelte_expression {#snippet my_snippet(p: string)} -1205-1237 block {#snippet my_snippet(p: string)} -1205-1206 punctuation { -1206-1214 special_keyword #snippet -1214-1236 lang_ts my_snippet(p: string) -1215-1225 function my_snippet -1225-1226 punctuation ( -1227-1228 operator : -1229-1235 builtin string -1235-1236 punctuation ) -1236-1237 punctuation } -1239-1257 tag -1260-1268 tag -1270-1280 svelte_expression {/snippet} -1270-1280 block {/snippet} -1270-1271 punctuation { -1271-1279 special_keyword /snippet -1279-1280 punctuation } -1282-1331 tag

    -1282-1284 tag

    + 916-935 svelte_expression {:else if f(a > 0)} + 916-935 block {:else if f(a > 0)} + 916-917 punctuation { + 917-925 special_keyword :else if + 925-934 lang_ts f(a > 0) + 926-927 function f + 927-928 punctuation ( + 930-931 operator > + 932-933 number 0 + 933-934 punctuation ) + 934-935 punctuation } + 944-951 svelte_expression {:else} + 944-951 block {:else} + 944-945 punctuation { + 945-950 special_keyword :else + 950-951 punctuation } + 953-1004 tag (c = f(!c))}> + 953-959 tag (c = f(!c))} + 984-985 punctuation { + 985-1002 lang_ts () => (c = f(!c)) + 985-986 punctuation ( + 986-987 punctuation ) + 988-990 operator => + 991-992 punctuation ( + 994-995 operator = + 996-997 function f + 997-998 punctuation ( + 998-999 operator ! +1000-1001 punctuation ) +1001-1002 punctuation ) +1002-1003 punctuation } +1003-1004 punctuation > +1007-1027 svelte_expression {@render children()} +1007-1027 at_directive {@render children()} +1007-1008 punctuation { +1008-1015 keyword @render +1016-1027 lang_ts children()} +1016-1024 function children +1024-1025 punctuation ( +1025-1026 punctuation ) +1026-1027 punctuation } +1029-1037 tag +1029-1036 tag +1038-1043 svelte_expression {/if} +1038-1043 block {/if} +1038-1039 punctuation { +1039-1042 special_keyword /if +1042-1043 punctuation } +1045-1101 comment +1102-1137 svelte_expression {@html 'raw html'} +1102-1137 at_directive {@html 'raw html'} +1102-1103 punctuation { +1103-1108 keyword @html +1109-1137 lang_ts 'raw html'} +1109-1136 string 'raw html' +1136-1137 punctuation } +1139-1188 tag +1139-1145 tag +1190-1233 tag +1190-1195 tag +1236-1243 tag +1236-1242 tag +1245-1270 svelte_expression {@render my_snippet('p')} +1245-1270 at_directive {@render my_snippet('p')} +1245-1246 punctuation { +1246-1253 keyword @render +1254-1270 lang_ts my_snippet('p')} +1254-1264 function my_snippet +1264-1265 punctuation ( +1265-1268 string 'p' +1268-1269 punctuation ) +1269-1270 punctuation } +1272-1304 svelte_expression {#snippet my_snippet(p: string)} +1272-1304 block {#snippet my_snippet(p: string)} +1272-1273 punctuation { +1273-1281 special_keyword #snippet +1281-1303 lang_ts my_snippet(p: string) +1282-1292 function my_snippet +1292-1293 punctuation ( +1294-1295 operator : +1296-1302 builtin string +1302-1303 punctuation ) +1303-1304 punctuation } +1306-1338 tag -1417-1425 tag -1428-1467 comment -1468-1481 svelte_expression {b.repeat(2)} -1468-1469 punctuation { -1469-1480 lang_ts b.repeat(2) -1470-1471 punctuation . -1471-1477 function repeat -1477-1478 punctuation ( -1478-1479 number 2 -1479-1480 punctuation ) -1480-1481 punctuation } -1482-1489 svelte_expression {bound} -1482-1483 punctuation { -1483-1488 lang_ts bound -1488-1489 punctuation } -1491-1497 tag
    -1491-1494 tag
    -1499-1505 tag


    -1499-1502 tag
    -1507-1543 tag access -1507-1511 tag -1545-1549 tag
      -1545-1548 tag
        -1551-1555 tag
      • -1551-1554 tag
      • -1566-1571 tag
      • -1566-1570 tag -1573-1577 tag
      • -1573-1576 tag
      • -1588-1593 tag
      • -1588-1592 tag -1594-1599 tag
      -1594-1598 tag
    -1601-1644 comment -1645-1650 tag
    -1645-1649 tag
    -1652-1660 tag -1698-1706 tag -1709-1716 tag -1750-1757 tag -1759-1765 tag
    -1759-1764 tag
    -1767-1774 tag -2159-2166 tag +1326-1327 punctuation " +1328-1337 svelte_expression {onclick} +1328-1329 punctuation { +1329-1336 lang_ts onclick +1336-1337 punctuation } +1337-1338 punctuation > +1338-1341 svelte_expression {p} +1338-1339 punctuation { +1339-1340 lang_ts p +1340-1341 punctuation } +1341-1350 tag +1341-1349 tag +1351-1361 svelte_expression {/snippet} +1351-1361 block {/snippet} +1351-1352 punctuation { +1352-1360 special_keyword /snippet +1360-1361 punctuation } +1363-1412 tag

    +1363-1365 tag

    +1419-1439 tag +1419-1424 tag +1443-1450 tag +1443-1449 tag +1451-1455 tag

    +1451-1454 tag

    +1457-1488 tag +1498-1506 tag +1509-1548 comment +1549-1562 svelte_expression {b.repeat(2)} +1549-1550 punctuation { +1550-1561 lang_ts b.repeat(2) +1551-1552 punctuation . +1552-1558 function repeat +1558-1559 punctuation ( +1559-1560 number 2 +1560-1561 punctuation ) +1561-1562 punctuation } +1563-1570 svelte_expression {bound} +1563-1564 punctuation { +1564-1569 lang_ts bound +1569-1570 punctuation } +1572-1578 tag
    +1572-1575 tag
    +1580-1586 tag
    +1580-1583 tag
    +1588-1624 tag access +1588-1592 tag +1626-1630 tag
      +1626-1629 tag
        +1632-1636 tag
      • +1632-1635 tag
      • +1647-1652 tag
      • +1647-1651 tag +1654-1658 tag
      • +1654-1657 tag
      • +1669-1674 tag
      • +1669-1673 tag +1675-1680 tag
      +1675-1679 tag
    +1682-1725 comment +1726-1731 tag
    +1726-1730 tag
    +1733-1741 tag +1779-1787 tag +1790-1797 tag +1831-1838 tag +1840-1846 tag
    +1840-1845 tag
    +1848-1855 tag +2240-2247 tag diff --git a/src/fixtures/generated/ts/ts_complex.html b/src/fixtures/generated/ts/ts_complex.html index 9faaf5ef..4eb31e46 100644 --- a/src/fixtures/generated/ts/ts_complex.html +++ b/src/fixtures/generated/ts/ts_complex.html @@ -12,6 +12,8 @@ abstract abstract_method(): void; } +/* eslint-disable no-console */ + @some_decorator class D extends Base { readonly d1: string = 'd'; @@ -68,19 +70,19 @@ // foo }; - #private_method(a2: number, c2: any) { + #private_method(a2: number, c2: any): void { throw new Error(`${this.d1} multiline etc ${a2 + c2} `); } - *generator() { + *generator(): Generator<number | Array<number>> { yield 1; yield* [2, 3]; } - async *async_generator() { + async *async_generator(): AsyncGenerator<number> { yield await Promise.resolve(4); } @@ -88,7 +90,7 @@ try { await new Promise((resolve) => setTimeout(resolve, 100)); if (Math.random() > 0.5) { - console.log(new Date()); // eslint-disable-line no-console + console.log(new Date()); } else if (Math.random() > 0.2) { console.log('else if branch'); } else { diff --git a/src/fixtures/generated/ts/ts_complex.txt b/src/fixtures/generated/ts/ts_complex.txt index e0d4c1a5..c7d2722e 100644 --- a/src/fixtures/generated/ts/ts_complex.txt +++ b/src/fixtures/generated/ts/ts_complex.txt @@ -1,16 +1,16 @@ === STATS === -Sample length: 2821 characters -Total tokens: 616 +Sample length: 2885 characters +Total tokens: 632 Token types (27 unique): punctuation: 233 - operator: 81 - keyword: 55 + operator: 90 + keyword: 56 special_keyword: 48 - builtin: 31 + builtin: 34 function: 26 string: 25 - capitalized_identifier: 17 + capitalized_identifier: 20 number: 14 class_name: 11 comment: 11 @@ -77,574 +77,590 @@ Token types (27 unique): 183-187 keyword void 187-188 punctuation ; 189-190 punctuation } - 192-207 decorator @some_decorator - 192-193 at @ - 193-207 function some_decorator - 208-213 keyword class - 214-215 class_name D - 214-215 constant D - 216-223 keyword extends - 224-228 class_name Base - 224-228 capitalized_identifier Base - 229-230 punctuation { - 232-240 keyword readonly - 243-252 type_annotation : string - 243-244 : : - 244-252 type string - 245-251 builtin string - 252-253 operator = - 254-257 string 'd' - 257-258 punctuation ; - 262-263 operator : - 264-270 builtin number - 270-271 punctuation ; - 276-277 operator = - 278-284 function $state - 284-285 punctuation ( - 285-289 keyword null - 289-290 punctuation ) + 192-223 comment /* eslint-disable no-console */ + 225-240 decorator @some_decorator + 225-226 at @ + 226-240 function some_decorator + 241-246 keyword class + 247-248 class_name D + 247-248 constant D + 249-256 keyword extends + 257-261 class_name Base + 257-261 capitalized_identifier Base + 262-263 punctuation { + 265-273 keyword readonly + 276-285 type_annotation : string + 276-277 : : + 277-285 type string + 278-284 builtin string + 285-286 operator = + 287-290 string 'd' 290-291 punctuation ; - 294-309 decorator @some_decorator - 294-295 at @ - 295-309 function some_decorator - 321-322 operator = - 323-327 boolean true - 327-328 punctuation ; - 331-342 function constructor - 342-343 punctuation ( - 345-346 operator : - 347-353 builtin number - 353-354 punctuation ) - 355-356 punctuation { - 359-364 keyword super - 364-365 punctuation ( - 365-366 punctuation ) - 366-367 punctuation ; - 370-374 keyword this - 374-375 punctuation . - 378-379 operator = - 382-383 punctuation ; - 385-386 punctuation } - 389-404 function abstract_method - 404-405 punctuation ( - 405-406 punctuation ) - 406-407 operator : - 408-412 keyword void - 413-414 punctuation { - 417-434 comment // implementation - 436-437 punctuation } - 440-455 decorator @some_decorator - 440-441 at @ - 441-455 function some_decorator - 455-456 punctuation ( - 456-465 string 'example' - 465-466 punctuation , - 467-468 punctuation { - 474-475 operator : - 476-480 boolean true - 480-481 punctuation } - 481-482 punctuation ) - 484-496 function class_method - 496-497 punctuation ( - 497-498 punctuation ) - 498-499 operator : - 500-506 builtin string - 507-508 punctuation { - 511-517 special_keyword return - 518-537 template_string `Hello, ${this.d1}` - 518-519 template_punctuation ` - 519-526 string Hello, - 526-536 interpolation ${this.d1} - 526-528 interpolation_punctuation ${ - 528-532 keyword this - 532-533 punctuation . - 535-536 interpolation_punctuation } - 536-537 template_punctuation ` - 537-538 punctuation ; - 540-541 punctuation } - 544-559 function_variable instance_method - 560-561 operator = - 562-563 punctuation ( - 563-564 punctuation ) - 564-571 type_annotation : void - 564-565 : : - 565-571 type void - 566-570 keyword void - 571-573 operator => - 574-575 punctuation { - 578-587 comment /* ... */ - 590-593 keyword let - 596-597 operator = - 598-599 number 0 - 599-600 punctuation ; - 603-605 special_keyword do - 606-607 punctuation { - 612-614 operator ++ - 614-615 punctuation ; - 618-619 punctuation } - 620-625 special_keyword while - 626-627 punctuation ( - 629-630 operator < - 631-632 number 3 - 632-633 punctuation ) - 633-634 punctuation ; - 638-641 special_keyword for - 642-643 punctuation ( - 643-648 keyword const - 652-654 keyword of - 655-659 keyword this - 659-660 punctuation . - 662-663 punctuation ) - 664-665 punctuation { - 669-671 special_keyword if - 672-673 punctuation ( - 676-679 operator === - 680-683 string 'd' - 683-684 punctuation ) - 685-693 special_keyword continue - 693-694 punctuation ; - 698-700 special_keyword if - 701-702 punctuation ( - 702-703 operator ! - 705-706 punctuation ) - 707-712 special_keyword break - 712-713 punctuation ; - 717-721 keyword this - 721-722 punctuation . - 722-737 function #private_method - 737-738 punctuation ( - 739-740 punctuation , - 743-744 punctuation ) - 744-745 punctuation ; - 748-749 punctuation } - 753-759 special_keyword switch - 760-761 punctuation ( - 761-765 keyword this - 765-766 punctuation . - 768-769 punctuation ) - 770-771 punctuation { - 775-779 special_keyword case - 780-783 string 'a' - 783-784 operator : - 789-796 builtin console - 796-797 punctuation . - 797-800 function log - 800-801 punctuation ( - 801-809 string 'case a' - 809-810 punctuation ) - 810-811 punctuation ; - 816-821 special_keyword break - 821-822 punctuation ; - 826-830 special_keyword case - 831-834 string 'b' - 834-835 operator : - 839-843 special_keyword case - 844-847 string 'c' - 847-848 operator : - 853-860 builtin console - 860-861 punctuation . - 861-864 function log - 864-865 punctuation ( - 865-878 string 'case b or c' - 878-879 punctuation ) - 879-880 punctuation ; - 885-890 special_keyword break - 890-891 punctuation ; - 895-902 special_keyword default - 902-903 operator : - 908-915 builtin console - 915-916 punctuation . - 916-919 function log - 919-920 punctuation ( - 920-929 string 'default' - 929-930 punctuation ) - 930-931 punctuation ; - 934-935 punctuation } - 939-944 keyword const - 948-949 operator : - 950-951 punctuation { - 957-958 operator ? - 958-959 operator : - 960-967 builtin boolean - 967-968 punctuation ; - 973-974 operator : - 975-982 builtin boolean - 982-983 punctuation } - 984-985 operator = - 986-987 punctuation { - 997-998 operator : - 999-1003 string 'd1' -1004-1006 keyword in -1007-1011 keyword this -1011-1012 punctuation , -1020-1021 operator : -1022-1026 keyword this -1027-1037 keyword instanceof -1038-1039 class_name D -1038-1039 constant D -1039-1040 punctuation , -1043-1044 punctuation } -1044-1045 punctuation ; -1048-1054 keyword delete -1058-1059 punctuation . -1065-1066 punctuation ; -1069-1075 comment // foo -1077-1078 punctuation } -1078-1079 punctuation ; -1082-1097 function #private_method -1097-1098 punctuation ( -1100-1101 operator : -1102-1108 builtin number -1108-1109 punctuation , -1112-1113 operator : -1114-1117 builtin any -1117-1118 punctuation ) -1119-1120 punctuation { -1123-1128 special_keyword throw -1129-1132 keyword new -1133-1138 class_name Error -1133-1138 capitalized_identifier Error -1138-1139 punctuation ( -1139-1185 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` -1139-1140 template_punctuation ` -1140-1150 interpolation ${this.d1} -1140-1142 interpolation_punctuation ${ -1142-1146 keyword this -1146-1147 punctuation . -1149-1150 interpolation_punctuation } -1150-1171 string \n\t\t\tmultiline\n\t\t\tetc -1171-1181 interpolation ${a2 + c2} -1171-1173 interpolation_punctuation ${ -1176-1177 operator + -1180-1181 interpolation_punctuation } -1181-1184 string \n\t\t -1184-1185 template_punctuation ` -1185-1186 punctuation ) -1186-1187 punctuation ; -1189-1190 punctuation } -1193-1194 operator * -1194-1203 function generator -1203-1204 punctuation ( -1204-1205 punctuation ) -1206-1207 punctuation { -1210-1215 special_keyword yield -1216-1217 number 1 -1217-1218 punctuation ; -1221-1226 special_keyword yield -1226-1227 operator * -1228-1229 punctuation [ -1229-1230 number 2 -1230-1231 punctuation , -1232-1233 number 3 -1233-1234 punctuation ] -1234-1235 punctuation ; -1237-1238 punctuation } -1241-1246 keyword async -1247-1248 operator * -1248-1263 function async_generator -1263-1264 punctuation ( -1264-1265 punctuation ) -1266-1267 punctuation { -1270-1275 special_keyword yield -1276-1281 special_keyword await -1282-1289 capitalized_identifier Promise -1289-1290 punctuation . -1290-1297 function resolve -1297-1298 punctuation ( -1298-1299 number 4 -1299-1300 punctuation ) -1300-1301 punctuation ; -1303-1304 punctuation } -1307-1316 keyword protected -1317-1322 keyword async -1323-1339 function protected_method -1339-1340 punctuation ( -1340-1341 punctuation ) -1341-1342 operator : -1343-1350 capitalized_identifier Promise -1350-1351 operator < -1351-1355 keyword void -1355-1356 operator > -1357-1358 punctuation { -1361-1364 special_keyword try -1365-1366 punctuation { -1370-1375 special_keyword await -1376-1379 keyword new -1380-1387 class_name Promise + 295-296 operator : + 297-303 builtin number + 303-304 punctuation ; + 309-310 operator = + 311-317 function $state + 317-318 punctuation ( + 318-322 keyword null + 322-323 punctuation ) + 323-324 punctuation ; + 327-342 decorator @some_decorator + 327-328 at @ + 328-342 function some_decorator + 354-355 operator = + 356-360 boolean true + 360-361 punctuation ; + 364-375 function constructor + 375-376 punctuation ( + 378-379 operator : + 380-386 builtin number + 386-387 punctuation ) + 388-389 punctuation { + 392-397 keyword super + 397-398 punctuation ( + 398-399 punctuation ) + 399-400 punctuation ; + 403-407 keyword this + 407-408 punctuation . + 411-412 operator = + 415-416 punctuation ; + 418-419 punctuation } + 422-437 function abstract_method + 437-438 punctuation ( + 438-439 punctuation ) + 439-440 operator : + 441-445 keyword void + 446-447 punctuation { + 450-467 comment // implementation + 469-470 punctuation } + 473-488 decorator @some_decorator + 473-474 at @ + 474-488 function some_decorator + 488-489 punctuation ( + 489-498 string 'example' + 498-499 punctuation , + 500-501 punctuation { + 507-508 operator : + 509-513 boolean true + 513-514 punctuation } + 514-515 punctuation ) + 517-529 function class_method + 529-530 punctuation ( + 530-531 punctuation ) + 531-532 operator : + 533-539 builtin string + 540-541 punctuation { + 544-550 special_keyword return + 551-570 template_string `Hello, ${this.d1}` + 551-552 template_punctuation ` + 552-559 string Hello, + 559-569 interpolation ${this.d1} + 559-561 interpolation_punctuation ${ + 561-565 keyword this + 565-566 punctuation . + 568-569 interpolation_punctuation } + 569-570 template_punctuation ` + 570-571 punctuation ; + 573-574 punctuation } + 577-592 function_variable instance_method + 593-594 operator = + 595-596 punctuation ( + 596-597 punctuation ) + 597-604 type_annotation : void + 597-598 : : + 598-604 type void + 599-603 keyword void + 604-606 operator => + 607-608 punctuation { + 611-620 comment /* ... */ + 623-626 keyword let + 629-630 operator = + 631-632 number 0 + 632-633 punctuation ; + 636-638 special_keyword do + 639-640 punctuation { + 645-647 operator ++ + 647-648 punctuation ; + 651-652 punctuation } + 653-658 special_keyword while + 659-660 punctuation ( + 662-663 operator < + 664-665 number 3 + 665-666 punctuation ) + 666-667 punctuation ; + 671-674 special_keyword for + 675-676 punctuation ( + 676-681 keyword const + 685-687 keyword of + 688-692 keyword this + 692-693 punctuation . + 695-696 punctuation ) + 697-698 punctuation { + 702-704 special_keyword if + 705-706 punctuation ( + 709-712 operator === + 713-716 string 'd' + 716-717 punctuation ) + 718-726 special_keyword continue + 726-727 punctuation ; + 731-733 special_keyword if + 734-735 punctuation ( + 735-736 operator ! + 738-739 punctuation ) + 740-745 special_keyword break + 745-746 punctuation ; + 750-754 keyword this + 754-755 punctuation . + 755-770 function #private_method + 770-771 punctuation ( + 772-773 punctuation , + 776-777 punctuation ) + 777-778 punctuation ; + 781-782 punctuation } + 786-792 special_keyword switch + 793-794 punctuation ( + 794-798 keyword this + 798-799 punctuation . + 801-802 punctuation ) + 803-804 punctuation { + 808-812 special_keyword case + 813-816 string 'a' + 816-817 operator : + 822-829 builtin console + 829-830 punctuation . + 830-833 function log + 833-834 punctuation ( + 834-842 string 'case a' + 842-843 punctuation ) + 843-844 punctuation ; + 849-854 special_keyword break + 854-855 punctuation ; + 859-863 special_keyword case + 864-867 string 'b' + 867-868 operator : + 872-876 special_keyword case + 877-880 string 'c' + 880-881 operator : + 886-893 builtin console + 893-894 punctuation . + 894-897 function log + 897-898 punctuation ( + 898-911 string 'case b or c' + 911-912 punctuation ) + 912-913 punctuation ; + 918-923 special_keyword break + 923-924 punctuation ; + 928-935 special_keyword default + 935-936 operator : + 941-948 builtin console + 948-949 punctuation . + 949-952 function log + 952-953 punctuation ( + 953-962 string 'default' + 962-963 punctuation ) + 963-964 punctuation ; + 967-968 punctuation } + 972-977 keyword const + 981-982 operator : + 983-984 punctuation { + 990-991 operator ? + 991-992 operator : + 993-1000 builtin boolean +1000-1001 punctuation ; +1006-1007 operator : +1008-1015 builtin boolean +1015-1016 punctuation } +1017-1018 operator = +1019-1020 punctuation { +1030-1031 operator : +1032-1036 string 'd1' +1037-1039 keyword in +1040-1044 keyword this +1044-1045 punctuation , +1053-1054 operator : +1055-1059 keyword this +1060-1070 keyword instanceof +1071-1072 class_name D +1071-1072 constant D +1072-1073 punctuation , +1076-1077 punctuation } +1077-1078 punctuation ; +1081-1087 keyword delete +1091-1092 punctuation . +1098-1099 punctuation ; +1102-1108 comment // foo +1110-1111 punctuation } +1111-1112 punctuation ; +1115-1130 function #private_method +1130-1131 punctuation ( +1133-1134 operator : +1135-1141 builtin number +1141-1142 punctuation , +1145-1146 operator : +1147-1150 builtin any +1150-1151 punctuation ) +1151-1152 operator : +1153-1157 keyword void +1158-1159 punctuation { +1162-1167 special_keyword throw +1168-1171 keyword new +1172-1177 class_name Error +1172-1177 capitalized_identifier Error +1177-1178 punctuation ( +1178-1224 template_string `${this.d1}\n\t\t\tmultiline\n\t\t\tetc ${a2 + c2}\n\t\t` +1178-1179 template_punctuation ` +1179-1189 interpolation ${this.d1} +1179-1181 interpolation_punctuation ${ +1181-1185 keyword this +1185-1186 punctuation . +1188-1189 interpolation_punctuation } +1189-1210 string \n\t\t\tmultiline\n\t\t\tetc +1210-1220 interpolation ${a2 + c2} +1210-1212 interpolation_punctuation ${ +1215-1216 operator + +1219-1220 interpolation_punctuation } +1220-1223 string \n\t\t +1223-1224 template_punctuation ` +1224-1225 punctuation ) +1225-1226 punctuation ; +1228-1229 punctuation } +1232-1233 operator * +1233-1242 function generator +1242-1243 punctuation ( +1243-1244 punctuation ) +1244-1245 operator : +1246-1255 capitalized_identifier Generator +1255-1256 operator < +1256-1262 builtin number +1263-1264 operator | +1265-1270 capitalized_identifier Array +1270-1271 operator < +1271-1277 builtin number +1277-1279 operator >> +1280-1281 punctuation { +1284-1289 special_keyword yield +1290-1291 number 1 +1291-1292 punctuation ; +1295-1300 special_keyword yield +1300-1301 operator * +1302-1303 punctuation [ +1303-1304 number 2 +1304-1305 punctuation , +1306-1307 number 3 +1307-1308 punctuation ] +1308-1309 punctuation ; +1311-1312 punctuation } +1315-1320 keyword async +1321-1322 operator * +1322-1337 function async_generator +1337-1338 punctuation ( +1338-1339 punctuation ) +1339-1340 operator : +1341-1355 capitalized_identifier AsyncGenerator +1355-1356 operator < +1356-1362 builtin number +1362-1363 operator > +1364-1365 punctuation { +1368-1373 special_keyword yield +1374-1379 special_keyword await 1380-1387 capitalized_identifier Promise -1387-1388 punctuation ( -1388-1389 punctuation ( -1396-1397 punctuation ) -1398-1400 operator => -1401-1411 function setTimeout -1411-1412 punctuation ( -1419-1420 punctuation , -1421-1424 number 100 -1424-1425 punctuation ) -1425-1426 punctuation ) -1426-1427 punctuation ; -1431-1433 special_keyword if -1434-1435 punctuation ( -1435-1439 capitalized_identifier Math -1439-1440 punctuation . -1440-1446 function random -1446-1447 punctuation ( -1447-1448 punctuation ) -1449-1450 operator > -1451-1454 number 0.5 -1454-1455 punctuation ) -1456-1457 punctuation { -1462-1469 builtin console -1469-1470 punctuation . -1470-1473 function log -1473-1474 punctuation ( +1387-1388 punctuation . +1388-1395 function resolve +1395-1396 punctuation ( +1396-1397 number 4 +1397-1398 punctuation ) +1398-1399 punctuation ; +1401-1402 punctuation } +1405-1414 keyword protected +1415-1420 keyword async +1421-1437 function protected_method +1437-1438 punctuation ( +1438-1439 punctuation ) +1439-1440 operator : +1441-1448 capitalized_identifier Promise +1448-1449 operator < +1449-1453 keyword void +1453-1454 operator > +1455-1456 punctuation { +1459-1462 special_keyword try +1463-1464 punctuation { +1468-1473 special_keyword await 1474-1477 keyword new -1478-1482 class_name Date -1478-1482 capitalized_identifier Date -1482-1483 punctuation ( -1483-1484 punctuation ) -1484-1485 punctuation ) -1485-1486 punctuation ; -1487-1520 comment // eslint-disable-line no-console -1524-1525 punctuation } -1526-1530 special_keyword else -1531-1533 special_keyword if -1534-1535 punctuation ( -1535-1539 capitalized_identifier Math -1539-1540 punctuation . -1540-1546 function random -1546-1547 punctuation ( -1547-1548 punctuation ) -1549-1550 operator > -1551-1554 number 0.2 -1554-1555 punctuation ) -1556-1557 punctuation { -1562-1569 builtin console -1569-1570 punctuation . -1570-1573 function log -1573-1574 punctuation ( -1574-1590 string 'else if branch' -1590-1591 punctuation ) -1591-1592 punctuation ; -1596-1597 punctuation } -1598-1602 special_keyword else -1603-1604 punctuation { -1609-1616 builtin console -1616-1617 punctuation . -1617-1620 function log -1620-1621 punctuation ( -1621-1634 string 'else branch' -1634-1635 punctuation ) -1635-1636 punctuation ; -1640-1641 punctuation } -1644-1645 punctuation } -1646-1651 special_keyword catch -1652-1653 punctuation ( -1658-1659 operator : -1660-1667 builtin unknown -1667-1668 punctuation ) -1669-1670 punctuation { -1674-1681 builtin console -1681-1682 punctuation . -1682-1687 function error -1687-1688 punctuation ( -1693-1694 punctuation ) -1694-1695 punctuation ; -1698-1699 punctuation } -1700-1707 special_keyword finally -1708-1709 punctuation { -1713-1720 builtin console -1720-1721 punctuation . -1721-1724 function log -1724-1725 punctuation ( -1725-1740 string 'finally block' -1740-1741 punctuation ) -1741-1742 punctuation ; -1745-1746 punctuation } -1748-1749 punctuation } -1750-1751 punctuation } -1753-1763 comment // comment -1765-1808 comment /*\nother comment\n\nconst comment = false;\n*/ -1810-1834 comment /**\n * JSDoc comment\n */ -1836-1842 special_keyword import -1843-1844 punctuation { -1856-1857 punctuation , -1858-1862 keyword type -1863-1874 class_name Sample_Lang -1863-1874 capitalized_identifier Sample_Lang -1874-1875 punctuation } -1876-1880 special_keyword from -1881-1900 string '../code_sample.js' -1900-1901 punctuation ; -1902-1908 special_keyword import -1909-1910 operator * -1911-1913 special_keyword as -1914-1915 constant A -1916-1920 special_keyword from -1921-1940 string '../code_sample.js' -1940-1941 punctuation ; -1943-1949 special_keyword export -1950-1951 punctuation { -1952-1953 punctuation , -1954-1955 constant A -1955-1956 punctuation , -1958-1959 punctuation , -1961-1962 punctuation , -1963-1964 constant D -1964-1965 punctuation } -1965-1966 punctuation ; -1981-1983 special_keyword as -1984-1991 builtin unknown -1992-1994 special_keyword as -1995-2006 capitalized_identifier Sample_Lang -2007-2016 keyword satisfies -2017-2028 capitalized_identifier Sample_Lang -2028-2029 punctuation ; -2031-2037 special_keyword export -2038-2047 keyword interface -2048-2064 class_name Some_E -2048-2054 capitalized_identifier Some_E -2054-2055 operator < -2055-2056 constant T -2057-2058 operator = -2059-2063 keyword null -2063-2064 operator > -2065-2066 punctuation { -2072-2073 operator : -2074-2080 builtin string -2080-2081 punctuation ; -2086-2087 operator : -2088-2094 builtin number -2094-2095 punctuation ; -2098-2099 operator ? -2099-2100 operator : -2101-2102 constant T -2102-2103 punctuation ; -2104-2105 punctuation } -2107-2112 keyword const -2114-2115 operator : -2116-2117 punctuation { -2121-2122 operator : -2123-2129 builtin string -2129-2130 punctuation ; -2134-2135 operator : -2136-2142 builtin number -2142-2143 punctuation } -2144-2145 operator = -2146-2147 punctuation { -2151-2152 operator : -2153-2160 string 'A. H.' -2160-2161 punctuation , -2165-2166 operator : -2167-2170 number 100 -2170-2171 punctuation } -2171-2172 punctuation ; -2173-2178 keyword const -2181-2182 operator = -2183-2184 punctuation [ -2184-2185 punctuation [ -2185-2187 string '' -2187-2188 punctuation , -2190-2191 punctuation ] -2191-2192 punctuation ] -2193-2195 special_keyword as -2196-2201 keyword const -2201-2202 punctuation ; -2203-2209 special_keyword export -2210-2215 keyword const -2222-2244 type_annotation : Map -2222-2223 : : -2223-2244 type Map -2224-2227 capitalized_identifier Map -2227-2228 operator < -2228-2234 builtin string -2234-2235 punctuation , -2236-2242 capitalized_identifier Some_E -2242-2243 operator > -2244-2245 operator = -2246-2249 keyword new -2250-2253 class_name Map -2250-2253 capitalized_identifier Map -2253-2254 punctuation ( -2255-2256 punctuation ) -2256-2257 punctuation ; -2259-2265 special_keyword export -2266-2274 keyword function -2275-2278 function add -2278-2279 punctuation ( -2280-2281 operator : -2282-2288 builtin number -2288-2289 punctuation , -2291-2292 operator : -2293-2299 builtin number -2299-2300 punctuation ) -2300-2301 operator : -2302-2308 builtin number -2309-2310 punctuation { -2312-2318 special_keyword return -2321-2322 operator + -2324-2325 punctuation ; -2326-2327 punctuation } -2329-2335 special_keyword export -2336-2341 keyword const -2342-2346 function_variable plus -2347-2348 operator = -2349-2350 punctuation ( -2351-2352 operator : -2353-2356 builtin any -2356-2357 punctuation , -2359-2360 operator : -2361-2364 builtin any -2364-2365 punctuation ) -2365-2371 type_annotation : any -2365-2366 : : -2366-2371 type any -2367-2370 builtin any -2371-2373 operator => -2376-2377 operator + -2379-2380 punctuation ; -2382-2404 comment // boundary test cases -2405-2411 special_keyword export -2412-2417 keyword const -2436-2437 operator = -2438-2467 string 'const class function string' -2467-2468 punctuation ; +1478-1485 class_name Promise +1478-1485 capitalized_identifier Promise +1485-1486 punctuation ( +1486-1487 punctuation ( +1494-1495 punctuation ) +1496-1498 operator => +1499-1509 function setTimeout +1509-1510 punctuation ( +1517-1518 punctuation , +1519-1522 number 100 +1522-1523 punctuation ) +1523-1524 punctuation ) +1524-1525 punctuation ; +1529-1531 special_keyword if +1532-1533 punctuation ( +1533-1537 capitalized_identifier Math +1537-1538 punctuation . +1538-1544 function random +1544-1545 punctuation ( +1545-1546 punctuation ) +1547-1548 operator > +1549-1552 number 0.5 +1552-1553 punctuation ) +1554-1555 punctuation { +1560-1567 builtin console +1567-1568 punctuation . +1568-1571 function log +1571-1572 punctuation ( +1572-1575 keyword new +1576-1580 class_name Date +1576-1580 capitalized_identifier Date +1580-1581 punctuation ( +1581-1582 punctuation ) +1582-1583 punctuation ) +1583-1584 punctuation ; +1588-1589 punctuation } +1590-1594 special_keyword else +1595-1597 special_keyword if +1598-1599 punctuation ( +1599-1603 capitalized_identifier Math +1603-1604 punctuation . +1604-1610 function random +1610-1611 punctuation ( +1611-1612 punctuation ) +1613-1614 operator > +1615-1618 number 0.2 +1618-1619 punctuation ) +1620-1621 punctuation { +1626-1633 builtin console +1633-1634 punctuation . +1634-1637 function log +1637-1638 punctuation ( +1638-1654 string 'else if branch' +1654-1655 punctuation ) +1655-1656 punctuation ; +1660-1661 punctuation } +1662-1666 special_keyword else +1667-1668 punctuation { +1673-1680 builtin console +1680-1681 punctuation . +1681-1684 function log +1684-1685 punctuation ( +1685-1698 string 'else branch' +1698-1699 punctuation ) +1699-1700 punctuation ; +1704-1705 punctuation } +1708-1709 punctuation } +1710-1715 special_keyword catch +1716-1717 punctuation ( +1722-1723 operator : +1724-1731 builtin unknown +1731-1732 punctuation ) +1733-1734 punctuation { +1738-1745 builtin console +1745-1746 punctuation . +1746-1751 function error +1751-1752 punctuation ( +1757-1758 punctuation ) +1758-1759 punctuation ; +1762-1763 punctuation } +1764-1771 special_keyword finally +1772-1773 punctuation { +1777-1784 builtin console +1784-1785 punctuation . +1785-1788 function log +1788-1789 punctuation ( +1789-1804 string 'finally block' +1804-1805 punctuation ) +1805-1806 punctuation ; +1809-1810 punctuation } +1812-1813 punctuation } +1814-1815 punctuation } +1817-1827 comment // comment +1829-1872 comment /*\nother comment\n\nconst comment = false;\n*/ +1874-1898 comment /**\n * JSDoc comment\n */ +1900-1906 special_keyword import +1907-1908 punctuation { +1920-1921 punctuation , +1922-1926 keyword type +1927-1938 class_name Sample_Lang +1927-1938 capitalized_identifier Sample_Lang +1938-1939 punctuation } +1940-1944 special_keyword from +1945-1964 string '../code_sample.js' +1964-1965 punctuation ; +1966-1972 special_keyword import +1973-1974 operator * +1975-1977 special_keyword as +1978-1979 constant A +1980-1984 special_keyword from +1985-2004 string '../code_sample.js' +2004-2005 punctuation ; +2007-2013 special_keyword export +2014-2015 punctuation { +2016-2017 punctuation , +2018-2019 constant A +2019-2020 punctuation , +2022-2023 punctuation , +2025-2026 punctuation , +2027-2028 constant D +2028-2029 punctuation } +2029-2030 punctuation ; +2045-2047 special_keyword as +2048-2055 builtin unknown +2056-2058 special_keyword as +2059-2070 capitalized_identifier Sample_Lang +2071-2080 keyword satisfies +2081-2092 capitalized_identifier Sample_Lang +2092-2093 punctuation ; +2095-2101 special_keyword export +2102-2111 keyword interface +2112-2128 class_name Some_E +2112-2118 capitalized_identifier Some_E +2118-2119 operator < +2119-2120 constant T +2121-2122 operator = +2123-2127 keyword null +2127-2128 operator > +2129-2130 punctuation { +2136-2137 operator : +2138-2144 builtin string +2144-2145 punctuation ; +2150-2151 operator : +2152-2158 builtin number +2158-2159 punctuation ; +2162-2163 operator ? +2163-2164 operator : +2165-2166 constant T +2166-2167 punctuation ; +2168-2169 punctuation } +2171-2176 keyword const +2178-2179 operator : +2180-2181 punctuation { +2185-2186 operator : +2187-2193 builtin string +2193-2194 punctuation ; +2198-2199 operator : +2200-2206 builtin number +2206-2207 punctuation } +2208-2209 operator = +2210-2211 punctuation { +2215-2216 operator : +2217-2224 string 'A. H.' +2224-2225 punctuation , +2229-2230 operator : +2231-2234 number 100 +2234-2235 punctuation } +2235-2236 punctuation ; +2237-2242 keyword const +2245-2246 operator = +2247-2248 punctuation [ +2248-2249 punctuation [ +2249-2251 string '' +2251-2252 punctuation , +2254-2255 punctuation ] +2255-2256 punctuation ] +2257-2259 special_keyword as +2260-2265 keyword const +2265-2266 punctuation ; +2267-2273 special_keyword export +2274-2279 keyword const +2286-2308 type_annotation : Map +2286-2287 : : +2287-2308 type Map +2288-2291 capitalized_identifier Map +2291-2292 operator < +2292-2298 builtin string +2298-2299 punctuation , +2300-2306 capitalized_identifier Some_E +2306-2307 operator > +2308-2309 operator = +2310-2313 keyword new +2314-2317 class_name Map +2314-2317 capitalized_identifier Map +2317-2318 punctuation ( +2319-2320 punctuation ) +2320-2321 punctuation ; +2323-2329 special_keyword export +2330-2338 keyword function +2339-2342 function add +2342-2343 punctuation ( +2344-2345 operator : +2346-2352 builtin number +2352-2353 punctuation , +2355-2356 operator : +2357-2363 builtin number +2363-2364 punctuation ) +2364-2365 operator : +2366-2372 builtin number +2373-2374 punctuation { +2376-2382 special_keyword return +2385-2386 operator + +2388-2389 punctuation ; +2390-2391 punctuation } +2393-2399 special_keyword export +2400-2405 keyword const +2406-2410 function_variable plus +2411-2412 operator = +2413-2414 punctuation ( +2415-2416 operator : +2417-2420 builtin any +2420-2421 punctuation , +2423-2424 operator : +2425-2428 builtin any +2428-2429 punctuation ) +2429-2435 type_annotation : any +2429-2430 : : +2430-2435 type any +2431-2434 builtin any +2435-2437 operator => +2440-2441 operator + +2443-2444 punctuation ; +2446-2468 comment // boundary test cases 2469-2475 special_keyword export 2476-2481 keyword const -2499-2500 operator = -2501-2527 string '// this is not a comment' -2527-2528 punctuation ; -2529-2535 special_keyword export -2536-2541 keyword const -2561-2562 operator = -2563-2580 template_string `Value: ${1 + 2}` -2563-2564 template_punctuation ` -2564-2571 string Value: -2571-2579 interpolation ${1 + 2} -2571-2573 interpolation_punctuation ${ -2573-2574 number 1 -2575-2576 operator + -2577-2578 number 2 -2578-2579 interpolation_punctuation } -2579-2580 template_punctuation ` -2580-2581 punctuation ; -2583-2615 comment // regex that looks like comment -2616-2622 special_keyword export -2623-2628 keyword const -2635-2636 operator = -2637-2646 regex /\/\/.*/g -2637-2638 regex_delimiter / -2638-2644 regex_source \/\/.* -2644-2645 regex_delimiter / -2645-2646 regex_flags g -2646-2647 punctuation ; -2648-2654 special_keyword export -2655-2660 keyword const -2675-2676 operator = -2677-2709 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ -2677-2678 regex_delimiter / -2678-2708 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +2500-2501 operator = +2502-2531 string 'const class function string' +2531-2532 punctuation ; +2533-2539 special_keyword export +2540-2545 keyword const +2563-2564 operator = +2565-2591 string '// this is not a comment' +2591-2592 punctuation ; +2593-2599 special_keyword export +2600-2605 keyword const +2625-2626 operator = +2627-2644 template_string `Value: ${1 + 2}` +2627-2628 template_punctuation ` +2628-2635 string Value: +2635-2643 interpolation ${1 + 2} +2635-2637 interpolation_punctuation ${ +2637-2638 number 1 +2639-2640 operator + +2641-2642 number 2 +2642-2643 interpolation_punctuation } +2643-2644 template_punctuation ` +2644-2645 punctuation ; +2647-2679 comment // regex that looks like comment +2680-2686 special_keyword export +2687-2692 keyword const +2699-2700 operator = +2701-2710 regex /\/\/.*/g +2701-2702 regex_delimiter / +2702-2708 regex_source \/\/.* 2708-2709 regex_delimiter / -2709-2710 punctuation ; -2712-2768 comment // string in comment should not be highlighted as string -2769-2820 comment // const commented = "this string is in a comment"; +2709-2710 regex_flags g +2710-2711 punctuation ; +2712-2718 special_keyword export +2719-2724 keyword const +2739-2740 operator = +2741-2773 regex /^(?:\/\*.*?\*\/|\/\/.*|[^/])+$/ +2741-2742 regex_delimiter / +2742-2772 regex_source ^(?:\/\*.*?\*\/|\/\/.*|[^/])+$ +2772-2773 regex_delimiter / +2773-2774 punctuation ; +2776-2832 comment // string in comment should not be highlighted as string +2833-2884 comment // const commented = "this string is in a comment"; diff --git a/src/lib/highlight_priorities.gen.ts b/src/lib/highlight_priorities.gen.ts index 747b51b6..0e25a89e 100644 --- a/src/lib/highlight_priorities.gen.ts +++ b/src/lib/highlight_priorities.gen.ts @@ -20,7 +20,7 @@ export const gen: Gen = ({origin_path}) => { for (const block of rule_blocks) { // Find all ::highlight(token_name) declarations in this block const highlight_regex = /::highlight\(([^)]+)\)/g; - const tokens_in_block: string[] = []; + const tokens_in_block: Array = []; let match; while ((match = highlight_regex.exec(block)) !== null) { @@ -33,7 +33,7 @@ export const gen: Gen = ({origin_path}) => { // Assign the same priority to all tokens in this block if (tokens_in_block.length > 0) { for (const token_name of tokens_in_block) { - if (!highlight_priorities.hasOwnProperty(token_name)) { + if (!Object.hasOwn(highlight_priorities, token_name)) { highlight_priorities[token_name] = priority; } } diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index da58c8ed..5dbfade6 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -96,6 +96,8 @@ abstract class Base { abstract abstract_method(): void; } +/* eslint-disable no-console */ + @some_decorator class D extends Base { readonly d1: string = 'd'; @@ -152,19 +154,19 @@ class D extends Base { // foo }; - #private_method(a2: number, c2: any) { + #private_method(a2: number, c2: any): void { throw new Error(\`\${this.d1} multiline etc \${a2 + c2} \`); } - *generator() { + *generator(): Generator> { yield 1; yield* [2, 3]; } - async *async_generator() { + async *async_generator(): AsyncGenerator { yield await Promise.resolve(4); } @@ -172,7 +174,7 @@ class D extends Base { try { await new Promise((resolve) => setTimeout(resolve, 100)); if (Math.random() > 0.5) { - console.log(new Date()); // eslint-disable-line no-console + console.log(new Date()); } else if (Math.random() > 0.2) { console.log('else if branch'); } else { @@ -307,7 +309,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; const thing_keys = $derived(Object.entries(thing)); - const a = 1; + const a = 1 as number; const b = 'b'; @@ -340,6 +342,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/;
    {/if} + {@html 'raw html'} @@ -349,7 +352,7 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; {@render my_snippet('p')} {#snippet my_snippet(p: string)} - + {/snippet}

    diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index a9c2feb8..c07df901 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -21,7 +21,7 @@ const thing_keys = $derived(Object.entries(thing)); - const a = 1; + const a = 1 as number; const b = 'b'; @@ -54,6 +54,7 @@ {/if} + {@html 'raw html'} @@ -63,7 +64,7 @@ {@render my_snippet('p')} {#snippet my_snippet(p: string)} - + {/snippet}

    diff --git a/src/lib/samples/sample_complex.ts b/src/lib/samples/sample_complex.ts index 57e413f7..c5cbea59 100644 --- a/src/lib/samples/sample_complex.ts +++ b/src/lib/samples/sample_complex.ts @@ -12,6 +12,8 @@ abstract class Base { abstract abstract_method(): void; } +/* eslint-disable no-console */ + @some_decorator class D extends Base { readonly d1: string = 'd'; @@ -68,19 +70,19 @@ class D extends Base { // foo }; - #private_method(a2: number, c2: any) { + #private_method(a2: number, c2: any): void { throw new Error(`${this.d1} multiline etc ${a2 + c2} `); } - *generator() { + *generator(): Generator> { yield 1; yield* [2, 3]; } - async *async_generator() { + async *async_generator(): AsyncGenerator { yield await Promise.resolve(4); } @@ -88,7 +90,7 @@ class D extends Base { try { await new Promise((resolve) => setTimeout(resolve, 100)); if (Math.random() > 0.5) { - console.log(new Date()); // eslint-disable-line no-console + console.log(new Date()); } else if (Math.random() > 0.2) { console.log('else if branch'); } else { From 09ab85738166f09c3066257fd0116b07e4a57740 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:40:24 -0400 Subject: [PATCH 44/49] wip --- src/lib/highlight_priorities.gen.ts | 96 +++++++++++++++-------------- src/routes/package.ts | 2 +- 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/lib/highlight_priorities.gen.ts b/src/lib/highlight_priorities.gen.ts index 0e25a89e..6cde371f 100644 --- a/src/lib/highlight_priorities.gen.ts +++ b/src/lib/highlight_priorities.gen.ts @@ -1,66 +1,72 @@ import type {Gen} from '@ryanatkn/gro'; import {readFileSync} from 'node:fs'; -import {join} from 'node:path'; +import {resolve} from 'node:path'; -export const gen: Gen = ({origin_path}) => { - // Read the theme.css file - const theme_css_path = join('src/lib/theme.css'); // TODO BLOCK declare as a gen dependency - let css_content = readFileSync(theme_css_path, 'utf-8'); +// TODO remove resolve after upgrading gro +const theme_css_path = resolve('src/lib/theme.css'); - // Strip CSS comments to avoid false positives - css_content = css_content.replace(/\/\*[\s\S]*?\*\//g, ''); +export const gen: Gen = { + dependencies: {files: [theme_css_path]}, + generate: ({origin_path}) => { + // Read the theme.css file + let css_content = readFileSync(theme_css_path, 'utf-8'); - // Extract ::highlight() rules by CSS rule blocks - const highlight_priorities: Record = {}; - let priority = 1; + // Strip CSS comments to avoid false positives + css_content = css_content.replace(/\/\*[\s\S]*?\*\//g, ''); - // Split CSS into rule blocks (roughly by closing braces) - const rule_blocks = css_content.split('}'); + // Extract ::highlight() rules by CSS rule blocks + const highlight_priorities: Record = {}; + let priority = 1; - for (const block of rule_blocks) { - // Find all ::highlight(token_name) declarations in this block - const highlight_regex = /::highlight\(([^)]+)\)/g; - const tokens_in_block: Array = []; - let match; + // Split CSS into rule blocks (roughly by closing braces) + const rule_blocks = css_content.split('}'); - while ((match = highlight_regex.exec(block)) !== null) { - const token_name = match[1]; - if (!tokens_in_block.includes(token_name)) { - tokens_in_block.push(token_name); + for (const block of rule_blocks) { + // Find all ::highlight(token_name) declarations in this block + const highlight_regex = /::highlight\(([^)]+)\)/g; + const tokens_in_block: Array = []; + let match; + + while ((match = highlight_regex.exec(block)) !== null) { + const token_name = match[1]; + if (!tokens_in_block.includes(token_name)) { + tokens_in_block.push(token_name); + } } - } - // Assign the same priority to all tokens in this block - if (tokens_in_block.length > 0) { - for (const token_name of tokens_in_block) { - if (!Object.hasOwn(highlight_priorities, token_name)) { - highlight_priorities[token_name] = priority; + // Assign the same priority to all tokens in this block + if (tokens_in_block.length > 0) { + for (const token_name of tokens_in_block) { + if (!Object.hasOwn(highlight_priorities, token_name)) { + highlight_priorities[token_name] = priority; + } } + priority++; } - priority++; } - } - const banner = `// generated by ${origin_path} - DO NOT EDIT OR RISK LOST DATA`; + const banner = `// generated by ${origin_path} - DO NOT EDIT OR RISK LOST DATA`; - // Generate priority entries - const priority_entries = Object.entries(highlight_priorities) - .map(([token, priority]) => `\t${token}: ${priority}`) - .join(',\n'); + // Generate priority entries + const priority_entries = Object.entries(highlight_priorities) + .map(([token, priority]) => `\t${token}: ${priority}`) + .join(',\n'); - // Generate the type - const token_names = Object.keys(highlight_priorities) - .map((name) => `'${name}'`) - .join(' | '); + // Generate the type + const token_names = Object.keys(highlight_priorities) + .map((name) => `'${name}'`) + .join(' | '); - return `${banner} + return ` + ${banner} -export type Highlight_Token_Name = ${token_names}; + export type Highlight_Token_Name = ${token_names}; -export const highlight_priorities: Record = { -${priority_entries}, -} as const; + export const highlight_priorities: Record = { + ${priority_entries}, + } as const; -${banner} -`; + ${banner} + `; + }, }; diff --git a/src/routes/package.ts b/src/routes/package.ts index 46d5f6c6..d20ded91 100644 --- a/src/routes/package.ts +++ b/src/routes/package.ts @@ -144,7 +144,7 @@ export const src_json: Src_Json = { }, './highlight_priorities.gen.js': { path: 'highlight_priorities.gen.ts', - declarations: [{name: 'gen', kind: 'function'}], + declarations: [{name: 'gen', kind: 'variable'}], }, './highlight_priorities.js': { path: 'highlight_priorities.ts', From 184e71a9287ba2cb234e6ba795442496d3ec86b5 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:45:36 -0400 Subject: [PATCH 45/49] wip --- src/lib/highlight_priorities.ts | 20 ++++++++++---------- src/lib/theme.css | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lib/highlight_priorities.ts b/src/lib/highlight_priorities.ts index f48a6aff..da81cfc9 100644 --- a/src/lib/highlight_priorities.ts +++ b/src/lib/highlight_priorities.ts @@ -32,13 +32,13 @@ export type Highlight_Token_Name = | 'property' | 'decorator' | 'decorator_name' - | 'bold' - | 'italic' | 'attr_equals' | 'processing_instruction' | 'doctype' | 'cdata' - | 'punctuation'; + | 'punctuation' + | 'bold' + | 'italic'; export const highlight_priorities: Record = { namespace: 1, @@ -72,13 +72,13 @@ export const highlight_priorities: Record Date: Fri, 26 Sep 2025 07:51:31 -0400 Subject: [PATCH 46/49] wip --- src/lib/highlight_priorities.ts | 80 ++++++++++++++++----------------- src/lib/theme.css | 17 +++---- 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/src/lib/highlight_priorities.ts b/src/lib/highlight_priorities.ts index da81cfc9..8c384629 100644 --- a/src/lib/highlight_priorities.ts +++ b/src/lib/highlight_priorities.ts @@ -1,7 +1,6 @@ // generated by src/lib/highlight_priorities.gen.ts - DO NOT EDIT OR RISK LOST DATA export type Highlight_Token_Name = - | 'namespace' | 'tag' | 'constant' | 'symbol' @@ -10,7 +9,6 @@ export type Highlight_Token_Name = | 'null' | 'boolean' | 'interpolation_punctuation' - | 'special_keyword' | 'comment' | 'char' | 'builtin' @@ -32,6 +30,8 @@ export type Highlight_Token_Name = | 'property' | 'decorator' | 'decorator_name' + | 'special_keyword' + | 'namespace' | 'attr_equals' | 'processing_instruction' | 'doctype' @@ -41,44 +41,44 @@ export type Highlight_Token_Name = | 'italic'; export const highlight_priorities: Record = { - namespace: 1, - tag: 2, - constant: 2, - symbol: 2, - deleted: 2, - keyword: 3, - null: 3, - boolean: 3, - interpolation_punctuation: 3, - special_keyword: 4, - comment: 5, - char: 5, - builtin: 5, - inserted: 5, - class_name: 6, - number: 6, - attr_value: 7, - attr_quote: 7, - string: 7, - template_punctuation: 7, - selector: 8, - function: 8, - regex: 8, - important: 8, - variable: 8, - atrule: 9, - rule: 10, - attr_name: 11, - property: 11, - decorator: 11, - decorator_name: 11, - attr_equals: 12, - processing_instruction: 12, - doctype: 12, - cdata: 12, - punctuation: 12, - bold: 13, - italic: 14, + tag: 1, + constant: 1, + symbol: 1, + deleted: 1, + keyword: 2, + null: 2, + boolean: 2, + interpolation_punctuation: 2, + comment: 3, + char: 3, + builtin: 3, + inserted: 3, + class_name: 4, + number: 4, + attr_value: 5, + attr_quote: 5, + string: 5, + template_punctuation: 5, + selector: 6, + function: 6, + regex: 6, + important: 6, + variable: 6, + atrule: 7, + rule: 8, + attr_name: 9, + property: 9, + decorator: 9, + decorator_name: 9, + special_keyword: 10, + namespace: 10, + attr_equals: 11, + processing_instruction: 11, + doctype: 11, + cdata: 11, + punctuation: 11, + bold: 12, + italic: 13, } as const; // generated by src/lib/highlight_priorities.gen.ts - DO NOT EDIT OR RISK LOST DATA diff --git a/src/lib/theme.css b/src/lib/theme.css index 21bd6818..980c3d05 100644 --- a/src/lib/theme.css +++ b/src/lib/theme.css @@ -1,8 +1,3 @@ -.token.namespace, -::highlight(namespace) { - color: var(--color_d_5); -} - .token.tag, ::highlight(tag), .token.constant, @@ -25,11 +20,6 @@ color: var(--color_a_5); } -.token.special_keyword, -::highlight(special_keyword) { - color: var(--color_g_5); -} - .token.comment, ::highlight(comment), .token.char, @@ -95,6 +85,13 @@ color: var(--color_i_5); } +.token.special_keyword, +::highlight(special_keyword), +.token.namespace, +::highlight(namespace) { + color: var(--color_g_5); +} + .token.attr_equals, ::highlight(attr_equals), .token.processing_instruction, From da23a8d5a357fdeb4a3eeef66ba3f746e1a9f9b9 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 26 Sep 2025 07:55:25 -0400 Subject: [PATCH 47/49] wip --- .../generated/svelte/svelte_complex.html | 10 +++++----- src/fixtures/generated/svelte/svelte_complex.txt | 15 ++++++++------- src/lib/grammar_svelte.ts | 2 +- src/lib/highlight_priorities.ts | 16 +++++++++------- src/lib/theme.css | 5 +++++ 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index 011b4782..d0267266 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -40,7 +40,7 @@ <h1 bind:this={element_ref}>hello {HELLO}!</h1> {#each thing_keys as [k, { t, u }] (f(k))} - {@const v = Math.round(t[k + f(u)])} + {@const v = Math.round(t[k + f(u)])} {f(v)} {/each} @@ -50,18 +50,18 @@ bigger {:else} <Thing string_prop="b" onthing={() => (c = f(!c))}> - {@render children()} + {@render children()} </Thing> {/if} <!-- eslint-disable-next-line svelte/no-at-html-tags --> -{@html '<strong>raw html</strong>'} +{@html '<strong>raw html</strong>'} <input bind:value type="text" class:active={c} /> -<span {@attach attachment('param', f(42))}>...</span> +<span {@attach attachment('param', f(42))}>...</span> -{@render my_snippet('p')} +{@render my_snippet('p')} {#snippet my_snippet(p: string)} <button type="button" {onclick}>{p}</button> diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 26048b81..209afa17 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -2,7 +2,7 @@ Sample length: 2249 characters Total tokens: 631 -Token types (32 unique): +Token types (33 unique): punctuation: 298 tag: 74 operator: 37 @@ -10,8 +10,8 @@ Token types (32 unique): lang_ts: 23 function: 23 attr_name: 20 - keyword: 19 special_keyword: 14 + keyword: 14 attr_value: 11 string: 11 builtin: 9 @@ -22,6 +22,7 @@ Token types (32 unique): comment: 6 number: 5 at_directive: 5 + at_keyword: 5 script: 3 namespace: 3 constant: 2 @@ -245,7 +246,7 @@ Token types (32 unique): 794-830 svelte_expression {@const v = Math.round(t[k + f(u)])} 794-830 at_directive {@const v = Math.round(t[k + f(u)])} 794-795 punctuation { - 795-801 keyword @const + 795-801 at_keyword @const 802-830 lang_ts v = Math.round(t[k + f(u)])} 804-805 operator = 806-810 capitalized_identifier Math @@ -347,7 +348,7 @@ Token types (32 unique): 1007-1027 svelte_expression {@render children()} 1007-1027 at_directive {@render children()} 1007-1008 punctuation { -1008-1015 keyword @render +1008-1015 at_keyword @render 1016-1027 lang_ts children()} 1016-1024 function children 1024-1025 punctuation ( @@ -366,7 +367,7 @@ Token types (32 unique): 1102-1137 svelte_expression {@html 'raw html'} 1102-1137 at_directive {@html 'raw html'} 1102-1103 punctuation { -1103-1108 keyword @html +1103-1108 at_keyword @html 1109-1137 lang_ts 'raw html'} 1109-1136 string 'raw html' 1136-1137 punctuation } @@ -393,7 +394,7 @@ Token types (32 unique): 1196-1232 svelte_expression {@attach attachment('param', f(42))} 1196-1232 at_directive {@attach attachment('param', f(42))} 1196-1197 punctuation { -1197-1204 keyword @attach +1197-1204 at_keyword @attach 1205-1232 lang_ts attachment('param', f(42))} 1205-1215 function attachment 1215-1216 punctuation ( @@ -413,7 +414,7 @@ Token types (32 unique): 1245-1270 svelte_expression {@render my_snippet('p')} 1245-1270 at_directive {@render my_snippet('p')} 1245-1246 punctuation { -1246-1253 keyword @render +1246-1253 at_keyword @render 1254-1270 lang_ts my_snippet('p')} 1254-1264 function my_snippet 1264-1265 punctuation ( diff --git a/src/lib/grammar_svelte.ts b/src/lib/grammar_svelte.ts index 2d10ae06..f7990dd6 100644 --- a/src/lib/grammar_svelte.ts +++ b/src/lib/grammar_svelte.ts @@ -23,7 +23,7 @@ export const add_grammar_svelte: Add_Syntax_Grammar = (syntax_styler) => { lookbehind: true, inside: grammar_ts, }, - keyword: /@\w+/, + at_keyword: /@\w+/, punctuation: /[{}]/, }, }; diff --git a/src/lib/highlight_priorities.ts b/src/lib/highlight_priorities.ts index 8c384629..b05b836a 100644 --- a/src/lib/highlight_priorities.ts +++ b/src/lib/highlight_priorities.ts @@ -32,6 +32,7 @@ export type Highlight_Token_Name = | 'decorator_name' | 'special_keyword' | 'namespace' + | 'at_keyword' | 'attr_equals' | 'processing_instruction' | 'doctype' @@ -72,13 +73,14 @@ export const highlight_priorities: Record Date: Fri, 26 Sep 2025 07:57:30 -0400 Subject: [PATCH 48/49] wip --- src/lib/highlight_priorities.ts | 70 ++++++++-------- src/lib/theme.css | 137 +------------------------------- 2 files changed, 39 insertions(+), 168 deletions(-) diff --git a/src/lib/highlight_priorities.ts b/src/lib/highlight_priorities.ts index b05b836a..5f6881f4 100644 --- a/src/lib/highlight_priorities.ts +++ b/src/lib/highlight_priorities.ts @@ -25,13 +25,13 @@ export type Highlight_Token_Name = | 'important' | 'variable' | 'atrule' - | 'rule' | 'attr_name' | 'property' | 'decorator' | 'decorator_name' | 'special_keyword' | 'namespace' + | 'rule' | 'at_keyword' | 'attr_equals' | 'processing_instruction' @@ -46,41 +46,41 @@ export const highlight_priorities: Record Date: Fri, 26 Sep 2025 07:58:01 -0400 Subject: [PATCH 49/49] wip --- .../generated/svelte/svelte_complex.html | 6 +- .../generated/svelte/svelte_complex.txt | 996 +++++++++--------- src/lib/samples/all.ts | 6 +- src/lib/samples/sample_complex.svelte | 6 +- 4 files changed, 512 insertions(+), 502 deletions(-) diff --git a/src/fixtures/generated/svelte/svelte_complex.html b/src/fixtures/generated/svelte/svelte_complex.html index d0267266..7814766d 100644 --- a/src/fixtures/generated/svelte/svelte_complex.html +++ b/src/fixtures/generated/svelte/svelte_complex.html @@ -29,8 +29,10 @@ const f = (p: any) => p; - const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { - element_ref !== el; + const attachment = (_p1: string, _p2: number) => { + return (el: HTMLElement) => { + element_ref !== el; + }; }; let value = $state(thing['']); diff --git a/src/fixtures/generated/svelte/svelte_complex.txt b/src/fixtures/generated/svelte/svelte_complex.txt index 209afa17..2e0f7160 100644 --- a/src/fixtures/generated/svelte/svelte_complex.txt +++ b/src/fixtures/generated/svelte/svelte_complex.txt @@ -1,16 +1,16 @@ === STATS === -Sample length: 2249 characters -Total tokens: 631 +Sample length: 2266 characters +Total tokens: 635 Token types (33 unique): - punctuation: 298 + punctuation: 301 tag: 74 operator: 37 svelte_expression: 24 lang_ts: 23 function: 23 attr_name: 20 - special_keyword: 14 + special_keyword: 15 keyword: 14 attr_value: 11 string: 11 @@ -69,8 +69,8 @@ Token types (33 unique): 81-82 punctuation " 84-85 punctuation " 85-86 punctuation > - 86-690 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1 as number;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n - 86-690 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1 as number;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => (el: HTMLElement) => {\n\t\telement_ref !== el;\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n + 86-707 script \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1 as number;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => {\n\t\treturn (el: HTMLElement) => {\n\t\t\telement_ref !== el;\n\t\t};\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n + 86-707 lang_ts \n\t// @ts-expect-error\n\timport Thing from '$lib/Thing.svelte';\n\timport type {Snippet} from 'svelte';\n\n\tconst {\n\t\tthing,\n\t\tbound = $bindable(true),\n\t\tchildren,\n\t\tonclick,\n\t}: {\n\t\tthing: Record;\n\t\tbound?: boolean;\n\t\tchildren: Snippet;\n\t\tonclick?: () => void;\n\t} = $props();\n\n\tconst thing_keys = $derived(Object.entries(thing));\n\n\tconst a = 1 as number;\n\n\tconst b = 'b';\n\n\tlet c: boolean = $state(true);\n\n\tconst f = (p: any) => p;\n\n\tconst attachment = (_p1: string, _p2: number) => {\n\t\treturn (el: HTMLElement) => {\n\t\t\telement_ref !== el;\n\t\t};\n\t};\n\n\tlet value = $state(thing['']);\n\tlet element_ref: HTMLElement;\n 88-107 comment // @ts-expect-error 109-115 special_keyword import 116-121 capitalized_identifier Thing @@ -179,493 +179,497 @@ Token types (33 unique): 566-572 builtin number 572-573 punctuation ) 574-576 operator => - 577-578 punctuation ( - 580-581 operator : - 582-593 capitalized_identifier HTMLElement - 593-594 punctuation ) - 595-597 operator => - 598-599 punctuation { - 614-617 operator !== - 620-621 punctuation ; - 623-624 punctuation } - 624-625 punctuation ; - 628-631 keyword let - 638-639 operator = - 640-646 function $state - 646-647 punctuation ( - 652-653 punctuation [ - 653-655 string '' - 655-656 punctuation ] - 656-657 punctuation ) - 657-658 punctuation ; - 660-663 keyword let - 675-676 operator : - 677-688 capitalized_identifier HTMLElement - 688-689 punctuation ; - 690-699 tag - 690-698 tag - 701-729 tag

    - 701-704 tag

    - 735-742 svelte_expression {HELLO} - 735-736 punctuation { - 736-741 lang_ts HELLO - 736-741 constant HELLO - 741-742 punctuation } - 743-748 tag

    - 743-747 tag - 750-792 svelte_expression {#each thing_keys as [k, { t, u }] (f(k))} - 750-792 each {#each thing_keys as [k, { t, u }] (f(k))} - 750-751 punctuation { - 751-756 special_keyword #each - 768-770 keyword as - 771-792 lang_ts [k, { t, u }] (f(k))} - 771-772 punctuation [ - 773-774 punctuation , - 775-776 punctuation { - 778-779 punctuation , - 782-783 punctuation } - 783-784 punctuation ] - 785-786 punctuation ( - 786-787 function f - 787-788 punctuation ( - 789-790 punctuation ) - 790-791 punctuation ) - 791-792 punctuation } - 794-830 svelte_expression {@const v = Math.round(t[k + f(u)])} - 794-830 at_directive {@const v = Math.round(t[k + f(u)])} - 794-795 punctuation { - 795-801 at_keyword @const - 802-830 lang_ts v = Math.round(t[k + f(u)])} - 804-805 operator = - 806-810 capitalized_identifier Math - 810-811 punctuation . - 811-816 function round - 816-817 punctuation ( - 818-819 punctuation [ - 821-822 operator + - 823-824 function f - 824-825 punctuation ( - 826-827 punctuation ) - 827-828 punctuation ] - 828-829 punctuation ) - 829-830 punctuation } - 832-838 svelte_expression {f(v)} - 832-833 punctuation { - 833-837 lang_ts f(v) - 833-834 function f - 834-835 punctuation ( - 836-837 punctuation ) - 837-838 punctuation } - 839-846 svelte_expression {/each} - 839-846 block {/each} - 839-840 punctuation { - 840-845 special_keyword /each - 845-846 punctuation } - 848-858 svelte_expression {#if f(c)} - 848-858 block {#if f(c)} - 848-849 punctuation { - 849-852 special_keyword #if - 852-857 lang_ts f(c) - 853-854 function f - 854-855 punctuation ( - 856-857 punctuation ) - 857-858 punctuation } - 860-915 tag - 860-866 tag - 916-935 svelte_expression {:else if f(a > 0)} - 916-935 block {:else if f(a > 0)} - 916-917 punctuation { - 917-925 special_keyword :else if - 925-934 lang_ts f(a > 0) - 926-927 function f - 927-928 punctuation ( - 930-931 operator > - 932-933 number 0 - 933-934 punctuation ) - 934-935 punctuation } - 944-951 svelte_expression {:else} - 944-951 block {:else} - 944-945 punctuation { - 945-950 special_keyword :else - 950-951 punctuation } - 953-1004 tag (c = f(!c))}> - 953-959 tag (c = f(!c))} - 984-985 punctuation { - 985-1002 lang_ts () => (c = f(!c)) - 985-986 punctuation ( - 986-987 punctuation ) - 988-990 operator => - 991-992 punctuation ( - 994-995 operator = - 996-997 function f - 997-998 punctuation ( - 998-999 operator ! -1000-1001 punctuation ) -1001-1002 punctuation ) -1002-1003 punctuation } -1003-1004 punctuation > -1007-1027 svelte_expression {@render children()} -1007-1027 at_directive {@render children()} -1007-1008 punctuation { -1008-1015 at_keyword @render -1016-1027 lang_ts children()} -1016-1024 function children -1024-1025 punctuation ( -1025-1026 punctuation ) -1026-1027 punctuation } -1029-1037 tag -1029-1036 tag -1038-1043 svelte_expression {/if} -1038-1043 block {/if} -1038-1039 punctuation { -1039-1042 special_keyword /if -1042-1043 punctuation } -1045-1101 comment -1102-1137 svelte_expression {@html 'raw html'} -1102-1137 at_directive {@html 'raw html'} -1102-1103 punctuation { -1103-1108 at_keyword @html -1109-1137 lang_ts 'raw html'} -1109-1136 string 'raw html' -1136-1137 punctuation } -1139-1188 tag -1139-1145 tag -1190-1233 tag -1190-1195 tag -1236-1243 tag -1236-1242 tag -1245-1270 svelte_expression {@render my_snippet('p')} -1245-1270 at_directive {@render my_snippet('p')} -1245-1246 punctuation { -1246-1253 at_keyword @render -1254-1270 lang_ts my_snippet('p')} -1254-1264 function my_snippet -1264-1265 punctuation ( -1265-1268 string 'p' -1268-1269 punctuation ) -1269-1270 punctuation } -1272-1304 svelte_expression {#snippet my_snippet(p: string)} -1272-1304 block {#snippet my_snippet(p: string)} -1272-1273 punctuation { -1273-1281 special_keyword #snippet -1281-1303 lang_ts my_snippet(p: string) -1282-1292 function my_snippet -1292-1293 punctuation ( -1294-1295 operator : -1296-1302 builtin string -1302-1303 punctuation ) -1303-1304 punctuation } -1306-1338 tag -1341-1349 tag -1351-1361 svelte_expression {/snippet} -1351-1361 block {/snippet} -1351-1352 punctuation { -1352-1360 special_keyword /snippet -1360-1361 punctuation } -1363-1412 tag

    -1363-1365 tag

    -1419-1439 tag -1419-1424 tag -1443-1450 tag -1443-1449 tag -1451-1455 tag

    -1451-1454 tag

    -1457-1488 tag -1498-1506 tag -1509-1548 comment -1549-1562 svelte_expression {b.repeat(2)} -1549-1550 punctuation { -1550-1561 lang_ts b.repeat(2) -1551-1552 punctuation . -1552-1558 function repeat -1558-1559 punctuation ( -1559-1560 number 2 -1560-1561 punctuation ) -1561-1562 punctuation } -1563-1570 svelte_expression {bound} -1563-1564 punctuation { -1564-1569 lang_ts bound -1569-1570 punctuation } -1572-1578 tag
    -1572-1575 tag
    -1580-1586 tag
    -1580-1583 tag
    -1588-1624 tag access -1588-1592 tag -1626-1630 tag
      -1626-1629 tag
        -1632-1636 tag
      • -1632-1635 tag
      • -1647-1652 tag
      • -1647-1651 tag -1654-1658 tag
      • -1654-1657 tag
      • -1669-1674 tag
      • -1669-1673 tag -1675-1680 tag
      -1675-1679 tag
    -1682-1725 comment -1726-1731 tag
    -1726-1730 tag
    -1733-1741 tag -1779-1787 tag -1790-1797 tag -1831-1838 tag -1840-1846 tag
    -1840-1845 tag
    -1848-1855 tag -2240-2247 tag + 577-578 punctuation { + 581-587 special_keyword return + 588-589 punctuation ( + 591-592 operator : + 593-604 capitalized_identifier HTMLElement + 604-605 punctuation ) + 606-608 operator => + 609-610 punctuation { + 626-629 operator !== + 632-633 punctuation ; + 636-637 punctuation } + 637-638 punctuation ; + 640-641 punctuation } + 641-642 punctuation ; + 645-648 keyword let + 655-656 operator = + 657-663 function $state + 663-664 punctuation ( + 669-670 punctuation [ + 670-672 string '' + 672-673 punctuation ] + 673-674 punctuation ) + 674-675 punctuation ; + 677-680 keyword let + 692-693 operator : + 694-705 capitalized_identifier HTMLElement + 705-706 punctuation ; + 707-716 tag + 707-715 tag + 718-746 tag

    + 718-721 tag

    + 752-759 svelte_expression {HELLO} + 752-753 punctuation { + 753-758 lang_ts HELLO + 753-758 constant HELLO + 758-759 punctuation } + 760-765 tag

    + 760-764 tag + 767-809 svelte_expression {#each thing_keys as [k, { t, u }] (f(k))} + 767-809 each {#each thing_keys as [k, { t, u }] (f(k))} + 767-768 punctuation { + 768-773 special_keyword #each + 785-787 keyword as + 788-809 lang_ts [k, { t, u }] (f(k))} + 788-789 punctuation [ + 790-791 punctuation , + 792-793 punctuation { + 795-796 punctuation , + 799-800 punctuation } + 800-801 punctuation ] + 802-803 punctuation ( + 803-804 function f + 804-805 punctuation ( + 806-807 punctuation ) + 807-808 punctuation ) + 808-809 punctuation } + 811-847 svelte_expression {@const v = Math.round(t[k + f(u)])} + 811-847 at_directive {@const v = Math.round(t[k + f(u)])} + 811-812 punctuation { + 812-818 at_keyword @const + 819-847 lang_ts v = Math.round(t[k + f(u)])} + 821-822 operator = + 823-827 capitalized_identifier Math + 827-828 punctuation . + 828-833 function round + 833-834 punctuation ( + 835-836 punctuation [ + 838-839 operator + + 840-841 function f + 841-842 punctuation ( + 843-844 punctuation ) + 844-845 punctuation ] + 845-846 punctuation ) + 846-847 punctuation } + 849-855 svelte_expression {f(v)} + 849-850 punctuation { + 850-854 lang_ts f(v) + 850-851 function f + 851-852 punctuation ( + 853-854 punctuation ) + 854-855 punctuation } + 856-863 svelte_expression {/each} + 856-863 block {/each} + 856-857 punctuation { + 857-862 special_keyword /each + 862-863 punctuation } + 865-875 svelte_expression {#if f(c)} + 865-875 block {#if f(c)} + 865-866 punctuation { + 866-869 special_keyword #if + 869-874 lang_ts f(c) + 870-871 function f + 871-872 punctuation ( + 873-874 punctuation ) + 874-875 punctuation } + 877-932 tag + 877-883 tag + 933-952 svelte_expression {:else if f(a > 0)} + 933-952 block {:else if f(a > 0)} + 933-934 punctuation { + 934-942 special_keyword :else if + 942-951 lang_ts f(a > 0) + 943-944 function f + 944-945 punctuation ( + 947-948 operator > + 949-950 number 0 + 950-951 punctuation ) + 951-952 punctuation } + 961-968 svelte_expression {:else} + 961-968 block {:else} + 961-962 punctuation { + 962-967 special_keyword :else + 967-968 punctuation } + 970-1021 tag (c = f(!c))}> + 970-976 tag (c = f(!c))} +1001-1002 punctuation { +1002-1019 lang_ts () => (c = f(!c)) +1002-1003 punctuation ( +1003-1004 punctuation ) +1005-1007 operator => +1008-1009 punctuation ( +1011-1012 operator = +1013-1014 function f +1014-1015 punctuation ( +1015-1016 operator ! +1017-1018 punctuation ) +1018-1019 punctuation ) +1019-1020 punctuation } +1020-1021 punctuation > +1024-1044 svelte_expression {@render children()} +1024-1044 at_directive {@render children()} +1024-1025 punctuation { +1025-1032 at_keyword @render +1033-1044 lang_ts children()} +1033-1041 function children +1041-1042 punctuation ( +1042-1043 punctuation ) +1043-1044 punctuation } +1046-1054 tag +1046-1053 tag +1055-1060 svelte_expression {/if} +1055-1060 block {/if} +1055-1056 punctuation { +1056-1059 special_keyword /if +1059-1060 punctuation } +1062-1118 comment +1119-1154 svelte_expression {@html 'raw html'} +1119-1154 at_directive {@html 'raw html'} +1119-1120 punctuation { +1120-1125 at_keyword @html +1126-1154 lang_ts 'raw html'} +1126-1153 string 'raw html' +1153-1154 punctuation } +1156-1205 tag +1156-1162 tag +1207-1250 tag +1207-1212 tag +1253-1260 tag +1253-1259 tag +1262-1287 svelte_expression {@render my_snippet('p')} +1262-1287 at_directive {@render my_snippet('p')} +1262-1263 punctuation { +1263-1270 at_keyword @render +1271-1287 lang_ts my_snippet('p')} +1271-1281 function my_snippet +1281-1282 punctuation ( +1282-1285 string 'p' +1285-1286 punctuation ) +1286-1287 punctuation } +1289-1321 svelte_expression {#snippet my_snippet(p: string)} +1289-1321 block {#snippet my_snippet(p: string)} +1289-1290 punctuation { +1290-1298 special_keyword #snippet +1298-1320 lang_ts my_snippet(p: string) +1299-1309 function my_snippet +1309-1310 punctuation ( +1311-1312 operator : +1313-1319 builtin string +1319-1320 punctuation ) +1320-1321 punctuation } +1323-1355 tag +1358-1366 tag +1368-1378 svelte_expression {/snippet} +1368-1378 block {/snippet} +1368-1369 punctuation { +1369-1377 special_keyword /snippet +1377-1378 punctuation } +1380-1429 tag

    +1380-1382 tag

    +1436-1456 tag +1436-1441 tag +1460-1467 tag +1460-1466 tag +1468-1472 tag

    +1468-1471 tag

    +1474-1505 tag +1515-1523 tag +1526-1565 comment +1566-1579 svelte_expression {b.repeat(2)} +1566-1567 punctuation { +1567-1578 lang_ts b.repeat(2) +1568-1569 punctuation . +1569-1575 function repeat +1575-1576 punctuation ( +1576-1577 number 2 +1577-1578 punctuation ) +1578-1579 punctuation } +1580-1587 svelte_expression {bound} +1580-1581 punctuation { +1581-1586 lang_ts bound +1586-1587 punctuation } +1589-1595 tag
    +1589-1592 tag
    +1597-1603 tag
    +1597-1600 tag
    +1605-1641 tag access +1605-1609 tag +1643-1647 tag
      +1643-1646 tag
        +1649-1653 tag
      • +1649-1652 tag
      • +1664-1669 tag
      • +1664-1668 tag +1671-1675 tag
      • +1671-1674 tag
      • +1686-1691 tag
      • +1686-1690 tag +1692-1697 tag
      +1692-1696 tag
    +1699-1742 comment +1743-1748 tag
    +1743-1747 tag
    +1750-1758 tag +1796-1804 tag +1807-1814 tag +1848-1855 tag +1857-1863 tag
    +1857-1862 tag
    +1865-1872 tag +2257-2264 tag diff --git a/src/lib/samples/all.ts b/src/lib/samples/all.ts index 5dbfade6..f9fe7302 100644 --- a/src/lib/samples/all.ts +++ b/src/lib/samples/all.ts @@ -317,8 +317,10 @@ export const complex_regex = /^(?:\\/\\*.*?\\*\\/|\\/\\/.*|[^/])+$/; const f = (p: any) => p; - const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { - element_ref !== el; + const attachment = (_p1: string, _p2: number) => { + return (el: HTMLElement) => { + element_ref !== el; + }; }; let value = $state(thing['']); diff --git a/src/lib/samples/sample_complex.svelte b/src/lib/samples/sample_complex.svelte index c07df901..405a33b0 100644 --- a/src/lib/samples/sample_complex.svelte +++ b/src/lib/samples/sample_complex.svelte @@ -29,8 +29,10 @@ const f = (p: any) => p; - const attachment = (_p1: string, _p2: number) => (el: HTMLElement) => { - element_ref !== el; + const attachment = (_p1: string, _p2: number) => { + return (el: HTMLElement) => { + element_ref !== el; + }; }; let value = $state(thing['']);