From b4687eb52458c7fd80f447c8060922e23ef77590 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Fri, 23 Aug 2024 18:21:35 +0200 Subject: [PATCH] Adjust TS/JS regexp for Document detection, also adjust TextMate (#179) Co-authored-by: Jerel Miller --- package-lock.json | 167 +- package.json | 4 +- .../sampleWorkspace.code-workspace | 47 +- .../__tests__/document.test.ts | 164 +- .../fixtures/TypeScript.tmLanguage.json | 5749 +++++++++++++++++ .../fixtures/documents/commentWithTemplate.ts | 41 + .../documents/commentWithTemplate.ts.snap | 185 + .../fixtures/documents/functionCall.ts | 93 + .../fixtures/documents/functionCall.ts.snap | 431 ++ .../fixtures/documents/taggedTemplate.ts | 80 + .../fixtures/documents/taggedTemplate.ts.snap | 353 + .../fixtures/documents/templateWithComment.ts | 38 + .../documents/templateWithComment.ts.snap | 123 + src/language-server/document.ts | 36 +- syntaxes/graphql.js.json | 39 +- 15 files changed, 7497 insertions(+), 53 deletions(-) create mode 100644 src/language-server/__tests__/fixtures/TypeScript.tmLanguage.json create mode 100644 src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts create mode 100644 src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts.snap create mode 100644 src/language-server/__tests__/fixtures/documents/functionCall.ts create mode 100644 src/language-server/__tests__/fixtures/documents/functionCall.ts.snap create mode 100644 src/language-server/__tests__/fixtures/documents/taggedTemplate.ts create mode 100644 src/language-server/__tests__/fixtures/documents/taggedTemplate.ts.snap create mode 100644 src/language-server/__tests__/fixtures/documents/templateWithComment.ts create mode 100644 src/language-server/__tests__/fixtures/documents/templateWithComment.ts.snap diff --git a/package-lock.json b/package-lock.json index 41bc37b8..e86409f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,7 +64,8 @@ "rimraf": "6.0.1", "ts-jest": "29.1.2", "ts-node": "^10.9.2", - "typescript": "^5.5.3" + "typescript": "^5.5.3", + "vscode-tmgrammar-test": "^0.1.3" }, "engines": { "vscode": "^1.90.0" @@ -5769,6 +5770,13 @@ "readable-stream": "^3.4.0" } }, + "node_modules/bottleneck": { + "version": "2.19.5", + "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", + "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==", + "dev": true, + "license": "MIT" + }, "node_modules/bplist-parser": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", @@ -6323,6 +6331,16 @@ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "dev": true }, + "node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/common-tags": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz", @@ -14195,6 +14213,153 @@ "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==" }, + "node_modules/vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-textmate": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-7.0.4.tgz", + "integrity": "sha512-9hJp0xL7HW1Q5OgGe03NACo7yiCTMEk3WU/rtKXUbncLtdg6rVVNJnHwD88UhbIYU2KoxY0Dih0x+kIsmUKn2A==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-tmgrammar-test": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/vscode-tmgrammar-test/-/vscode-tmgrammar-test-0.1.3.tgz", + "integrity": "sha512-Wg6Pz+ePAT1O+F/A1Fc4wS5vY2X+HNtgN4qMdL+65NLQYd1/zdDWH4fhwsLjX8wTzeXkMy49Cr4ZqWTJ7VnVxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "bottleneck": "^2.19.5", + "chalk": "^2.4.2", + "commander": "^9.2.0", + "diff": "^4.0.2", + "glob": "^7.1.6", + "vscode-oniguruma": "^1.5.1", + "vscode-textmate": "^7.0.1" + }, + "bin": { + "vscode-tmgrammar-snap": "dist/snapshot.js", + "vscode-tmgrammar-test": "dist/unit.js" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-tmgrammar-test/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/vscode-tmgrammar-test/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/vscode-uri": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", diff --git a/package.json b/package.json index 2b36bcd7..ce770018 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "format": "prettier --write .", "test": "NODE_OPTIONS=--experimental-vm-modules jest", "test:extension": "node src/__e2e__/runTests.js", + "test:textmate": "npx vscode-tmgrammar-snap -s source.ts -g src/language-server/__tests__/fixtures/TypeScript.tmLanguage.json src/language-server/__tests__/fixtures/documents/*.ts", "codegen": "graphql-codegen", "vscode:prepublish": "npm run build:production" }, @@ -91,7 +92,8 @@ "rimraf": "6.0.1", "ts-jest": "29.1.2", "ts-node": "^10.9.2", - "typescript": "^5.5.3" + "typescript": "^5.5.3", + "vscode-tmgrammar-test": "^0.1.3" }, "publisher": "apollographql", "categories": [ diff --git a/sampleWorkspace/sampleWorkspace.code-workspace b/sampleWorkspace/sampleWorkspace.code-workspace index bd11d1c0..f1bfa090 100644 --- a/sampleWorkspace/sampleWorkspace.code-workspace +++ b/sampleWorkspace/sampleWorkspace.code-workspace @@ -1,23 +1,26 @@ { - "folders": [ - { - "path": "localSchema" - }, - { - "path": "clientSchema" - }, - { - "path": "spotifyGraph" - }, - { - "path": "httpSchema" - }, - { - "path": "localSchemaArray" - }, - { - "path": "rover" - } - ], - "settings": {} -} \ No newline at end of file + "folders": [ + { + "path": "localSchema" + }, + { + "path": "clientSchema" + }, + { + "path": "spotifyGraph" + }, + { + "path": "httpSchema" + }, + { + "path": "localSchemaArray" + }, + { + "path": "rover" + }, + { + "path": "../src/language-server/__tests__/fixtures/documents" + } + ], + "settings": {} +} diff --git a/src/language-server/__tests__/document.test.ts b/src/language-server/__tests__/document.test.ts index 360dc8b1..03dfbd4c 100644 --- a/src/language-server/__tests__/document.test.ts +++ b/src/language-server/__tests__/document.test.ts @@ -1,5 +1,8 @@ -import { extractGraphQLDocuments } from "../document"; +import { readFileSync } from "fs"; +import { extractGraphQLDocuments, GraphQLDocument } from "../document"; import { TextDocument, Position } from "vscode-languageserver"; +import { join } from "path"; +import { DocumentNode, OperationDefinitionNode } from "graphql"; describe("extractGraphQLDocuments", () => { describe("extracting documents from JavaScript template literals", () => { @@ -38,6 +41,18 @@ describe("extractGraphQLDocuments", () => { expect(documents?.length).toEqual(1); expect(documents?.[0].syntaxErrors.length).toBe(0); expect(documents?.[0].ast?.definitions.length).toBe(1); + expect(replaceWhitespaceWithDots(documents![0].source.body)) + .toMatchInlineSnapshot(` +" +········{ +··········hero·{ +············...Hero_character +··········} +········} + +············································· +······" +`); }); it("works with multiple placeholders in a document", () => { @@ -65,6 +80,26 @@ describe("extractGraphQLDocuments", () => { expect(documents?.length).toEqual(1); expect(documents?.[0].syntaxErrors.length).toBe(0); expect(documents?.[0].ast?.definitions.length).toBe(2); + expect(replaceWhitespaceWithDots(documents![0].source.body)) + .toMatchInlineSnapshot(` +" +········{ +··········hero·{ +············...Hero_character +··········} +········} + +·································· + +········{ +··········reviews(episode:·NEWHOPE)·{ +············...ReviewList_reviews +··········} +········} + +······································ +······" +`); }); it("works with a custom tagname", () => { @@ -90,8 +125,28 @@ describe("extractGraphQLDocuments", () => { const documents = extractGraphQLDocuments(textDocument, "gqltag"); expect(documents?.length).toEqual(1); - expect(documents?.[0].syntaxErrors.length).toBe(0); - expect(documents?.[0].ast?.definitions.length).toBe(2); + expect(documents![0].syntaxErrors.length).toBe(0); + expect(documents![0].ast?.definitions.length).toBe(2); + expect(replaceWhitespaceWithDots(documents![0].source.body)) + .toMatchInlineSnapshot(` +" +········{ +··········hero·{ +············...Hero_character +··········} +········} + +·································· + +········{ +··········reviews(episode:·NEWHOPE)·{ +············...ReviewList_reviews +··········} +········} + +······································ +······" +`); }); it("works with parens", () => { @@ -119,6 +174,101 @@ describe("extractGraphQLDocuments", () => { expect(documents?.length).toEqual(1); expect(documents?.[0].syntaxErrors.length).toBe(0); expect(documents?.[0].ast?.definitions.length).toBe(2); + expect(replaceWhitespaceWithDots(documents![0].source.body)) + .toMatchInlineSnapshot(` +" +········{ +··········hero·{ +············...Hero_character +··········} +········} + +·································· + +········{ +··········reviews(episode:·NEWHOPE)·{ +············...ReviewList_reviews +··········} +········} + +···································· +····" +`); + }); + + test("fixtures", () => { + function loadFixture(name: string) { + const path = join(__dirname, "fixtures", "documents", name); + const body = readFileSync(path, "utf8"); + + return extractGraphQLDocuments( + TextDocument.create(`file://${path}.js`, "javascript", 1, body), + )!; + } + function documentName(document: GraphQLDocument) { + expect(document.syntaxErrors.length).toBe(0); + let first = document.ast?.definitions[0]; + expect(first).toBeDefined(); + expect(first!.kind).toBe("OperationDefinition"); + first = first as OperationDefinitionNode; + return (first.name && first.name.value) || "Unnamed"; + } + + expect(loadFixture("commentWithTemplate.ts").map(documentName)) + .toMatchInlineSnapshot(` +Array [ + "Q1", + "Q2", + "Q3", + "Q4", + "Q6", + "Q8", + "Q9", + "Q10", +] +`); + expect(loadFixture("functionCall.ts").map(documentName)) + .toMatchInlineSnapshot(` +Array [ + "Q2", + "Q3", + "Q4", + "Q5", + "Q6", + "Q7", + "Q9", + "Q10", + "Q11", +] +`); + expect(loadFixture("taggedTemplate.ts").map(documentName)) + .toMatchInlineSnapshot(` +Array [ + "Foo", + "Q1", + "Q2", + "Q3", + "Q4", + "Q5", + "Q6", + "Q7", + "Q8", + "Q9", + "Q10", + "Q11", +] +`); + expect(loadFixture("templateWithComment.ts").map(documentName)) + .toMatchInlineSnapshot(` +Array [ + "Q1", + "Q2", + "Q3", + "Q4", + "Q5", + "Q6", +] +`); }); }); @@ -185,3 +335,11 @@ describe("extractGraphQLDocuments", () => { }); }); }); + +/** + * When editing this file manually, prettier will remove long bouts of whitespace in template strings on save, + * which messes up inline snapshots. This function replaces spaces with dots to prevent that. + */ +function replaceWhitespaceWithDots(str: string) { + return str.replace(/[ ]/g, "·"); +} diff --git a/src/language-server/__tests__/fixtures/TypeScript.tmLanguage.json b/src/language-server/__tests__/fixtures/TypeScript.tmLanguage.json new file mode 100644 index 00000000..e8c0c880 --- /dev/null +++ b/src/language-server/__tests__/fixtures/TypeScript.tmLanguage.json @@ -0,0 +1,5749 @@ +{ + "license": [ + "taken from https://github.com/microsoft/vscode/blob/6ab1a1e4fefffb25fe15ed33dcf5ae6322043b40/extensions/typescript-basics/syntaxes/TypeScript.tmLanguage.json", + "MIT License", + "Copyright (c) 2015 - present Microsoft Corporation", + "full license at https://github.com/microsoft/vscode/blob/6ab1a1e4fefffb25fe15ed33dcf5ae6322043b40/LICENSE.txt" + ], + "information_for_contributors": [ + "This file has been converted from https://github.com/microsoft/TypeScript-TmLanguage/blob/master/TypeScript.tmLanguage", + "If you want to provide a fix or improvement, please create a pull request against the original repository.", + "Once accepted there, we are happy to receive an update request." + ], + "version": "https://github.com/microsoft/TypeScript-TmLanguage/commit/b80b7509a78e642f789c567e144ed951ab98b4e3", + "name": "TypeScript", + "scopeName": "source.ts", + "patterns": [ + { + "include": "#directives" + }, + { + "include": "#statements" + }, + { + "include": "#shebang" + } + ], + "repository": { + "shebang": { + "name": "comment.line.shebang.ts", + "match": "\\A(#!).*(?=$)", + "captures": { + "1": { + "name": "punctuation.definition.comment.ts" + } + } + }, + "statements": { + "patterns": [ + { + "include": "#declaration" + }, + { + "include": "#control-statement" + }, + { + "include": "#after-operator-block-as-object-literal" + }, + { + "include": "#decl-block" + }, + { + "include": "#label" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation-semicolon" + }, + { + "include": "#string" + }, + { + "include": "#comment" + } + ] + }, + "declaration": { + "patterns": [ + { + "include": "#decorator" + }, + { + "include": "#var-expr" + }, + { + "include": "#function-declaration" + }, + { + "include": "#class-declaration" + }, + { + "include": "#interface-declaration" + }, + { + "include": "#enum-declaration" + }, + { + "include": "#namespace-declaration" + }, + { + "include": "#type-alias-declaration" + }, + { + "include": "#import-equals-declaration" + }, + { + "include": "#import-declaration" + }, + { + "include": "#export-declaration" + }, + { + "name": "storage.modifier.ts", + "match": "(?)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*))))))) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "beginCaptures": { + "1": { + "name": "meta.definition.variable.ts entity.name.function.ts" + }, + "2": { + "name": "keyword.operator.definiteassignment.ts" + } + }, + "end": "(?=$|^|[;,=}]|((?)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*))))))) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "beginCaptures": { + "1": { + "name": "meta.definition.variable.ts variable.other.constant.ts entity.name.function.ts" + } + }, + "end": "(?=$|^|[;,=}]|((?)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*))))))) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "keyword.operator.rest.ts" + }, + "3": { + "name": "entity.name.function.ts variable.language.this.ts" + }, + "4": { + "name": "entity.name.function.ts" + }, + "5": { + "name": "keyword.operator.optional.ts" + } + } + }, + { + "match": "(?x)(?:(?)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*))))))) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "meta.definition.property.ts entity.name.function.ts" + }, + "2": { + "name": "keyword.operator.optional.ts" + }, + "3": { + "name": "keyword.operator.definiteassignment.ts" + } + } + }, + { + "name": "meta.definition.property.ts variable.object.property.ts", + "match": "\\#?[_$[:alpha:]][_$[:alnum:]]*" + }, + { + "name": "keyword.operator.optional.ts", + "match": "\\?" + }, + { + "name": "keyword.operator.definiteassignment.ts", + "match": "\\!" + } + ] + }, + "variable-initializer": { + "patterns": [ + { + "begin": "(?\\s*$)", + "beginCaptures": { + "1": { + "name": "keyword.operator.assignment.ts" + } + }, + "end": "(?=$|^|[,);}\\]]|((?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*))?[\\(])", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "storage.modifier.ts" + }, + "4": { + "name": "storage.modifier.async.ts" + }, + "5": { + "name": "keyword.operator.new.ts" + }, + "6": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + }, + { + "name": "meta.method.declaration.ts", + "begin": "(?x)(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*))?[\\(])", + "beginCaptures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "storage.modifier.ts" + }, + "4": { + "name": "storage.modifier.async.ts" + }, + "5": { + "name": "storage.type.property.ts" + }, + "6": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\}|;|,|$)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + } + ] + } + ] + }, + "object-literal-method-declaration": { + "name": "meta.method.declaration.ts", + "begin": "(?x)(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*))?[\\(])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + }, + "2": { + "name": "storage.type.property.ts" + }, + "3": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\}|;|,)|(?<=\\})", + "patterns": [ + { + "include": "#method-declaration-name" + }, + { + "include": "#function-body" + }, + { + "begin": "(?x)(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*))?[\\(])", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + }, + "2": { + "name": "storage.type.property.ts" + }, + "3": { + "name": "keyword.generator.asterisk.ts" + } + }, + "end": "(?=\\(|\\<)", + "patterns": [ + { + "include": "#method-declaration-name" + } + ] + } + ] + }, + "method-declaration-name": { + "begin": "(?x)(?=((\\b(?)", + "captures": { + "1": { + "name": "storage.modifier.async.ts" + }, + "2": { + "name": "variable.parameter.ts" + } + } + }, + { + "name": "meta.arrow.ts", + "begin": "(?x) (?:\n (? is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n )\n)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + }, + { + "include": "#function-parameters" + }, + { + "include": "#arrow-return-type" + }, + { + "include": "#possibly-arrow-return-type" + } + ] + }, + { + "name": "meta.arrow.ts", + "begin": "=>", + "beginCaptures": { + "0": { + "name": "storage.type.function.arrow.ts" + } + }, + "end": "((?<=\\}|\\S)(?)|((?!\\{)(?=\\S)))(?!\\/[\\/\\*])", + "patterns": [ + { + "include": "#single-line-comment-consuming-line-ending" + }, + { + "include": "#decl-block" + }, + { + "include": "#expression" + } + ] + } + ] + }, + "indexer-declaration": { + "name": "meta.indexer.declaration.ts", + "begin": "(?:(?]|^await|[^\\._$[:alnum:]]await|^return|[^\\._$[:alnum:]]return|^yield|[^\\._$[:alnum:]]yield|^throw|[^\\._$[:alnum:]]throw|^in|[^\\._$[:alnum:]]in|^of|[^\\._$[:alnum:]]of|^typeof|[^\\._$[:alnum:]]typeof|&&|\\|\\||\\*)\\s*(\\{)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.block.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, + "patterns": [ + { + "include": "#object-member" + } + ] + }, + "object-literal": { + "name": "meta.objectliteral.ts", + "begin": "\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.block.ts" + } + }, + "patterns": [ + { + "include": "#object-member" + } + ] + }, + "object-member": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#object-literal-method-declaration" + }, + { + "name": "meta.object.member.ts meta.object-literal.key.ts", + "begin": "(?=\\[)", + "end": "(?=:)|((?<=[\\]])(?=\\s*[\\(\\<]))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#array-literal" + } + ] + }, + { + "name": "meta.object.member.ts meta.object-literal.key.ts", + "begin": "(?=[\\'\\\"\\`])", + "end": "(?=:)|((?<=[\\'\\\"\\`])(?=((\\s*[\\(\\<,}])|(\\s+(as|satisifies)\\s+))))", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + } + ] + }, + { + "name": "meta.object.member.ts meta.object-literal.key.ts", + "begin": "(?x)(?=(\\b(?)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "0": { + "name": "meta.object-literal.key.ts" + }, + "1": { + "name": "entity.name.function.ts" + } + } + }, + { + "name": "meta.object.member.ts", + "match": "(?:[_$[:alpha:]][_$[:alnum:]]*)\\s*(?=(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*:)", + "captures": { + "0": { + "name": "meta.object-literal.key.ts" + } + } + }, + { + "name": "meta.object.member.ts", + "begin": "\\.\\.\\.", + "beginCaptures": { + "0": { + "name": "keyword.operator.spread.ts" + } + }, + "end": "(?=,|\\})", + "patterns": [ + { + "include": "#expression" + } + ] + }, + { + "name": "meta.object.member.ts", + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?=,|\\}|$|\\/\\/|\\/\\*)", + "captures": { + "1": { + "name": "variable.other.readwrite.ts" + } + } + }, + { + "name": "meta.object.member.ts", + "match": "(?]|\\|\\||\\&\\&|\\!\\=\\=|$|^|((?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)\\(\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#type-parameters" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + } + ] + }, + { + "begin": "(?<=:)\\s*(async)?\\s*(\\()(?=\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + }, + "2": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + }, + { + "begin": "(?<=:)\\s*(async)?\\s*(?=\\<\\s*$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?<=\\>)", + "patterns": [ + { + "include": "#type-parameters" + } + ] + }, + { + "begin": "(?<=\\>)\\s*(\\()(?=\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))", + "beginCaptures": { + "1": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + }, + { + "include": "#possibly-arrow-return-type" + }, + { + "include": "#expression" + } + ] + }, + { + "include": "#punctuation-comma" + }, + { + "include": "#decl-block" + } + ] + }, + "ternary-expression": { + "begin": "(?!\\?\\.\\s*[^[:digit:]])(\\?)(?!\\?)", + "beginCaptures": { + "1": { + "name": "keyword.operator.ternary.ts" + } + }, + "end": "\\s*(:)", + "endCaptures": { + "1": { + "name": "keyword.operator.ternary.ts" + } + }, + "patterns": [ + { + "include": "#expression" + } + ] + }, + "function-call": { + "patterns": [ + { + "begin": "(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\\s*\\??\\.\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\\)]))\\s*(?:(\\?\\.\\s*)|(\\!))?((<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))(([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>)*(?))*(?)*(?\\s*)?\\())", + "end": "(?<=\\))(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\\s*\\??\\.\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\\)]))\\s*(?:(\\?\\.\\s*)|(\\!))?((<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))(([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>)*(?))*(?)*(?\\s*)?\\())", + "patterns": [ + { + "name": "meta.function-call.ts", + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)(\\s*\\??\\.\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*))", + "end": "(?=\\s*(?:(\\?\\.\\s*)|(\\!))?((<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))(([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>)*(?))*(?)*(?\\s*)?\\())", + "patterns": [ + { + "include": "#function-call-target" + } + ] + }, + { + "include": "#comment" + }, + { + "include": "#function-call-optionals" + }, + { + "include": "#type-arguments" + }, + { + "include": "#paren-expression" + } + ] + }, + { + "begin": "(?=(((([_$[:alpha:]][_$[:alnum:]]*)(\\s*\\??\\.\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\\)]))(<\\s*[\\{\\[\\(]\\s*$))", + "end": "(?<=\\>)(?!(((([_$[:alpha:]][_$[:alnum:]]*)(\\s*\\??\\.\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*))|(?<=[\\)]))(<\\s*[\\{\\[\\(]\\s*$))", + "patterns": [ + { + "name": "meta.function-call.ts", + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*)(\\s*\\??\\.\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*))*)|(\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*))", + "end": "(?=(<\\s*[\\{\\[\\(]\\s*$))", + "patterns": [ + { + "include": "#function-call-target" + } + ] + }, + { + "include": "#comment" + }, + { + "include": "#function-call-optionals" + }, + { + "include": "#type-arguments" + } + ] + } + ] + }, + "function-call-target": { + "patterns": [ + { + "include": "#support-function-call-identifiers" + }, + { + "name": "entity.name.function.ts", + "match": "(\\#?[_$[:alpha:]][_$[:alnum:]]*)" + } + ] + }, + "function-call-optionals": { + "patterns": [ + { + "name": "meta.function-call.ts punctuation.accessor.optional.ts", + "match": "\\?\\." + }, + { + "name": "meta.function-call.ts keyword.operator.definiteassignment.ts", + "match": "\\!" + } + ] + }, + "support-function-call-identifiers": { + "patterns": [ + { + "include": "#literal" + }, + { + "include": "#support-objects" + }, + { + "include": "#object-identifiers" + }, + { + "include": "#punctuation-accessor" + }, + { + "name": "keyword.operator.expression.import.ts", + "match": "(?:(?]|\\|\\||\\&\\&|\\!\\=\\=|$|((?]|\\|\\||\\&\\&|\\!\\=\\=|$|(===|!==|==|!=)|(([\\&\\~\\^\\|]\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s+instanceof(?![_$[:alnum:]])(?:(?=\\.\\.\\.)|(?!\\.)))|((?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*))?\\(\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#paren-expression-possibly-arrow-with-typeparameters" + } + ] + }, + { + "begin": "(?<=[(=,]|=>|^return|[^\\._$[:alnum:]]return)\\s*(async)?(?=\\s*((((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*))?\\()|(<)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)))\\s*$)", + "beginCaptures": { + "1": { + "name": "storage.modifier.async.ts" + } + }, + "end": "(?<=\\))", + "patterns": [ + { + "include": "#paren-expression-possibly-arrow-with-typeparameters" + } + ] + }, + { + "include": "#possibly-arrow-return-type" + } + ] + }, + "paren-expression-possibly-arrow-with-typeparameters": { + "patterns": [ + { + "include": "#type-parameters" + }, + { + "begin": "\\(", + "beginCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "meta.brace.round.ts" + } + }, + "patterns": [ + { + "include": "#expression-inside-possibly-arrow-parens" + } + ] + } + ] + }, + "expression-inside-possibly-arrow-parens": { + "patterns": [ + { + "include": "#expressionWithoutIdentifiers" + }, + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#decorator" + }, + { + "include": "#destructuring-parameter" + }, + { + "match": "(?)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)) |\n# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>\n(:\\s*(\n (<) |\n ([(]\\s*(\n ([)]) |\n (\\.\\.\\.) |\n ([_$[:alnum:]]+\\s*(\n ([:,?=])|\n ([)]\\s*=>)\n ))\n ))\n)) |\n(:\\s*(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*))))))) |\n(:\\s*(=>|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(<[^<>]*>)|[^<>(),=])+=\\s*(\n ((async\\s+)?(\n (function\\s*[(<*]) |\n (function\\s+) |\n ([_$[:alpha:]][_$[:alnum:]]*\\s*=>)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n)))", + "captures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "keyword.operator.rest.ts" + }, + "3": { + "name": "entity.name.function.ts variable.language.this.ts" + }, + "4": { + "name": "entity.name.function.ts" + }, + "5": { + "name": "keyword.operator.optional.ts" + } + } + }, + { + "match": "(?x)(?:(?)", + "captures": { + "1": { + "name": "meta.brace.angle.ts" + }, + "2": { + "name": "storage.modifier.ts" + }, + "3": { + "name": "meta.brace.angle.ts" + } + } + }, + { + "name": "cast.expr.ts", + "begin": "(?:(?*?\\&\\|\\^]|[^_$[:alnum:]](?:\\+\\+|\\-\\-)|[^\\+]\\+|[^\\-]\\-))\\s*(<)(?!)", + "endCaptures": { + "1": { + "name": "meta.brace.angle.ts" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "name": "cast.expr.ts", + "begin": "(?:(?<=^))\\s*(<)(?=[_$[:alpha:]][_$[:alnum:]]*\\s*>)", + "beginCaptures": { + "1": { + "name": "meta.brace.angle.ts" + } + }, + "end": "(\\>)", + "endCaptures": { + "1": { + "name": "meta.brace.angle.ts" + } + }, + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, + "expression-operators": { + "patterns": [ + { + "name": "keyword.control.flow.ts", + "match": "(?]|\\|\\||\\&\\&|\\!\\=\\=|$|((?>=|>>>=|\\|=" + }, + { + "name": "keyword.operator.bitwise.shift.ts", + "match": "<<|>>>|>>" + }, + { + "name": "keyword.operator.comparison.ts", + "match": "===|!==|==|!=" + }, + { + "name": "keyword.operator.relational.ts", + "match": "<=|>=|<>|<|>" + }, + { + "match": "(?<=[_$[:alnum:]])(\\!)\\s*(?:(/=)|(?:(/)(?![/*])))", + "captures": { + "1": { + "name": "keyword.operator.logical.ts" + }, + "2": { + "name": "keyword.operator.assignment.compound.ts" + }, + "3": { + "name": "keyword.operator.arithmetic.ts" + } + } + }, + { + "name": "keyword.operator.logical.ts", + "match": "\\!|&&|\\|\\||\\?\\?" + }, + { + "name": "keyword.operator.bitwise.ts", + "match": "\\&|~|\\^|\\|" + }, + { + "name": "keyword.operator.assignment.ts", + "match": "\\=" + }, + { + "name": "keyword.operator.decrement.ts", + "match": "--" + }, + { + "name": "keyword.operator.increment.ts", + "match": "\\+\\+" + }, + { + "name": "keyword.operator.arithmetic.ts", + "match": "%|\\*|/|-|\\+" + }, + { + "begin": "(?<=[_$[:alnum:])\\]])\\s*(?=(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)+(?:(/=)|(?:(/)(?![/*]))))", + "end": "(?:(/=)|(?:(/)(?!\\*([^\\*]|(\\*[^\\/]))*\\*\\/)))", + "endCaptures": { + "1": { + "name": "keyword.operator.assignment.compound.ts" + }, + "2": { + "name": "keyword.operator.arithmetic.ts" + } + }, + "patterns": [ + { + "include": "#comment" + } + ] + }, + { + "match": "(?<=[_$[:alnum:])\\]])\\s*(?:(/=)|(?:(/)(?![/*])))", + "captures": { + "1": { + "name": "keyword.operator.assignment.compound.ts" + }, + "2": { + "name": "keyword.operator.arithmetic.ts" + } + } + } + ] + }, + "typeof-operator": { + "begin": "(?:&|{\\?]|(extends\\s+)|$|;|^\\s*$|(?:^\\s*(?:abstract|async|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|break|case|catch|class|const|continue|declare|do|else|enum|export|finally|function|for|goto|if|import|interface|let|module|namespace|switch|return|throw|try|type|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|var|while)\\b))", + "patterns": [ + { + "include": "#type-arguments" + }, + { + "include": "#expression" + } + ] + }, + "literal": { + "patterns": [ + { + "include": "#numeric-literal" + }, + { + "include": "#boolean-literal" + }, + { + "include": "#null-literal" + }, + { + "include": "#undefined-literal" + }, + { + "include": "#numericConstant-literal" + }, + { + "include": "#array-literal" + }, + { + "include": "#this-literal" + }, + { + "include": "#super-literal" + } + ] + }, + "array-literal": { + "name": "meta.array.literal.ts", + "begin": "\\s*(\\[)", + "beginCaptures": { + "1": { + "name": "meta.brace.square.ts" + } + }, + "end": "\\]", + "endCaptures": { + "0": { + "name": "meta.brace.square.ts" + } + }, + "patterns": [ + { + "include": "#expression" + }, + { + "include": "#punctuation-comma" + } + ] + }, + "numeric-literal": { + "patterns": [ + { + "name": "constant.numeric.hex.ts", + "match": "\\b(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\\())\n |\n (?:(EPSILON|MAX_SAFE_INTEGER|MAX_VALUE|MIN_SAFE_INTEGER|MIN_VALUE|NEGATIVE_INFINITY|POSITIVE_INFINITY)\\b(?!\\$)))", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { + "name": "support.variable.property.ts" + }, + "4": { + "name": "support.constant.ts" + } + } + }, + { + "match": "(?)\n )) |\n ((async\\s*)?(\n ((<\\s*$)|((<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))))) |\n # sure shot arrow functions even if => is on new line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?\n [(]\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*\n (\n ([)]\\s*:) | # ():\n ((\\.\\.\\.\\s*)?[_$[:alpha:]][_$[:alnum:]]*\\s*:) # [(]param: | [(]...param:\n )\n) |\n\n# arrow function possible to detect only with => on same line\n(\n (<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)? # typeparameters\n \\(\\s*(\\/\\*([^\\*]|(\\*[^\\/]))*\\*\\/\\s*)*(([_$[:alpha:]]|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\.\\.\\.\\s*[_$[:alpha:]]))([^()\\'\\\"\\`]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))*)?\\) # parameters\n (\\s*:\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+)? # return type\n \\s*=> # arrow operator\n)\n ))\n))", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { + "name": "entity.name.function.ts" + } + } + }, + { + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\\#?[[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { + "name": "variable.other.constant.property.ts" + } + } + }, + { + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(\\#?[_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { + "name": "variable.other.property.ts" + } + } + }, + { + "name": "variable.other.constant.ts", + "match": "([[:upper:]][_$[:digit:][:upper:]]*)(?![_$[:alnum:]])" + }, + { + "name": "variable.other.readwrite.ts", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + } + ] + }, + "object-identifiers": { + "patterns": [ + { + "name": "support.class.ts", + "match": "([_$[:alpha:]][_$[:alnum:]]*)(?=\\s*\\??\\.\\s*prototype\\b(?!\\$))" + }, + { + "match": "(?x)(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))\\s*(?:\n (\\#?[[:upper:]][_$[:digit:][:upper:]]*) |\n (\\#?[_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" + }, + "3": { + "name": "variable.other.constant.object.property.ts" + }, + "4": { + "name": "variable.other.object.property.ts" + } + } + }, + { + "match": "(?x)(?:\n ([[:upper:]][_$[:digit:][:upper:]]*) |\n ([_$[:alpha:]][_$[:alnum:]]*)\n)(?=\\s*\\??\\.\\s*\\#?[_$[:alpha:]][_$[:alnum:]]*)", + "captures": { + "1": { + "name": "variable.other.constant.object.ts" + }, + "2": { + "name": "variable.other.object.ts" + } + } + } + ] + }, + "type-annotation": { + "patterns": [ + { + "name": "meta.type.annotation.ts", + "begin": "(:)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.ts" + } + }, + "end": "(?])|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", + "patterns": [ + { + "include": "#type" + } + ] + }, + { + "name": "meta.type.annotation.ts", + "begin": "(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.ts" + } + }, + "end": "(?])|(?=^\\s*$)|((?<=[\\}>\\]\\)]|[_$[:alpha:]])\\s*(?=\\{)))", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, + "parameter-type-annotation": { + "patterns": [ + { + "name": "meta.type.annotation.ts", + "begin": "(:)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.ts" + } + }, + "end": "(?=[,)])|(?==[^>])", + "patterns": [ + { + "include": "#type" + } + ] + } + ] + }, + "return-type": { + "patterns": [ + { + "name": "meta.return.type.ts", + "begin": "(?<=\\))\\s*(:)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "keyword.operator.type.annotation.ts" + } + }, + "end": "(?|\\{|(^\\s*(export|function|class|interface|let|var|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "possibly-arrow-return-type": { + "begin": "(?<=\\)|^)\\s*(:)(?=\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*=>)", + "beginCaptures": { + "1": { + "name": "meta.arrow.ts meta.return.type.arrow.ts keyword.operator.type.annotation.ts" + } + }, + "end": "(?==>|\\{|(^\\s*(export|function|class|interface|let|var|(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)|(?:\\bawait\\s+(?:\\busing(?=\\s+(?!in\\b|of\\b(?!\\s*(?:of\\b|=)))[_$[:alpha:]])\\b)\\b)|const|import|enum|namespace|module|type|abstract|declare)\\s+))", + "contentName": "meta.arrow.ts meta.return.type.arrow.ts", + "patterns": [ + { + "include": "#arrow-return-type-body" + } + ] + }, + "arrow-return-type-body": { + "patterns": [ + { + "begin": "(?<=[:])(?=\\s*\\{)", + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "type-parameters": { + "name": "meta.type.parameters.ts", + "begin": "(<)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.begin.ts" + } + }, + "end": "(>)", + "endCaptures": { + "1": { + "name": "punctuation.definition.typeparameters.end.ts" + } + }, + "patterns": [ + { + "include": "#comment" + }, + { + "name": "storage.modifier.ts", + "match": "(?)" + } + ] + }, + "type-arguments": { + "name": "meta.type.parameters.ts", + "begin": "\\<", + "beginCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.begin.ts" + } + }, + "end": "\\>", + "endCaptures": { + "0": { + "name": "punctuation.definition.typeparameters.end.ts" + } + }, + "patterns": [ + { + "include": "#type-arguments-body" + } + ] + }, + "type-arguments-body": { + "patterns": [ + { + "match": "(?)\n ))\n ))\n)) |\n(:\\s*(?]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<]|\\<\\s*(((const\\s+)?[_$[:alpha:]])|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\]))([^=<>]|=[^<])*\\>)*\\>)*>\\s*)?[\\(]\\s*((([\\{\\[]\\s*)?$)|((\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})\\s*((:\\s*\\{?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*)))|((\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])\\s*((:\\s*\\[?$)|((\\s*([^<>\\(\\)\\{\\}]|\\<([^<>]|\\<([^<>]|\\<[^<>]+\\>)+\\>)+\\>|\\([^\\(\\)]+\\)|\\{[^\\{\\}]+\\})+\\s*)?=\\s*))))))))", + "captures": { + "1": { + "name": "storage.modifier.ts" + }, + "2": { + "name": "keyword.operator.rest.ts" + }, + "3": { + "name": "entity.name.function.ts variable.language.this.ts" + }, + "4": { + "name": "entity.name.function.ts" + }, + "5": { + "name": "keyword.operator.optional.ts" + } + } + }, + { + "match": "(?x)(?:(?)", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#type-parameters" + } + ] + }, + { + "name": "meta.type.constructor.ts", + "begin": "(?)\n ))\n )\n )\n)", + "end": "(?<=\\))", + "patterns": [ + { + "include": "#function-parameters" + } + ] + } + ] + }, + "type-function-return-type": { + "patterns": [ + { + "name": "meta.type.function.return.ts", + "begin": "(=>)(?=\\s*\\S)", + "beginCaptures": { + "1": { + "name": "storage.type.function.arrow.ts" + } + }, + "end": "(?)(?:\\?]|//|$)", + "patterns": [ + { + "include": "#type-function-return-type-core" + } + ] + }, + { + "name": "meta.type.function.return.ts", + "begin": "=>", + "beginCaptures": { + "0": { + "name": "storage.type.function.arrow.ts" + } + }, + "end": "(?)(?]|//|^\\s*$)|((?<=\\S)(?=\\s*$)))", + "patterns": [ + { + "include": "#type-function-return-type-core" + } + ] + } + ] + }, + "type-function-return-type-core": { + "patterns": [ + { + "include": "#comment" + }, + { + "begin": "(?<==>)(?=\\s*\\{)", + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "include": "#type-predicate-operator" + }, + { + "include": "#type" + } + ] + }, + "type-operators": { + "patterns": [ + { + "include": "#typeof-operator" + }, + { + "include": "#type-infer" + }, + { + "begin": "([&|])(?=\\s*\\{)", + "beginCaptures": { + "0": { + "name": "keyword.operator.type.ts" + } + }, + "end": "(?<=\\})", + "patterns": [ + { + "include": "#type-object" + } + ] + }, + { + "begin": "[&|]", + "beginCaptures": { + "0": { + "name": "keyword.operator.type.ts" + } + }, + "end": "(?=\\S)" + }, + { + "name": "keyword.operator.expression.keyof.ts", + "match": "(?)", + "endCaptures": { + "1": { + "name": "meta.type.parameters.ts punctuation.definition.typeparameters.end.ts" + } + }, + "contentName": "meta.type.parameters.ts", + "patterns": [ + { + "include": "#type-arguments-body" + } + ] + }, + { + "begin": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(<)", + "beginCaptures": { + "1": { + "name": "entity.name.type.ts" + }, + "2": { + "name": "meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts" + } + }, + "end": "(>)", + "endCaptures": { + "1": { + "name": "meta.type.parameters.ts punctuation.definition.typeparameters.end.ts" + } + }, + "contentName": "meta.type.parameters.ts", + "patterns": [ + { + "include": "#type-arguments-body" + } + ] + }, + { + "match": "([_$[:alpha:]][_$[:alnum:]]*)\\s*(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "entity.name.type.module.ts" + }, + "2": { + "name": "punctuation.accessor.ts" + }, + "3": { + "name": "punctuation.accessor.optional.ts" + } + } + }, + { + "name": "entity.name.type.ts", + "match": "[_$[:alpha:]][_$[:alnum:]]*" + } + ] + }, + "punctuation-comma": { + "name": "punctuation.separator.comma.ts", + "match": "," + }, + "punctuation-semicolon": { + "name": "punctuation.terminator.statement.ts", + "match": ";" + }, + "punctuation-accessor": { + "match": "(?:(\\.)|(\\?\\.(?!\\s*[[:digit:]])))", + "captures": { + "1": { + "name": "punctuation.accessor.ts" + }, + "2": { + "name": "punctuation.accessor.optional.ts" + } + } + }, + "string": { + "patterns": [ + { + "include": "#qstring-single" + }, + { + "include": "#qstring-double" + }, + { + "include": "#template" + } + ] + }, + "qstring-double": { + "name": "string.quoted.double.ts", + "begin": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.ts" + } + }, + "end": "(\")|((?:[^\\\\\\n])$)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.ts" + }, + "2": { + "name": "invalid.illegal.newline.ts" + } + }, + "patterns": [ + { + "include": "#string-character-escape" + } + ] + }, + "qstring-single": { + "name": "string.quoted.single.ts", + "begin": "'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.ts" + } + }, + "end": "(\\')|((?:[^\\\\\\n])$)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.ts" + }, + "2": { + "name": "invalid.illegal.newline.ts" + } + }, + "patterns": [ + { + "include": "#string-character-escape" + } + ] + }, + "string-character-escape": { + "name": "constant.character.escape.ts", + "match": "\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|u\\{[0-9A-Fa-f]+\\}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.|$)" + }, + "template": { + "patterns": [ + { + "include": "#template-call" + }, + { + "contentName": "string.template.ts", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.ts" + }, + "2": { + "name": "string.template.ts punctuation.definition.string.template.begin.ts" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "string.template.ts punctuation.definition.string.template.end.ts" + } + }, + "patterns": [ + { + "include": "#template-substitution-element" + }, + { + "include": "#string-character-escape" + } + ] + } + ] + }, + "template-call": { + "patterns": [ + { + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*)(<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))(([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>)*(?))*(?)*(?\\s*)?`)", + "end": "(?=`)", + "patterns": [ + { + "begin": "(?=(([_$[:alpha:]][_$[:alnum:]]*\\s*\\??\\.\\s*)*|(\\??\\.\\s*)?)([_$[:alpha:]][_$[:alnum:]]*))", + "end": "(?=(<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))(([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>)*(?))*(?)*(?\\s*)?`)", + "patterns": [ + { + "include": "#support-function-call-identifiers" + }, + { + "name": "entity.name.function.tagged-template.ts", + "match": "([_$[:alpha:]][_$[:alnum:]]*)" + } + ] + }, + { + "include": "#type-arguments" + } + ] + }, + { + "begin": "([_$[:alpha:]][_$[:alnum:]]*)?\\s*(?=(<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))(([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>|\\<\\s*(((keyof|infer|typeof|readonly)\\s+)|(([_$[:alpha:]][_$[:alnum:]]*|(\\{([^\\{\\}]|(\\{([^\\{\\}]|\\{[^\\{\\}]*\\})*\\}))*\\})|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(\\[([^\\[\\]]|(\\[([^\\[\\]]|\\[[^\\[\\]]*\\])*\\]))*\\])|(\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`))(?=\\s*([\\<\\>\\,\\.\\[]|=>|&(?!&)|\\|(?!\\|)))))([^<>\\(]|(\\(([^\\(\\)]|(\\(([^\\(\\)]|\\([^\\(\\)]*\\))*\\)))*\\))|(?<==)\\>)*(?))*(?)*(?\\s*)`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.ts" + } + }, + "end": "(?=`)", + "patterns": [ + { + "include": "#type-arguments" + } + ] + } + ] + }, + "template-substitution-element": { + "name": "meta.template.expression.ts", + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.template-expression.begin.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.template-expression.end.ts" + } + }, + "patterns": [ + { + "include": "#expression" + } + ], + "contentName": "meta.embedded.line.ts" + }, + "type-string": { + "patterns": [ + { + "include": "#qstring-single" + }, + { + "include": "#qstring-double" + }, + { + "include": "#template-type" + } + ] + }, + "template-type": { + "patterns": [ + { + "include": "#template-call" + }, + { + "contentName": "string.template.ts", + "begin": "([_$[:alpha:]][_$[:alnum:]]*)?(`)", + "beginCaptures": { + "1": { + "name": "entity.name.function.tagged-template.ts" + }, + "2": { + "name": "string.template.ts punctuation.definition.string.template.begin.ts" + } + }, + "end": "`", + "endCaptures": { + "0": { + "name": "string.template.ts punctuation.definition.string.template.end.ts" + } + }, + "patterns": [ + { + "include": "#template-type-substitution-element" + }, + { + "include": "#string-character-escape" + } + ] + } + ] + }, + "template-type-substitution-element": { + "name": "meta.template.expression.ts", + "begin": "\\$\\{", + "beginCaptures": { + "0": { + "name": "punctuation.definition.template-expression.begin.ts" + } + }, + "end": "\\}", + "endCaptures": { + "0": { + "name": "punctuation.definition.template-expression.end.ts" + } + }, + "patterns": [ + { + "include": "#type" + } + ], + "contentName": "meta.embedded.line.ts" + }, + "regex": { + "patterns": [ + { + "name": "string.regexp.ts", + "begin": "(?|&&|\\|\\||\\*\\/)\\s*(\\/)(?![\\/*])(?=(?:[^\\/\\\\\\[\\()]|\\\\.|\\[([^\\]\\\\]|\\\\.)+\\]|\\(([^\\)\\\\]|\\\\.)+\\))+\\/([dgimsuy]+|(?![\\/\\*])|(?=\\/\\*))(?!\\s*[a-zA-Z0-9_$]))", + "beginCaptures": { + "1": { + "name": "punctuation.definition.string.begin.ts" + } + }, + "end": "(/)([dgimsuy]*)", + "endCaptures": { + "1": { + "name": "punctuation.definition.string.end.ts" + }, + "2": { + "name": "keyword.other.ts" + } + }, + "patterns": [ + { + "include": "#regexp" + } + ] + }, + { + "name": "string.regexp.ts", + "begin": "((?", + "captures": { + "0": { + "name": "keyword.other.back-reference.regexp" + }, + "1": { + "name": "variable.other.regexp" + } + } + }, + { + "name": "keyword.operator.quantifier.regexp", + "match": "[?+*]|\\{(\\d+,\\d+|\\d+,|,\\d+|\\d+)\\}\\??" + }, + { + "name": "keyword.operator.or.regexp", + "match": "\\|" + }, + { + "name": "meta.group.assertion.regexp", + "begin": "(\\()((\\?=)|(\\?!)|(\\?<=)|(\\?))?", + "beginCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + }, + "1": { + "name": "punctuation.definition.group.no-capture.regexp" + }, + "2": { + "name": "variable.other.regexp" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.group.regexp" + } + }, + "patterns": [ + { + "include": "#regexp" + } + ] + }, + { + "name": "constant.other.character-class.set.regexp", + "begin": "(\\[)(\\^)?", + "beginCaptures": { + "1": { + "name": "punctuation.definition.character-class.regexp" + }, + "2": { + "name": "keyword.operator.negation.regexp" + } + }, + "end": "(\\])", + "endCaptures": { + "1": { + "name": "punctuation.definition.character-class.regexp" + } + }, + "patterns": [ + { + "name": "constant.other.character-class.range.regexp", + "match": "(?:.|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))\\-(?:[^\\]\\\\]|(\\\\(?:[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}))|(\\\\c[A-Z])|(\\\\.))", + "captures": { + "1": { + "name": "constant.character.numeric.regexp" + }, + "2": { + "name": "constant.character.control.regexp" + }, + "3": { + "name": "constant.character.escape.backslash.regexp" + }, + "4": { + "name": "constant.character.numeric.regexp" + }, + "5": { + "name": "constant.character.control.regexp" + }, + "6": { + "name": "constant.character.escape.backslash.regexp" + } + } + }, + { + "include": "#regex-character-class" + } + ] + }, + { + "include": "#regex-character-class" + } + ] + }, + "regex-character-class": { + "patterns": [ + { + "name": "constant.other.character-class.regexp", + "match": "\\\\[wWsSdDtrnvf]|\\." + }, + { + "name": "constant.character.numeric.regexp", + "match": "\\\\([0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4})" + }, + { + "name": "constant.character.control.regexp", + "match": "\\\\c[A-Z]" + }, + { + "name": "constant.character.escape.backslash.regexp", + "match": "\\\\." + } + ] + }, + "comment": { + "patterns": [ + { + "name": "comment.block.documentation.ts", + "begin": "/\\*\\*(?!/)", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.ts" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.ts" + } + }, + "patterns": [ + { + "include": "#docblock" + } + ] + }, + { + "name": "comment.block.ts", + "begin": "(/\\*)(?:\\s*((@)internal)(?=\\s|(\\*/)))?", + "beginCaptures": { + "1": { + "name": "punctuation.definition.comment.ts" + }, + "2": { + "name": "storage.type.internaldeclaration.ts" + }, + "3": { + "name": "punctuation.decorator.internaldeclaration.ts" + } + }, + "end": "\\*/", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.ts" + } + } + }, + { + "begin": "(^[ \\t]+)?((//)(?:\\s*((@)internal)(?=\\s|$))?)", + "beginCaptures": { + "1": { + "name": "punctuation.whitespace.comment.leading.ts" + }, + "2": { + "name": "comment.line.double-slash.ts" + }, + "3": { + "name": "punctuation.definition.comment.ts" + }, + "4": { + "name": "storage.type.internaldeclaration.ts" + }, + "5": { + "name": "punctuation.decorator.internaldeclaration.ts" + } + }, + "end": "(?=$)", + "contentName": "comment.line.double-slash.ts" + } + ] + }, + "single-line-comment-consuming-line-ending": { + "begin": "(^[ \\t]+)?((//)(?:\\s*((@)internal)(?=\\s|$))?)", + "beginCaptures": { + "1": { + "name": "punctuation.whitespace.comment.leading.ts" + }, + "2": { + "name": "comment.line.double-slash.ts" + }, + "3": { + "name": "punctuation.definition.comment.ts" + }, + "4": { + "name": "storage.type.internaldeclaration.ts" + }, + "5": { + "name": "punctuation.decorator.internaldeclaration.ts" + } + }, + "end": "(?=^)", + "contentName": "comment.line.double-slash.ts" + }, + "directives": { + "name": "comment.line.triple-slash.directive.ts", + "begin": "^(///)\\s*(?=<(reference|amd-dependency|amd-module)(\\s+(path|types|no-default-lib|lib|name|resolution-mode)\\s*=\\s*((\\'([^\\'\\\\]|\\\\.)*\\')|(\\\"([^\\\"\\\\]|\\\\.)*\\\")|(\\`([^\\`\\\\]|\\\\.)*\\`)))+\\s*/>\\s*$)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.comment.ts" + } + }, + "end": "(?=$)", + "patterns": [ + { + "name": "meta.tag.ts", + "begin": "(<)(reference|amd-dependency|amd-module)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.tag.directive.ts" + }, + "2": { + "name": "entity.name.tag.directive.ts" + } + }, + "end": "/>", + "endCaptures": { + "0": { + "name": "punctuation.definition.tag.directive.ts" + } + }, + "patterns": [ + { + "name": "entity.other.attribute-name.directive.ts", + "match": "path|types|no-default-lib|lib|name|resolution-mode" + }, + { + "name": "keyword.operator.assignment.ts", + "match": "=" + }, + { + "include": "#string" + } + ] + } + ] + }, + "docblock": { + "patterns": [ + { + "match": "(?x)\n((@)(?:access|api))\n\\s+\n(private|protected|public)\n\\b", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "constant.language.access-type.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)author)\n\\s+\n(\n [^@\\s<>*/]\n (?:[^@<>*/]|\\*[^/])*\n)\n(?:\n \\s*\n (<)\n ([^>\\s]+)\n (>)\n)?", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "entity.name.type.instance.jsdoc" + }, + "4": { + "name": "punctuation.definition.bracket.angle.begin.jsdoc" + }, + "5": { + "name": "constant.other.email.link.underline.jsdoc" + }, + "6": { + "name": "punctuation.definition.bracket.angle.end.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)borrows) \\s+\n((?:[^@\\s*/]|\\*[^/])+) # \n\\s+ (as) \\s+ # as\n((?:[^@\\s*/]|\\*[^/])+) # ", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "entity.name.type.instance.jsdoc" + }, + "4": { + "name": "keyword.operator.control.jsdoc" + }, + "5": { + "name": "entity.name.type.instance.jsdoc" + } + } + }, + { + "name": "meta.example.jsdoc", + "begin": "((@)example)\\s+", + "end": "(?=@|\\*/)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "patterns": [ + { + "match": "^\\s\\*\\s+" + }, + { + "contentName": "constant.other.description.jsdoc", + "begin": "\\G(<)caption(>)", + "beginCaptures": { + "0": { + "name": "entity.name.tag.inline.jsdoc" + }, + "1": { + "name": "punctuation.definition.bracket.angle.begin.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.angle.end.jsdoc" + } + }, + "end": "()|(?=\\*/)", + "endCaptures": { + "0": { + "name": "entity.name.tag.inline.jsdoc" + }, + "1": { + "name": "punctuation.definition.bracket.angle.begin.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.angle.end.jsdoc" + } + } + }, + { + "match": "[^\\s@*](?:[^*]|\\*[^/])*", + "captures": { + "0": { + "name": "source.embedded.ts" + } + } + } + ] + }, + { + "match": "(?x) ((@)kind) \\s+ (class|constant|event|external|file|function|member|mixin|module|namespace|typedef) \\b", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "constant.language.symbol-type.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)see)\n\\s+\n(?:\n # URL\n (\n (?=https?://)\n (?:[^\\s*]|\\*[^/])+\n )\n |\n # JSDoc namepath\n (\n (?!\n # Avoid matching bare URIs (also acceptable as links)\n https?://\n |\n # Avoid matching {@inline tags}; we match those below\n (?:\\[[^\\[\\]]*\\])? # Possible description [preceding]{@tag}\n {@(?:link|linkcode|linkplain|tutorial)\\b\n )\n # Matched namepath\n (?:[^@\\s*/]|\\*[^/])+\n )\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.link.underline.jsdoc" + }, + "4": { + "name": "entity.name.type.instance.jsdoc" + } + } + }, + { + "match": "(?x)\n((@)template)\n\\s+\n# One or more valid identifiers\n(\n [A-Za-z_$] # First character: non-numeric word character\n [\\w$.\\[\\]]* # Rest of identifier\n (?: # Possible list of additional identifiers\n \\s* , \\s*\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n )*\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + } + } + }, + { + "begin": "(?x)((@)template)\\s+(?={)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "end": "(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])", + "patterns": [ + { + "include": "#jsdoctype" + }, + { + "name": "variable.other.jsdoc", + "match": "([A-Za-z_$][\\w$.\\[\\]]*)" + } + ] + }, + { + "match": "(?x)\n(\n (@)\n (?:arg|argument|const|constant|member|namespace|param|var)\n)\n\\s+\n(\n [A-Za-z_$]\n [\\w$.\\[\\]]*\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + } + } + }, + { + "begin": "((@)typedef)\\s+(?={)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "end": "(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])", + "patterns": [ + { + "include": "#jsdoctype" + }, + { + "name": "entity.name.type.instance.jsdoc", + "match": "(?:[^@\\s*/]|\\*[^/])+" + } + ] + }, + { + "begin": "((@)(?:arg|argument|const|constant|member|namespace|param|prop|property|var))\\s+(?={)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "end": "(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])", + "patterns": [ + { + "include": "#jsdoctype" + }, + { + "name": "variable.other.jsdoc", + "match": "([A-Za-z_$][\\w$.\\[\\]]*)" + }, + { + "name": "variable.other.jsdoc", + "match": "(?x)\n(\\[)\\s*\n[\\w$]+\n(?:\n (?:\\[\\])? # Foo[ ].bar properties within an array\n \\. # Foo.Bar namespaced parameter\n [\\w$]+\n)*\n(?:\n \\s*\n (=) # [foo=bar] Default parameter value\n \\s*\n (\n # The inner regexes are to stop the match early at */ and to not stop at escaped quotes\n (?>\n \"(?:(?:\\*(?!/))|(?:\\\\(?!\"))|[^*\\\\])*?\" | # [foo=\"bar\"] Double-quoted\n '(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted\n \\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal\n (?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else\n )*\n )\n)?\n\\s*(?:(\\])((?:[^*\\s]|\\*[^\\s/])+)?|(?=\\*/))", + "captures": { + "1": { + "name": "punctuation.definition.optional-value.begin.bracket.square.jsdoc" + }, + "2": { + "name": "keyword.operator.assignment.jsdoc" + }, + "3": { + "name": "source.embedded.ts" + }, + "4": { + "name": "punctuation.definition.optional-value.end.bracket.square.jsdoc" + }, + "5": { + "name": "invalid.illegal.syntax.jsdoc" + } + } + } + ] + }, + { + "begin": "(?x)\n(\n (@)\n (?:define|enum|exception|export|extends|lends|implements|modifies\n |namespace|private|protected|returns?|satisfies|suppress|this|throws|type\n |yields?)\n)\n\\s+(?={)", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + }, + "end": "(?=\\s|\\*/|[^{}\\[\\]A-Za-z_$])", + "patterns": [ + { + "include": "#jsdoctype" + } + ] + }, + { + "match": "(?x)\n(\n (@)\n (?:alias|augments|callback|constructs|emits|event|fires|exports?\n |extends|external|function|func|host|lends|listens|interface|memberof!?\n |method|module|mixes|mixin|name|requires|see|this|typedef|uses)\n)\n\\s+\n(\n (?:\n [^{}@\\s*] | \\*[^/]\n )+\n)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "entity.name.type.instance.jsdoc" + } + } + }, + { + "contentName": "variable.other.jsdoc", + "begin": "((@)(?:default(?:value)?|license|version))\\s+(([''\"]))", + "beginCaptures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + }, + "4": { + "name": "punctuation.definition.string.begin.jsdoc" + } + }, + "end": "(\\3)|(?=$|\\*/)", + "endCaptures": { + "0": { + "name": "variable.other.jsdoc" + }, + "1": { + "name": "punctuation.definition.string.end.jsdoc" + } + } + }, + { + "match": "((@)(?:default(?:value)?|license|tutorial|variation|version))\\s+([^\\s*]+)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + }, + "3": { + "name": "variable.other.jsdoc" + } + } + }, + { + "name": "storage.type.class.jsdoc", + "match": "(?x) (@) (?:abstract|access|alias|api|arg|argument|async|attribute|augments|author|beta|borrows|bubbles |callback|chainable|class|classdesc|code|config|const|constant|constructor|constructs|copyright |default|defaultvalue|define|deprecated|desc|description|dict|emits|enum|event|example|exception |exports?|extends|extension(?:_?for)?|external|externs|file|fileoverview|final|fires|for|func |function|generator|global|hideconstructor|host|ignore|implements|implicitCast|inherit[Dd]oc |inner|instance|interface|internal|kind|lends|license|listens|main|member|memberof!?|method |mixes|mixins?|modifies|module|name|namespace|noalias|nocollapse|nocompile|nosideeffects |override|overview|package|param|polymer(?:Behavior)?|preserve|private|prop|property|protected |public|read[Oo]nly|record|require[ds]|returns?|see|since|static|struct|submodule|summary |suppress|template|this|throws|todo|tutorial|type|typedef|unrestricted|uses|var|variation |version|virtual|writeOnce|yields?) \\b", + "captures": { + "1": { + "name": "punctuation.definition.block.tag.jsdoc" + } + } + }, + { + "include": "#inline-tags" + }, + { + "match": "((@)(?:[_$[:alpha:]][_$[:alnum:]]*))(?=\\s+)", + "captures": { + "1": { + "name": "storage.type.class.jsdoc" + }, + "2": { + "name": "punctuation.definition.block.tag.jsdoc" + } + } + } + ] + }, + "brackets": { + "patterns": [ + { + "begin": "{", + "end": "}|(?=\\*/)", + "patterns": [ + { + "include": "#brackets" + } + ] + }, + { + "begin": "\\[", + "end": "\\]|(?=\\*/)", + "patterns": [ + { + "include": "#brackets" + } + ] + } + ] + }, + "inline-tags": { + "patterns": [ + { + "name": "constant.other.description.jsdoc", + "match": "(\\[)[^\\]]+(\\])(?={@(?:link|linkcode|linkplain|tutorial))", + "captures": { + "1": { + "name": "punctuation.definition.bracket.square.begin.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.square.end.jsdoc" + } + } + }, + { + "name": "entity.name.type.instance.jsdoc", + "begin": "({)((@)(?:link(?:code|plain)?|tutorial))\\s*", + "beginCaptures": { + "1": { + "name": "punctuation.definition.bracket.curly.begin.jsdoc" + }, + "2": { + "name": "storage.type.class.jsdoc" + }, + "3": { + "name": "punctuation.definition.inline.tag.jsdoc" + } + }, + "end": "}|(?=\\*/)", + "endCaptures": { + "0": { + "name": "punctuation.definition.bracket.curly.end.jsdoc" + } + }, + "patterns": [ + { + "match": "\\G((?=https?://)(?:[^|}\\s*]|\\*[/])+)(\\|)?", + "captures": { + "1": { + "name": "variable.other.link.underline.jsdoc" + }, + "2": { + "name": "punctuation.separator.pipe.jsdoc" + } + } + }, + { + "match": "\\G((?:[^{}@\\s|*]|\\*[^/])+)(\\|)?", + "captures": { + "1": { + "name": "variable.other.description.jsdoc" + }, + "2": { + "name": "punctuation.separator.pipe.jsdoc" + } + } + } + ] + } + ] + }, + "jsdoctype": { + "patterns": [ + { + "contentName": "entity.name.type.instance.jsdoc", + "begin": "\\G({)", + "beginCaptures": { + "0": { + "name": "entity.name.type.instance.jsdoc" + }, + "1": { + "name": "punctuation.definition.bracket.curly.begin.jsdoc" + } + }, + "end": "((}))\\s*|(?=\\*/)", + "endCaptures": { + "1": { + "name": "entity.name.type.instance.jsdoc" + }, + "2": { + "name": "punctuation.definition.bracket.curly.end.jsdoc" + } + }, + "patterns": [ + { + "include": "#brackets" + } + ] + } + ] + } + } +} diff --git a/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts b/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts new file mode 100644 index 00000000..6a03cf60 --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts @@ -0,0 +1,41 @@ +// hint for reading the snapshots generated by this file: +// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +// but also leaves it again + +/* NormalComment */ `query Foo {test}`; + +// prettier-ignore +{ +const _1 = /* GraphQL */`query Q1 {test}`; +const _2 = +/* GraphQL */` +query Q2 { + test +} +`; +} + +/* GraphQL */ `query Q3 {test}`; +/*GraphQL*/ `query Q4 {test}`; +/** GraphQL */ `query Q5 {test}`; + +const _3 = /* GraphQL */ ` + query Q6 { + test + } +`; + +// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this + +/** + * GraphQL + */ `query Q7 {test}`; + +/* GraphQL */ +`query Q8 {test}`; + +/* graphql */ +`query Q9 {test}`; + +/* gql */ +`query Q10 {test}`; diff --git a/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts.snap b/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts.snap new file mode 100644 index 00000000..8b2010be --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/commentWithTemplate.ts.snap @@ -0,0 +1,185 @@ +>// hint for reading the snapshots generated by this file: +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// but also leaves it again +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +> +>/* NormalComment */ `query Foo {test}`; +#^^ source.ts comment.block.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^ source.ts comment.block.ts +# ^^ source.ts comment.block.ts punctuation.definition.comment.ts +# ^ source.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>{ +#^ source.ts meta.block.ts punctuation.definition.block.ts +>const _1 = /* GraphQL */`query Q1 {test}`; +#^^^^^ source.ts meta.block.ts meta.var.expr.ts storage.type.ts +# ^ source.ts meta.block.ts meta.var.expr.ts +# ^^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts +# ^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts +# ^ source.ts meta.block.ts meta.var.expr.ts keyword.operator.assignment.ts +# ^ source.ts meta.block.ts meta.var.expr.ts +# ^^^ source.ts meta.block.ts meta.var.expr.ts +# ^^^^^^^ source.ts meta.block.ts meta.var.expr.ts markup.italic +# ^^^^ source.ts meta.block.ts meta.var.expr.ts +# ^^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql +# ^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts +# ^ source.ts meta.block.ts punctuation.terminator.statement.ts +>const _2 = +#^^^^^ source.ts meta.block.ts meta.var.expr.ts storage.type.ts +# ^ source.ts meta.block.ts meta.var.expr.ts +# ^^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts +# ^ source.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts +# ^ source.ts meta.block.ts meta.var.expr.ts keyword.operator.assignment.ts +>/* GraphQL */` +#^^^ source.ts meta.block.ts meta.var.expr.ts +# ^^^^^^^ source.ts meta.block.ts meta.var.expr.ts markup.italic +# ^^^^ source.ts meta.block.ts meta.var.expr.ts +>query Q2 { +#^^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql +# ^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +>} +#^ source.ts meta.block.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +>`; +#^ source.ts meta.block.ts meta.var.expr.ts +# ^ source.ts meta.block.ts punctuation.terminator.statement.ts +>} +#^ source.ts meta.block.ts punctuation.definition.block.ts +> +>/* GraphQL */ `query Q3 {test}`; +#^^^ source.ts +# ^^^^^^^ source.ts markup.italic +# ^^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +>/*GraphQL*/ `query Q4 {test}`; +#^^ source.ts +# ^^^^^^^ source.ts markup.italic +# ^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +>/** GraphQL */ `query Q5 {test}`; +#^^^^ source.ts +# ^^^^^^^ source.ts markup.italic +# ^^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>const _3 = /* GraphQL */ ` +#^^^^^ source.ts meta.var.expr.ts storage.type.ts +# ^ source.ts meta.var.expr.ts +# ^^ source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts +# ^ source.ts meta.var.expr.ts meta.var-single-variable.expr.ts +# ^ source.ts meta.var.expr.ts keyword.operator.assignment.ts +# ^ source.ts meta.var.expr.ts +# ^^^ source.ts meta.var.expr.ts +# ^^^^^^^ source.ts meta.var.expr.ts markup.italic +# ^^^^^ source.ts meta.var.expr.ts +> query Q6 { +#^^ source.ts meta.var.expr.ts meta.embedded.block.graphql +# ^^^^^ source.ts meta.var.expr.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.var.expr.ts meta.embedded.block.graphql +# ^^ source.ts meta.var.expr.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^^^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +> } +#^^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.var.expr.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +>`; +#^ source.ts meta.var.expr.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +> +>/** +#^^^ source.ts comment.block.documentation.ts punctuation.definition.comment.ts +> * GraphQL +#^^^^^^^^^^^ source.ts comment.block.documentation.ts +> */ `query Q7 {test}`; +#^ source.ts comment.block.documentation.ts +# ^^ source.ts comment.block.documentation.ts punctuation.definition.comment.ts +# ^ source.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>/* GraphQL */ +#^^ source.ts comment.block.ts punctuation.definition.comment.ts +# ^^^^^^^^^ source.ts comment.block.ts +# ^^ source.ts comment.block.ts punctuation.definition.comment.ts +>`query Q8 {test}`; +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>/* graphql */ +#^^ source.ts comment.block.ts punctuation.definition.comment.ts +# ^^^^^^^^^ source.ts comment.block.ts +# ^^ source.ts comment.block.ts punctuation.definition.comment.ts +>`query Q9 {test}`; +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>/* gql */ +#^^ source.ts comment.block.ts punctuation.definition.comment.ts +# ^^^^^ source.ts comment.block.ts +# ^^ source.ts comment.block.ts punctuation.definition.comment.ts +>`query Q10 {test}`; +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> \ No newline at end of file diff --git a/src/language-server/__tests__/fixtures/documents/functionCall.ts b/src/language-server/__tests__/fixtures/documents/functionCall.ts new file mode 100644 index 00000000..9a578d1b --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/functionCall.ts @@ -0,0 +1,93 @@ +// hint for reading the snapshots generated by this file: +// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +// but also leaves it again + +declare function gql(arg: string, ...args: any[]): void; +declare function foo(...args: any[]): void; +declare type SomeResult = any; +declare type SomeVariables = any; + +// for comparison - this is what a normal function all is colored +foo(`query Foo { test }`); + +// if possible, these should look the same +foo("notATemplate"); +gql("notATemplate"); +foo<"">("notATemplate"); +gql<"">("notATemplate"); + +// prettier-ignore +gql(`query Q1($arg: String!) { test }`) + +// prettier-ignore +gql(`query Q2 { test }`) + +// prettier-ignore +gql ( `query Q3 { test }` ) + +gql(` + query Q4 { + test + } +`); + +// prettier-ignore +gql ( ` + query Q5 { + test + } +` ); + +// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this + +gql< + { + test: string; + }, + { + test: string; + } +>(` + query Q6 { + test + } +`); + +// prettier-ignore +gql( +` + query Q7 { + test + } +` +); + +gql( + // ts-ignore + ` + query Q8 { + test + } +`, + `query {}`, +); + +// prettier-ignore +gql<{ + test: string; +},{ + test: string; +}>(`query Q9 { test }`) + +// prettier-ignore +gql( +`query Q10 { test }` +) + +// prettier-ignore +gql +( + `query Q11 { test }` + ) + +export {}; diff --git a/src/language-server/__tests__/fixtures/documents/functionCall.ts.snap b/src/language-server/__tests__/fixtures/documents/functionCall.ts.snap new file mode 100644 index 00000000..b521f100 --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/functionCall.ts.snap @@ -0,0 +1,431 @@ +>// hint for reading the snapshots generated by this file: +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// but also leaves it again +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +> +>declare function gql(arg: string, ...args: any[]): void; +#^^^^^^^ source.ts meta.function.ts storage.modifier.ts +# ^ source.ts meta.function.ts +# ^^^^^^^^ source.ts meta.function.ts storage.type.function.ts +# ^ source.ts meta.function.ts +# ^^^ source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts +# ^^^ source.ts meta.function.ts meta.parameters.ts variable.parameter.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts +# ^^^^^^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.separator.parameter.ts +# ^ source.ts meta.function.ts meta.parameters.ts +# ^^^ source.ts meta.function.ts meta.parameters.ts keyword.operator.rest.ts +# ^^^^ source.ts meta.function.ts meta.parameters.ts variable.parameter.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts +# ^^^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.type.tuple.ts meta.brace.square.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.type.tuple.ts meta.brace.square.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts +# ^ source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.return.type.ts +# ^^^^ source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +>declare function foo(...args: any[]): void; +#^^^^^^^ source.ts meta.function.ts storage.modifier.ts +# ^ source.ts meta.function.ts +# ^^^^^^^^ source.ts meta.function.ts storage.type.function.ts +# ^ source.ts meta.function.ts +# ^^^ source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts +# ^^^ source.ts meta.function.ts meta.parameters.ts keyword.operator.rest.ts +# ^^^^ source.ts meta.function.ts meta.parameters.ts variable.parameter.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts +# ^^^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.type.tuple.ts meta.brace.square.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts meta.type.tuple.ts meta.brace.square.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts +# ^ source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.return.type.ts +# ^^^^ source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +>declare type SomeResult = any; +#^^^^^^^ source.ts meta.type.declaration.ts storage.modifier.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^ source.ts meta.type.declaration.ts storage.type.type.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^^^^^^^ source.ts meta.type.declaration.ts entity.name.type.alias.ts +# ^ source.ts meta.type.declaration.ts +# ^ source.ts meta.type.declaration.ts keyword.operator.assignment.ts +# ^ source.ts meta.type.declaration.ts +# ^^^ source.ts meta.type.declaration.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +>declare type SomeVariables = any; +#^^^^^^^ source.ts meta.type.declaration.ts storage.modifier.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^ source.ts meta.type.declaration.ts storage.type.type.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^^^^^^^^^^ source.ts meta.type.declaration.ts entity.name.type.alias.ts +# ^ source.ts meta.type.declaration.ts +# ^ source.ts meta.type.declaration.ts keyword.operator.assignment.ts +# ^ source.ts meta.type.declaration.ts +# ^^^ source.ts meta.type.declaration.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// for comparison - this is what a normal function all is colored +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>foo(`query Foo { test }`); +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// if possible, these should look the same +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>foo("notATemplate"); +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.begin.ts +# ^^^^^^^^^^^^ source.ts string.quoted.double.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +>gql("notATemplate"); +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.begin.ts +# ^^^^^^^^^^^^ source.ts string.quoted.double.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +>foo<"">("notATemplate"); +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.type.parameters.ts string.quoted.double.ts punctuation.definition.string.begin.ts +# ^ source.ts meta.type.parameters.ts string.quoted.double.ts punctuation.definition.string.end.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.begin.ts +# ^^^^^^^^^^^^ source.ts string.quoted.double.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +>gql<"">("notATemplate"); +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.type.parameters.ts string.quoted.double.ts punctuation.definition.string.begin.ts +# ^ source.ts meta.type.parameters.ts string.quoted.double.ts punctuation.definition.string.end.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.begin.ts +# ^^^^^^^^^^^^ source.ts string.quoted.double.ts +# ^ source.ts string.quoted.double.ts punctuation.definition.string.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql(`query Q1($arg: String!) { test }`) +#^^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.brace.round.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.variables.graphql variable.parameter.graphql +# ^ source.ts meta.embedded.block.graphql meta.variables.graphql punctuation.colon.graphql +# ^ source.ts meta.embedded.block.graphql meta.variables.graphql +# ^^^^^^ source.ts meta.embedded.block.graphql meta.variables.graphql support.type.builtin.graphql +# ^ source.ts meta.embedded.block.graphql meta.variables.graphql keyword.operator.nulltype.graphql +# ^ source.ts meta.embedded.block.graphql meta.brace.round.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^ source.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql(`query Q2 { test }`) +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^ source.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql ( `query Q3 { test }` ) +#^^^^^^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^^ source.ts +> +>gql(` +#^^^^^ source.ts +> query Q4 { +#^^ source.ts meta.embedded.block.graphql +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +> } +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +>`); +#^^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql ( ` +#^^^^^^^^ source.ts +> query Q5 { +#^^ source.ts meta.embedded.block.graphql +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +> } +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +>` ); +#^^^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +> +>gql< +#^^^ source.ts variable.other.readwrite.ts +# ^ source.ts keyword.operator.relational.ts +> { +#^^ source.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +> test: string; +#^^^^ source.ts meta.block.ts +# ^^^^ source.ts meta.block.ts entity.name.label.ts +# ^ source.ts meta.block.ts punctuation.separator.label.ts +# ^ source.ts meta.block.ts +# ^^^^^^ source.ts meta.block.ts variable.other.readwrite.ts +# ^ source.ts meta.block.ts punctuation.terminator.statement.ts +> }, +#^^ source.ts meta.block.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +# ^ source.ts punctuation.separator.comma.ts +> { +#^^ source.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +> test: string; +#^^^^ source.ts meta.block.ts +# ^^^^ source.ts meta.block.ts entity.name.label.ts +# ^ source.ts meta.block.ts punctuation.separator.label.ts +# ^ source.ts meta.block.ts +# ^^^^^^ source.ts meta.block.ts variable.other.readwrite.ts +# ^ source.ts meta.block.ts punctuation.terminator.statement.ts +> } +#^^ source.ts meta.block.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +>>(` +#^ source.ts keyword.operator.relational.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +> query Q6 { +#^^^^^^^^^^^^^ source.ts string.template.ts +> test +#^^^^^^^^^ source.ts string.template.ts +> } +#^^^^ source.ts string.template.ts +>`); +#^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql( +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.brace.round.ts +>` +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +> query Q7 { +#^^^^^^^^^^^^^ source.ts string.template.ts +> test +#^^^^^^^^^ source.ts string.template.ts +> } +#^^^^ source.ts string.template.ts +>` +#^ source.ts string.template.ts punctuation.definition.string.template.end.ts +>); +#^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>gql( +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^^^^^^^^^^ source.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.type.parameters.ts +# ^^^^^^^^^^^^^ source.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.brace.round.ts +> // ts-ignore +#^^ source.ts punctuation.whitespace.comment.leading.ts +# ^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^ source.ts comment.line.double-slash.ts +> ` +#^^ source.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +> query Q8 { +#^^^^^^^^^^^^^ source.ts string.template.ts +> test +#^^^^^^^^^ source.ts string.template.ts +> } +#^^^^ source.ts string.template.ts +>`, +#^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.separator.comma.ts +> `query {}`, +#^^ source.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.separator.comma.ts +>); +#^ source.ts meta.brace.round.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql<{ +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +> test: string; +#^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts +# ^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts +# ^^^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.terminator.statement.ts +>},{ +#^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +# ^ source.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +> test: string; +#^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts +# ^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts +# ^^^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.terminator.statement.ts +>}>(`query Q9 { test }`) +#^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.brace.round.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts meta.brace.round.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql( +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.brace.round.ts +>`query Q10 { test }` +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +>) +#^ source.ts meta.brace.round.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql +#^^^ source.ts variable.other.readwrite.ts +>( +#^ source.ts meta.brace.round.ts +> `query { test }` +#^^ source.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +> ) +#^^ source.ts +# ^ source.ts meta.brace.round.ts +> +>export {}; +#^^^^^^ source.ts meta.export.ts keyword.control.export.ts +# ^ source.ts meta.export.ts +# ^ source.ts meta.export.ts meta.block.ts punctuation.definition.block.ts +# ^ source.ts meta.export.ts meta.block.ts punctuation.definition.block.ts +# ^ source.ts punctuation.terminator.statement.ts +> \ No newline at end of file diff --git a/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts b/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts new file mode 100644 index 00000000..93216fb0 --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts @@ -0,0 +1,80 @@ +// hint for reading the snapshots generated by this file: +// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +// but also leaves it again + +declare function gql(strings: TemplateStringsArray): void; +declare function foo(strings: TemplateStringsArray): void; +declare type SomeResult = any; +declare type SomeVariables = any; + +// for comparison - this is what a normal function all is colored +foo`query Foo { test }`; +foo`query Foo { test }`; + +// prettier-ignore +gql`query Q1 { test }` + +// prettier-ignore +gql`query Q2 { test }` + +// prettier-ignore +gql ` +query Q3 { test }` + +// prettier-ignore +gql `query Q4 { test }` + +gql` + query Q5 { + test + } +`; + +gql` + query Q6 { + test + } +`; + +// prettier-ignore +gql ` + query Q7 { + test + } +`; + +// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this + +// prettier-ignore +gql +`query Q8 { test }` + +// prettier-ignore +gql<{ + test: string; +},{ + test: string; +}>`query Q9 { test }` + +gql< + { + test: string; + }, + { + test: string; + } +>` + query Q10 { + test + } +`; + +// prettier-ignore +gql +` + query Q11 { + test + } +`; + +export {}; diff --git a/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts.snap b/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts.snap new file mode 100644 index 00000000..c299b23b --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/taggedTemplate.ts.snap @@ -0,0 +1,353 @@ +>// hint for reading the snapshots generated by this file: +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// but also leaves it again +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +> +>declare function gql(strings: TemplateStringsArray): void; +#^^^^^^^ source.ts meta.function.ts storage.modifier.ts +# ^ source.ts meta.function.ts +# ^^^^^^^^ source.ts meta.function.ts storage.type.function.ts +# ^ source.ts meta.function.ts +# ^^^ source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts +# ^^^^^^^ source.ts meta.function.ts meta.parameters.ts variable.parameter.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts +# ^^^^^^^^^^^^^^^^^^^^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts +# ^ source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.return.type.ts +# ^^^^ source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +>declare function foo(strings: TemplateStringsArray): void; +#^^^^^^^ source.ts meta.function.ts storage.modifier.ts +# ^ source.ts meta.function.ts +# ^^^^^^^^ source.ts meta.function.ts storage.type.function.ts +# ^ source.ts meta.function.ts +# ^^^ source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts keyword.operator.assignment.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts +# ^^^ source.ts meta.function.ts meta.type.parameters.ts support.type.primitive.ts +# ^ source.ts meta.function.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts +# ^^^^^^^ source.ts meta.function.ts meta.parameters.ts variable.parameter.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts +# ^^^^^^^^^^^^^^^^^^^^ source.ts meta.function.ts meta.parameters.ts meta.type.annotation.ts entity.name.type.ts +# ^ source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts +# ^ source.ts meta.function.ts meta.return.type.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.function.ts meta.return.type.ts +# ^^^^ source.ts meta.function.ts meta.return.type.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +>declare type SomeResult = any; +#^^^^^^^ source.ts meta.type.declaration.ts storage.modifier.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^ source.ts meta.type.declaration.ts storage.type.type.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^^^^^^^ source.ts meta.type.declaration.ts entity.name.type.alias.ts +# ^ source.ts meta.type.declaration.ts +# ^ source.ts meta.type.declaration.ts keyword.operator.assignment.ts +# ^ source.ts meta.type.declaration.ts +# ^^^ source.ts meta.type.declaration.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +>declare type SomeVariables = any; +#^^^^^^^ source.ts meta.type.declaration.ts storage.modifier.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^ source.ts meta.type.declaration.ts storage.type.type.ts +# ^ source.ts meta.type.declaration.ts +# ^^^^^^^^^^^^^ source.ts meta.type.declaration.ts entity.name.type.alias.ts +# ^ source.ts meta.type.declaration.ts +# ^ source.ts meta.type.declaration.ts keyword.operator.assignment.ts +# ^ source.ts meta.type.declaration.ts +# ^^^ source.ts meta.type.declaration.ts support.type.primitive.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// for comparison - this is what a normal function all is colored +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>foo`query Foo { test }`; +#^^^ source.ts entity.name.function.tagged-template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +>foo`query Foo { test }`; +#^^^ source.ts entity.name.function.tagged-template.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^^^^^^^^^^ source.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.type.parameters.ts +# ^^^^^^^^^^^^^ source.ts meta.type.parameters.ts entity.name.type.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql`query Q1 { test }` +#^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql`query Q2 { test }` +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql ` +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts +>query Q3 { test }` +#^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql `query Q4 { test }` +#^^^^^^^^ source.ts +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +> +>gql` +#^^^^ source.ts +> query Q5 { +#^^ source.ts meta.embedded.block.graphql +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +> } +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +>`; +#^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>gql` +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts +> query Q6 { +#^^ source.ts meta.embedded.block.graphql +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +> } +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +>`; +#^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql ` +#^^^^^^^ source.ts +> query Q7 { +#^^ source.ts meta.embedded.block.graphql +# ^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +> } +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +>`; +#^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql +#^^^ source.ts variable.other.readwrite.ts +>`query Q8 { test }` +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql<{ +#^^^ source.ts meta.function-call.ts entity.name.function.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.begin.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +> test: string; +#^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts +# ^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts +# ^^^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.terminator.statement.ts +>},{ +#^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +# ^ source.ts meta.type.parameters.ts punctuation.separator.comma.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +> test: string; +#^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts +# ^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.definition.property.ts variable.object.property.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts keyword.operator.type.annotation.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts +# ^^^^^^ source.ts meta.type.parameters.ts meta.object.type.ts meta.field.declaration.ts meta.type.annotation.ts support.type.primitive.ts +# ^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.terminator.statement.ts +>}>`query Q9 { test }` +#^ source.ts meta.type.parameters.ts meta.object.type.ts punctuation.definition.block.ts +# ^ source.ts meta.type.parameters.ts punctuation.definition.typeparameters.end.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +> +>gql< +#^^^ source.ts variable.other.readwrite.ts +# ^ source.ts keyword.operator.relational.ts +> { +#^^ source.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +> test: string; +#^^^^ source.ts meta.block.ts +# ^^^^ source.ts meta.block.ts entity.name.label.ts +# ^ source.ts meta.block.ts punctuation.separator.label.ts +# ^ source.ts meta.block.ts +# ^^^^^^ source.ts meta.block.ts variable.other.readwrite.ts +# ^ source.ts meta.block.ts punctuation.terminator.statement.ts +> }, +#^^ source.ts meta.block.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +# ^ source.ts punctuation.separator.comma.ts +> { +#^^ source.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +> test: string; +#^^^^ source.ts meta.block.ts +# ^^^^ source.ts meta.block.ts entity.name.label.ts +# ^ source.ts meta.block.ts punctuation.separator.label.ts +# ^ source.ts meta.block.ts +# ^^^^^^ source.ts meta.block.ts variable.other.readwrite.ts +# ^ source.ts meta.block.ts punctuation.terminator.statement.ts +> } +#^^ source.ts meta.block.ts +# ^ source.ts meta.block.ts punctuation.definition.block.ts +>>` +#^ source.ts keyword.operator.relational.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +> query Q10 { +#^^^^^^^^^^^^^^ source.ts string.template.ts +> test +#^^^^^^^^^ source.ts string.template.ts +> } +#^^^^ source.ts string.template.ts +>`; +#^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// prettier-ignore +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>gql +#^^^ source.ts variable.other.readwrite.ts +>` +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +> query Q11 { +#^^^^^^^^^^^^^^ source.ts string.template.ts +> test +#^^^^^^^^^ source.ts string.template.ts +> } +#^^^^ source.ts string.template.ts +>`; +#^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>export {}; +#^^^^^^ source.ts meta.export.ts keyword.control.export.ts +# ^ source.ts meta.export.ts +# ^ source.ts meta.export.ts meta.block.ts punctuation.definition.block.ts +# ^ source.ts meta.export.ts meta.block.ts punctuation.definition.block.ts +# ^ source.ts punctuation.terminator.statement.ts +> \ No newline at end of file diff --git a/src/language-server/__tests__/fixtures/documents/templateWithComment.ts b/src/language-server/__tests__/fixtures/documents/templateWithComment.ts new file mode 100644 index 00000000..ad7b8f2d --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/templateWithComment.ts @@ -0,0 +1,38 @@ +// hint for reading the snapshots generated by this file: +// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +// but also leaves it again + +`#NormalComment +query Foo {test}`; + +`#graphql +query Q1 {test}`; + +` # graphql +query Q2 {test}`; + +`# GraphQL +query Q3 { + test +}`; + +`#gql +# normal comment +query Q4 { + test +}`; + +`#graphql +query Q5 { + test +}`; + +// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this +` + +# graphql + +query Q6 { + test +} +`; diff --git a/src/language-server/__tests__/fixtures/documents/templateWithComment.ts.snap b/src/language-server/__tests__/fixtures/documents/templateWithComment.ts.snap new file mode 100644 index 00000000..43f7f8d0 --- /dev/null +++ b/src/language-server/__tests__/fixtures/documents/templateWithComment.ts.snap @@ -0,0 +1,123 @@ +>// hint for reading the snapshots generated by this file: +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// it is important to check that a rule doesn't only enter `meta.embedded.block.graphql` +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>// but also leaves it again +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +> +>`#NormalComment +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +# ^^^^^^^^^^^^^^^ source.ts string.template.ts +>query Foo {test}`; +#^^^^^^^^^^^^^^^^ source.ts string.template.ts +# ^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>`#graphql +#^ source.ts +# ^ source.ts meta.embedded.block.graphql comment.line.graphql.js +# ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic +>query Q1 {test}`; +#^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>` # graphql +#^ source.ts +# ^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js +# ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic +>query Q2 {test}`; +#^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>`# GraphQL +#^ source.ts +# ^^ source.ts meta.embedded.block.graphql comment.line.graphql.js +# ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic +>query Q3 { +#^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +>}`; +#^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>`#gql +#^ source.ts +# ^ source.ts meta.embedded.block.graphql comment.line.graphql.js +# ^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic +># normal comment +#^^^^^^^^^^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js +>query Q4 { +#^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +>}`; +#^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>`#graphql +#^ source.ts +# ^ source.ts meta.embedded.block.graphql comment.line.graphql.js +# ^^^^^^^ source.ts meta.embedded.block.graphql comment.line.graphql.js markup.italic +>query Q5 { +#^^^^^ source.ts meta.embedded.block.graphql keyword.operation.graphql +# ^ source.ts meta.embedded.block.graphql +# ^^ source.ts meta.embedded.block.graphql entity.name.function.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +> test +#^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql +# ^^^^ source.ts meta.embedded.block.graphql meta.selectionset.graphql variable.graphql +>}`; +#^ source.ts meta.embedded.block.graphql meta.selectionset.graphql punctuation.operation.graphql +# ^ source.ts +# ^ source.ts punctuation.terminator.statement.ts +> +>// syntax highlighting cannot work in all examples after this - textmate grammars don't work over multiple lines like this +#^^ source.ts comment.line.double-slash.ts punctuation.definition.comment.ts +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.ts comment.line.double-slash.ts +>` +#^ source.ts string.template.ts punctuation.definition.string.template.begin.ts +> +># graphql +#^^^^^^^^^^ source.ts string.template.ts +> +>query Q6 { +#^^^^^^^^^^^ source.ts string.template.ts +> test +#^^^^^^^ source.ts string.template.ts +>} +#^^ source.ts string.template.ts +>`; +#^ source.ts string.template.ts punctuation.definition.string.template.end.ts +# ^ source.ts punctuation.terminator.statement.ts +> \ No newline at end of file diff --git a/src/language-server/document.ts b/src/language-server/document.ts index 829cfacf..f3cf536d 100644 --- a/src/language-server/document.ts +++ b/src/language-server/document.ts @@ -15,6 +15,11 @@ import { } from "./utilities/source"; import { TextDocument } from "vscode-languageserver-textdocument"; +declare global { + interface RegExpExecArray { + indices?: Array<[number, number]>; + } +} export class GraphQLDocument { ast?: DocumentNode; syntaxErrors: Diagnostic[] = []; @@ -89,6 +94,17 @@ export function extractGraphQLDocuments( return sources.map((source) => new GraphQLDocument(source)); } +const parts = [ + // normal tagged template literals + /TAG_NAME\s*(?:<.*?>\s*)?`(.*?)`/, + // template string starting with a #TAG_NAME, #graphql or #GraphQL comment + /`(\s*#[ ]*(?:TAG_NAME|graphql|GraphQL).*?)`/, + // template string preceeded by a /* TAG_NAME */, /* graphql */ or /* GraphQL */ comment + /\/\*\s*(?:TAG_NAME|graphql|GraphQL)\s*\*\/\s?`(.*?)`/, + // function call to TAG_NAME with a single template string argument + /TAG_NAME\s*(?:<.*?>\s*)?\(\s*`(.*?)`\s*\)/, +].map((r) => r.source); + function extractGraphQLSourcesFromJSTemplateLiterals( document: TextDocument, tagName: string, @@ -98,20 +114,30 @@ function extractGraphQLSourcesFromJSTemplateLiterals( const sources: Source[] = []; const regExp = new RegExp( - `(?:${tagName}(?:\\s|\\()*\`|\`#graphql)([\\s\\S]+?)\`\\)?`, - "gm", + parts.map((r) => r.replace("TAG_NAME", tagName)).join("|"), + // g: global search + // s: treat `.` as any character, including newlines + // d: save indices + "gsd", ); let result; while ((result = regExp.exec(text)) !== null) { - const contents = replacePlaceholdersWithWhiteSpace(result[1]); - const position = document.positionAt(result.index + (tagName.length + 1)); + // we have multiple alternative capture groups in the regexp, and only one of them will have a result + // so we need the index for that + const groupIndex = result.findIndex( + (part, index) => index !== 0 && part != null, + ); + const contents = replacePlaceholdersWithWhiteSpace(result[groupIndex]); + const position = document.positionAt(result.indices![groupIndex][0]); const locationOffset: SourceLocation = { line: position.line + 1, column: position.character + 1, }; const source = new Source(contents, document.uri, locationOffset); - sources.push(source); + if (source.body.trim().length > 0) { + sources.push(source); + } } if (sources.length < 1) return null; diff --git a/syntaxes/graphql.js.json b/syntaxes/graphql.js.json index d24f52e1..3a30ee55 100644 --- a/syntaxes/graphql.js.json +++ b/syntaxes/graphql.js.json @@ -3,43 +3,40 @@ "injectionSelector": "L:source -string -comment", "patterns": [ { - "name": "taggedTemplates", "contentName": "meta.embedded.block.graphql", - "begin": "(Relay\\.QL|gql|graphql(\\.experimental)?)\\(?(`)", + "begin": "(?:Relay\\.QL|gql|graphql(\\.experimental)?)\\s*(?:<.*?>\\s*)?`", + "end": "`", + "patterns": [{ "include": "source.graphql" }] + }, + { + "contentName": "meta.embedded.block.graphql", + "begin": "`(\\s*#[ ]*(gql|graphql|GraphQL))", "beginCaptures": { "1": { - "name": "entity.name.function.tagged-template.js" + "name": "meta.embedded.block.graphql comment.line.graphql.js" }, "2": { - "name": "punctuation.definition.string.template.begin.js" - } - }, - "end": "`\\)?", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.template.end.js" + "name": "markup.italic" } }, + "end": "`", "patterns": [{ "include": "source.graphql" }] }, { - "name": "taggedTemplates", "contentName": "meta.embedded.block.graphql", - "begin": "(`)(#graphql)", + "begin": "(?:gql|graphql)\\s*(?:<.*?>\\s*)?\\(\\s*`", + "end": "`\\s*\\)", + "patterns": [{ "include": "source.graphql" }] + }, + { + "contentName": "meta.embedded.block.graphql", + "begin": "(?:\\/\\*[\\s\\*]*(gql|graphql|GraphQL)\\s*\\*\\/)\\s*(`)", "beginCaptures": { "1": { - "name": "punctuation.definition.string.template.begin.js" - }, - "2": { - "name": "comment.line.graphql.js" + "name": "markup.italic" } }, "end": "`", - "endCaptures": { - "0": { - "name": "punctuation.definition.string.template.end.js" - } - }, "patterns": [{ "include": "source.graphql" }] } ],