diff --git a/.vscode/settings.json b/.vscode/settings.json index c5ff74b927..e0cbe8c4d4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,17 +1,17 @@ -// Place your settings in this file to overwrite default and user settings. { + "[lua]": { + "editor.defaultFormatter": "JohnnyMorganz.stylua" + }, "[python]": { "editor.defaultFormatter": "charliermarsh.ruff" }, "[scm]": { - "editor.defaultFormatter": "AndreasArvidsson.andreas-talon" + "editor.defaultFormatter": "AndreasArvidsson.andreas-talon", + "editor.tabSize": 2 }, "[talon]": { "editor.defaultFormatter": "wenkokke.talonfmt-vscode" }, - "editor.defaultFormatter": "esbenp.prettier-vscode", - // Turn off tsc task auto detection since we have the necessary tasks as npm scripts - "typescript.tsc.autoDetect": "off", "cSpell.words": [ "Autoformatting", "camelize", @@ -22,14 +22,14 @@ "pojo", "subword" ], - "files.eol": "\n", - "typescript.enablePromptUseWorkspaceTsdk": true, - "typescript.tsdk": "node_modules/typescript/lib", + "editor.defaultFormatter": "esbenp.prettier-vscode", "eslint.workingDirectories": [{ "pattern": "packages/*/" }], - "[lua]": { - "editor.defaultFormatter": "JohnnyMorganz.stylua" - }, "files.associations": { ".busted": "lua" - } + }, + "files.eol": "\n", + "typescript.enablePromptUseWorkspaceTsdk": true, + "typescript.tsdk": "node_modules/typescript/lib", + // Turn off tsc task auto detection since we have the necessary tasks as npm scripts + "typescript.tsc.autoDetect": "off" } diff --git a/data/fixtures/scopes/javascript.core/interior.class.scope b/data/fixtures/scopes/javascript.core/interior.class.scope new file mode 100644 index 0000000000..5390112f29 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.class.scope @@ -0,0 +1,25 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Removal] = 0:11-0:12 + >-< +0| class Foo { } + +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:11-0:12 + >-< +0| class Foo { } + +[#2 Domain] = 0:10-0:13 + >---< +0| class Foo { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.function.scope b/data/fixtures/scopes/javascript.core/interior.function.scope new file mode 100644 index 0000000000..1a87486f13 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.function.scope @@ -0,0 +1,37 @@ +function foo() { } +--- + +[#1 Content] = +[#1 Removal] = 0:16-0:17 + >-< +0| function foo() { } + +[#1 Domain] = 0:0-0:18 + >------------------< +0| function foo() { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:13-0:13 + >< +0| function foo() { } + +[#2 Domain] = 0:12-0:14 + >--< +0| function foo() { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:16-0:17 + >-< +0| function foo() { } + +[#3 Domain] = 0:15-0:18 + >---< +0| function foo() { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.function2.scope b/data/fixtures/scopes/javascript.core/interior.function2.scope new file mode 100644 index 0000000000..b83489b042 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.function2.scope @@ -0,0 +1,81 @@ +class Foo { + bar() { } +} +--- + +[#1 Content] = 1:4-1:13 + >---------< +1| bar() { } + +[#1 Removal] = 0:11-2:0 + > +0| class Foo { +1| bar() { } +2| } + < + +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| bar() { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:13 + >---------< +1| bar() { } + +[#2 Removal] = 0:11-2:0 + > +0| class Foo { +1| bar() { } +2| } + < + +[#2 Domain] = 0:10-2:1 + >- +0| class Foo { +1| bar() { } +2| } + -< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:11-1:12 + >-< +1| bar() { } + +[#3 Domain] = 1:4-1:13 + >---------< +1| bar() { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:8-1:8 + >< +1| bar() { } + +[#4 Domain] = 1:7-1:9 + >--< +1| bar() { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:11-1:12 + >-< +1| bar() { } + +[#5 Domain] = 1:10-1:13 + >---< +1| bar() { } + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.if.scope b/data/fixtures/scopes/javascript.core/interior.if.scope new file mode 100644 index 0000000000..52ac91931a --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.if.scope @@ -0,0 +1,99 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Removal] = 0:11-0:12 + >-< +0| if (true) { } + +[#1 Domain] = 0:0-0:13 + >-------------< +0| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:4-0:8 + >----< +0| if (true) { } + +[#2 Domain] = 0:3-0:9 + >------< +0| if (true) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:11-0:12 + >-< +0| if (true) { } + +[#3 Domain] = 0:10-0:13 + >---< +0| if (true) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:17-1:18 + >-< +1| else if (false) { } + +[#4 Domain] = 1:0-1:19 + >-------------------< +1| else if (false) { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:9-1:14 + >-----< +1| else if (false) { } + +[#5 Domain] = 1:8-1:15 + >-------< +1| else if (false) { } + +[#5 Insertion delimiter] = " " + + +[#6 Content] = +[#6 Removal] = 1:17-1:18 + >-< +1| else if (false) { } + +[#6 Domain] = 1:16-1:19 + >---< +1| else if (false) { } + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 2:6-2:7 + >-< +2| else { } + +[#7 Domain] = 2:0-2:8 + >--------< +2| else { } + +[#7 Insertion delimiter] = " " + + +[#8 Content] = +[#8 Removal] = 2:6-2:7 + >-< +2| else { } + +[#8 Domain] = 2:5-2:8 + >---< +2| else { } + +[#8 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.lambda.scope b/data/fixtures/scopes/javascript.core/interior.lambda.scope new file mode 100644 index 0000000000..3e128b3d86 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.lambda.scope @@ -0,0 +1,37 @@ +() => { } +--- + +[#1 Content] = +[#1 Removal] = 0:1-0:1 + >< +0| () => { } + +[#1 Domain] = 0:0-0:2 + >--< +0| () => { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:7-0:8 + >-< +0| () => { } + +[#2 Domain] = 0:0-0:9 + >---------< +0| () => { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:7-0:8 + >-< +0| () => { } + +[#3 Domain] = 0:6-0:9 + >---< +0| () => { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.lambda2.scope b/data/fixtures/scopes/javascript.core/interior.lambda2.scope new file mode 100644 index 0000000000..6d85ffaf2f --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.lambda2.scope @@ -0,0 +1,25 @@ +() => 0; +--- + +[#1 Content] = +[#1 Removal] = 0:1-0:1 + >< +0| () => 0; + +[#1 Domain] = 0:0-0:2 + >--< +0| () => 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:6-0:7 + >-< +0| () => 0; + +[#2 Domain] = 0:0-0:7 + >-------< +0| () => 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.loop.scope b/data/fixtures/scopes/javascript.core/interior.loop.scope new file mode 100644 index 0000000000..e9ae933299 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.loop.scope @@ -0,0 +1,37 @@ +for (let i = 0; i < size; ++i) { } +--- + +[#1 Content] = +[#1 Removal] = 0:32-0:33 + >-< +0| for (let i = 0; i < size; ++i) { } + +[#1 Domain] = 0:0-0:34 + >----------------------------------< +0| for (let i = 0; i < size; ++i) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:29 + >------------------------< +0| for (let i = 0; i < size; ++i) { } + +[#2 Domain] = 0:4-0:30 + >--------------------------< +0| for (let i = 0; i < size; ++i) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:32-0:33 + >-< +0| for (let i = 0; i < size; ++i) { } + +[#3 Domain] = 0:31-0:34 + >---< +0| for (let i = 0; i < size; ++i) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.loop2.scope b/data/fixtures/scopes/javascript.core/interior.loop2.scope new file mode 100644 index 0000000000..3e16181107 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.loop2.scope @@ -0,0 +1,37 @@ +while (true) { } +--- + +[#1 Content] = +[#1 Removal] = 0:14-0:15 + >-< +0| while (true) { } + +[#1 Domain] = 0:0-0:16 + >----------------< +0| while (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:7-0:11 + >----< +0| while (true) { } + +[#2 Domain] = 0:6-0:12 + >------< +0| while (true) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:14-0:15 + >-< +0| while (true) { } + +[#3 Domain] = 0:13-0:16 + >---< +0| while (true) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.loop3.scope b/data/fixtures/scopes/javascript.core/interior.loop3.scope new file mode 100644 index 0000000000..d1833e59d1 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.loop3.scope @@ -0,0 +1,37 @@ +do { } while (true); +--- + +[#1 Content] = +[#1 Removal] = 0:4-0:5 + >-< +0| do { } while (true); + +[#1 Domain] = 0:0-0:20 + >--------------------< +0| do { } while (true); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:4-0:5 + >-< +0| do { } while (true); + +[#2 Domain] = 0:3-0:6 + >---< +0| do { } while (true); + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:14-0:18 + >----< +0| do { } while (true); + +[#3 Domain] = 0:13-0:19 + >------< +0| do { } while (true); + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.loop4.scope b/data/fixtures/scopes/javascript.core/interior.loop4.scope new file mode 100644 index 0000000000..c440342398 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.loop4.scope @@ -0,0 +1,37 @@ +for (const v of values) { } +--- + +[#1 Content] = +[#1 Removal] = 0:25-0:26 + >-< +0| for (const v of values) { } + +[#1 Domain] = 0:0-0:27 + >---------------------------< +0| for (const v of values) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:22 + >-----------------< +0| for (const v of values) { } + +[#2 Domain] = 0:4-0:23 + >-------------------< +0| for (const v of values) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:25-0:26 + >-< +0| for (const v of values) { } + +[#3 Domain] = 0:24-0:27 + >---< +0| for (const v of values) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.loop5.scope b/data/fixtures/scopes/javascript.core/interior.loop5.scope new file mode 100644 index 0000000000..83dc8c49b5 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.loop5.scope @@ -0,0 +1,37 @@ +for (const k in values) { } +--- + +[#1 Content] = +[#1 Removal] = 0:25-0:26 + >-< +0| for (const k in values) { } + +[#1 Domain] = 0:0-0:27 + >---------------------------< +0| for (const k in values) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:22 + >-----------------< +0| for (const k in values) { } + +[#2 Domain] = 0:4-0:23 + >-------------------< +0| for (const k in values) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:25-0:26 + >-< +0| for (const k in values) { } + +[#3 Domain] = 0:24-0:27 + >---< +0| for (const k in values) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.switchCase.scope b/data/fixtures/scopes/javascript.core/interior.switchCase.scope new file mode 100644 index 0000000000..58797959fa --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.switchCase.scope @@ -0,0 +1,181 @@ +switch (value) { + case 0: + foo; + break; + case 1: { + break; + } + default: + break; +} +--- + +[#1 Content] = 1:4-8:14 + >------- +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; + --------------< + +[#1 Removal] = 0:16-9:0 + > +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + < + +[#1 Domain] = 0:0-9:1 + >---------------- +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:8-0:13 + >-----< +0| switch (value) { + +[#2 Domain] = 0:7-0:14 + >-------< +0| switch (value) { + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:4-8:14 + >------- +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; + --------------< + +[#3 Removal] = 0:16-9:0 + > +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + < + +[#3 Domain] = 0:15-9:1 + >- +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + -< + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 2:8-3:14 + >---- +2| foo; +3| break; + --------------< + +[#4 Domain] = 1:4-3:14 + >------- +1| case 0: +2| foo; +3| break; + --------------< + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 5:8-5:14 + >------< +5| break; + +[#5 Removal] = 4:13-6:4 + > +4| case 1: { +5| break; +6| } + ----< + +[#5 Domain] = 4:4-6:5 + >--------- +4| case 1: { +5| break; +6| } + -----< + +[#5 Insertion delimiter] = " " + + +[#6 Content] = 5:8-5:14 + >------< +5| break; + +[#6 Removal] = 4:13-6:4 + > +4| case 1: { +5| break; +6| } + ----< + +[#6 Domain] = 4:12-6:5 + >- +4| case 1: { +5| break; +6| } + -----< + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 8:8-8:14 + >------< +8| break; + +[#7 Domain] = 7:4-8:14 + >-------- +7| default: +8| break; + --------------< + +[#7 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.ternary.scope b/data/fixtures/scopes/javascript.core/interior.ternary.scope new file mode 100644 index 0000000000..79ef01735b --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.ternary.scope @@ -0,0 +1,28 @@ +true ? 1 : 0; +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:4 + >----< +0| true ? 1 : 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:7-0:8 + >-< +0| true ? 1 : 0; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 0:11-0:12 + >-< +0| true ? 1 : 0; + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/interior.try.scope b/data/fixtures/scopes/javascript.core/interior.try.scope new file mode 100644 index 0000000000..3b5323b649 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/interior.try.scope @@ -0,0 +1,87 @@ +try { } +catch(e) { } +finally { } +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:6 + >-< +0| try { } + +[#1 Domain] = 0:0-0:7 + >-------< +0| try { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:6 + >-< +0| try { } + +[#2 Domain] = 0:4-0:7 + >---< +0| try { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:10-1:11 + >-< +1| catch(e) { } + +[#3 Domain] = 1:0-1:12 + >------------< +1| catch(e) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:6-1:7 + >-< +1| catch(e) { } + +[#4 Domain] = 1:5-1:8 + >---< +1| catch(e) { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:10-1:11 + >-< +1| catch(e) { } + +[#5 Domain] = 1:9-1:12 + >---< +1| catch(e) { } + +[#5 Insertion delimiter] = " " + + +[#6 Content] = +[#6 Removal] = 2:9-2:10 + >-< +2| finally { } + +[#6 Domain] = 2:0-2:11 + >-----------< +2| finally { } + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 2:9-2:10 + >-< +2| finally { } + +[#7 Domain] = 2:8-2:11 + >---< +2| finally { } + +[#7 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascriptreact/textFragment.element.scope b/data/fixtures/scopes/javascript.jsx/textFragment.element.scope similarity index 100% rename from data/fixtures/scopes/javascriptreact/textFragment.element.scope rename to data/fixtures/scopes/javascript.jsx/textFragment.element.scope diff --git a/data/fixtures/scopes/javascriptreact/textFragment.element2.scope b/data/fixtures/scopes/javascript.jsx/textFragment.element2.scope similarity index 100% rename from data/fixtures/scopes/javascriptreact/textFragment.element2.scope rename to data/fixtures/scopes/javascript.jsx/textFragment.element2.scope diff --git a/packages/common/src/scopeSupportFacets/javascript.ts b/packages/common/src/scopeSupportFacets/javascript.ts index 74cef5dd4b..140122842d 100644 --- a/packages/common/src/scopeSupportFacets/javascript.ts +++ b/packages/common/src/scopeSupportFacets/javascript.ts @@ -1,8 +1,7 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; +const { supported, notApplicable } = ScopeSupportFacetLevel; export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { list: supported, @@ -154,43 +153,55 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { "type.class": supported, - // Unsupported + "interior.class": supported, + "interior.function": supported, + "interior.if": supported, + "interior.lambda": supported, + "interior.loop": supported, + "interior.switchCase": supported, + "interior.ternary": supported, + "interior.try": supported, - "interior.class": unsupported, - "interior.function": unsupported, - "interior.if": unsupported, - "interior.lambda": unsupported, - "interior.loop": unsupported, - "interior.switchCase": unsupported, - "interior.ternary": unsupported, - "interior.try": unsupported, - - // Not applicable + /* NOT APPLICABLE (JS & TS) */ + // Nested the classes "class.iteration.block": notApplicable, "className.iteration.block": notApplicable, - "functionName.iteration.block": notApplicable, - "interior.cell": notApplicable, + + // Section + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + // Command + command: notApplicable, "interior.command": notApplicable, + + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Resource "interior.resource": notApplicable, - "name.argument.actual.iteration": notApplicable, - "name.argument.actual": notApplicable, "name.resource.iteration": notApplicable, "name.resource": notApplicable, - "namedFunction.iteration.block": notApplicable, - "section.iteration.document": notApplicable, - "section.iteration.parent": notApplicable, - "textFragment.element": notApplicable, "type.resource.iteration": notApplicable, "type.resource": notApplicable, - "value.argument.actual.iteration": notApplicable, - "value.argument.actual": notApplicable, "value.resource.iteration": notApplicable, "value.resource": notApplicable, - command: notApplicable, + + // Keyword argument + "name.argument.actual.iteration": notApplicable, + "name.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + "value.argument.actual": notApplicable, + + // Nested functions. Technically supported, but great problem with `every funk` in a method. + "functionName.iteration.block": notApplicable, + "namedFunction.iteration.block": notApplicable, + + // Miscellaneous environment: notApplicable, - notebookCell: notApplicable, - section: notApplicable, }; export const javascriptJsxScopeSupport: LanguageScopeSupportFacetMap = { @@ -202,6 +213,7 @@ export const javascriptJsxScopeSupport: LanguageScopeSupportFacetMap = { "key.attribute": supported, "value.attribute": supported, "interior.element": supported, + "textFragment.element": supported, }; export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { @@ -210,22 +222,24 @@ export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { // Types are defined here because we don't want typescript to import them and // accidentally forget to add support for them. - "value.typeAlias": notApplicable, - "type.alias": notApplicable, - "type.argument.formal.constructor.iteration": notApplicable, - "type.argument.formal.constructor": notApplicable, + + "type.argument.formal": notApplicable, "type.argument.formal.iteration": notApplicable, - "type.argument.formal.method.iteration": notApplicable, "type.argument.formal.method": notApplicable, - "type.argument.formal": notApplicable, + "type.argument.formal.method.iteration": notApplicable, + "type.argument.formal.constructor": notApplicable, + "type.argument.formal.constructor.iteration": notApplicable, + "type.alias": notApplicable, "type.cast": notApplicable, - "type.enum": notApplicable, - "type.field.iteration": notApplicable, "type.field": notApplicable, + "type.field.iteration": notApplicable, "type.foreach": notApplicable, "type.interface": notApplicable, + "type.enum": notApplicable, "type.return": notApplicable, - "type.typeArgument.iteration": notApplicable, - "type.typeArgument": notApplicable, "type.variable": notApplicable, + "type.typeArgument": notApplicable, + "type.typeArgument.iteration": notApplicable, + + "value.typeAlias": notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/javascriptreact.ts b/packages/common/src/scopeSupportFacets/javascriptreact.ts index 2d38ba0c5f..11f9cf56e6 100644 --- a/packages/common/src/scopeSupportFacets/javascriptreact.ts +++ b/packages/common/src/scopeSupportFacets/javascriptreact.ts @@ -1,12 +1,6 @@ import { javascriptScopeSupport } from "./javascript"; import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; -import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const javascriptreactScopeSupport: LanguageScopeSupportFacetMap = { ...javascriptScopeSupport, - - "textFragment.element": supported, }; diff --git a/packages/common/src/scopeSupportFacets/typescript.ts b/packages/common/src/scopeSupportFacets/typescript.ts index 58001edb3c..31785b93e5 100644 --- a/packages/common/src/scopeSupportFacets/typescript.ts +++ b/packages/common/src/scopeSupportFacets/typescript.ts @@ -26,8 +26,9 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = { "value.typeAlias": supported, - // Not applicable + /* NOT APPLICABLE */ + // Element and tags element: notApplicable, tags: notApplicable, startTag: notApplicable, @@ -35,6 +36,9 @@ export const typescriptScopeSupport: LanguageScopeSupportFacetMap = { attribute: notApplicable, "key.attribute": notApplicable, "value.attribute": notApplicable, - "type.foreach": notApplicable, "interior.element": notApplicable, + "textFragment.element": notApplicable, + + // Miscellaneous + "type.foreach": notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/typescriptreact.ts b/packages/common/src/scopeSupportFacets/typescriptreact.ts index 017870775b..ee20103440 100644 --- a/packages/common/src/scopeSupportFacets/typescriptreact.ts +++ b/packages/common/src/scopeSupportFacets/typescriptreact.ts @@ -1,11 +1,7 @@ import { javascriptJsxScopeSupport } from "./javascript"; import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; -import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; import { typescriptScopeSupport } from "./typescript"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; - export const typescriptreactScopeSupport: LanguageScopeSupportFacetMap = { ...typescriptScopeSupport, ...javascriptJsxScopeSupport, diff --git a/queries/javascript.core.scm b/queries/javascript.core.scm index 888f701789..eb8883811a 100644 --- a/queries/javascript.core.scm +++ b/queries/javascript.core.scm @@ -401,11 +401,11 @@ (_) @value ) @_.domain -;;!! str => str.length > 0 -;;! ^^^^^^^^^^^^^^ -;;! --------------------- +;;!! str => 0 +;;! ^ +;;! -------- (arrow_function - body: (_) @value + body: (_) @value @interior (#not-type? @value statement_block) ) @_.domain @@ -437,6 +437,16 @@ ) ) +( + (_ + body: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) + ) @_.domain + (#not-type? @_.domain try_statement) +) + ;;!! const aaa = {bbb: 0, ccc: 0}; ;;! ************** (object @@ -507,18 +517,6 @@ (array_pattern) ] @list -;;!! if () {} -;;! ^^^^^^^^ -(if_statement) @ifStatement - -;;!! switch (value) {} -;;! ^^^^^ -;;! ----------------- -(switch_statement - value: (_) @private.switchStatementSubject - (#child-range! @private.switchStatementSubject 0 -1 true true) -) @_.domain - ;;!! foo() ;;! ^^^^^ ;;!! new Foo() @@ -571,16 +569,21 @@ (program) @class.iteration @className.iteration -;;!! true ? 0 : 1; +;;!! true ? 0 : 1 ;;! ^^^^ ;;! ^ ^ -;;! -------------- +;;! ------------- (ternary_expression - condition: (_) @condition + condition: (_) @condition @interior consequence: (_) @branch ) @condition.domain + (ternary_expression - alternative: (_) @branch + consequence: (_) @branch @interior +) + +(ternary_expression + alternative: (_) @branch @interior ) ;;!! for (let i = 0; i < 2; ++i) {} @@ -605,68 +608,103 @@ (#child-range! @condition 0 -1 true true) ) @_.domain -;;!! case 0: {} -;;! ^^^^^^^^^^ +;;!! switch (value) { } +;;! ^^^^^ +;;! ^ +(switch_statement + value: (_) @private.switchStatementSubject + body: (_ + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @branch.iteration.end.startOf @condition.iteration.end.startOf + ) + (#child-range! @private.switchStatementSubject 0 -1 true true) +) @branch.iteration.domain @condition.iteration.domain @private.switchStatementSubject.domain + +;;!! case 0: break; +;;! ^^^^^^^^^^^^^^ ;;! ^ (switch_case value: (_) @condition ) @branch @condition.domain +;;!! default: break; +;;! ^^^^^^^^^^^^^^^ (switch_default) @branch -;;!! switch () { } -;;! ^ -(switch_statement - body: (_ - . - "{" @branch.iteration.start.endOf @condition.iteration.start.endOf - "}" @branch.iteration.end.startOf @condition.iteration.end.startOf - . - ) -) @branch.iteration.domain @condition.iteration.domain +(switch_case + body: (_) @interior.start + body: (_)? @interior.end + . + (#not-type? @interior.start "statement_block") +) @_.domain + +(switch_default + body: (_) @interior.start + body: (_)? @interior.end + . + (#not-type? @interior.start "statement_block") +) @_.domain + +;;!! if () {} +;;! ^^^^^^^^ +(if_statement) @ifStatement ;;!! if () {} ;;! ^^^^^^^^ ( (if_statement + "if" @branch.start.startOf @branch.removal.start.startOf @interior.domain.start.startOf condition: (_) @condition - consequence: (_) @branch.end.endOf @branch.removal.end.endOf + consequence: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end.endOf @branch.removal.end.endOf @interior.domain.end.endOf alternative: (_ (if_statement) @branch.removal.end.startOf )? - ) @branch.start.startOf @branch.removal.start.startOf @condition.domain - (#not-parent-type? @condition.domain "else_clause") + ) @condition.domain + (#not-parent-type? @condition.domain else_clause) (#child-range! @condition 0 -1 true true) ) ;;!! else if () {} ;;! ^^^^^^^^^^^^^ (else_clause + "else" @branch.start.startOf @condition.domain.start.startOf @interior.domain.start.startOf (if_statement condition: (_) @condition - consequence: (_) @branch.end.endOf @condition.domain.end.endOf + consequence: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end.endOf @condition.domain.end.endOf @interior.domain.end.endOf ) (#child-range! @condition 0 -1 true true) -) @branch.start.startOf @condition.domain.start.startOf +) ;;!! else {} ;;! ^^^^^^^ (else_clause - (statement_block) -) @branch + (statement_block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) +) @branch @interior.domain ;;!! if () {} else if () {} else {} ;;! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ( (if_statement) @branch.iteration - (#not-parent-type? @branch.iteration "else_clause") + (#not-parent-type? @branch.iteration else_clause) ) ;;!! try () {} ;;! ^^^^^^^^^ (try_statement - "try" @branch.start - body: (_) @branch.end + "try" @branch.start @interior.domain.start.startOf + body: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end @interior.domain.end.endOf ) ;;!! catch () {} @@ -818,6 +856,7 @@ operator: [ ">>>" ">>>=" ] @disqualifyDelimiter + (arrow_function "=>" @disqualifyDelimiter )