From e12b1940c2875f576a60caac5b91884d2977019e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 10 Sep 2026 07:53:47 +0200 Subject: [PATCH 1/4] Added additional scope fixtures to shellscript --- .../user/languages/fixtures/shellscript.json | 645 ++++++++++++++++++ .../src/docs/user/languages/shellscript.mdx | 48 ++ .../src/docs/user/scopes/branch.mdx | 2 + .../src/docs/user/scopes/collectionKey.mdx | 6 + .../src/docs/user/scopes/condition.mdx | 4 + .../src/docs/user/scopes/fixtures/branch.json | 35 + .../user/scopes/fixtures/collectionKey.json | 50 ++ .../docs/user/scopes/fixtures/condition.json | 52 ++ .../docs/user/scopes/fixtures/interior.json | 61 ++ .../src/docs/user/scopes/fixtures/list.json | 44 ++ .../src/docs/user/scopes/fixtures/map.json | 34 + .../src/docs/user/scopes/fixtures/name.json | 40 ++ .../user/scopes/fixtures/namedFunction.json | 17 + .../docs/user/scopes/fixtures/statement.json | 152 +++++ .../src/docs/user/scopes/fixtures/value.json | 160 +++++ .../src/docs/user/scopes/interior.mdx | 4 + .../src/docs/user/scopes/list.mdx | 2 + .../app-web-docs/src/docs/user/scopes/map.mdx | 4 + .../src/docs/user/scopes/name.mdx | 2 + .../src/docs/user/scopes/namedFunction.mdx | 2 + .../src/docs/user/scopes/statement.mdx | 12 + .../src/docs/user/scopes/value.mdx | 10 + .../branch/branch.switchCase3.scope | 59 ++ .../condition/condition.switchCase2.scope | 22 + .../condition/condition.switchCase3.scope | 62 ++ .../interior/interior.function3.scope | 13 + .../interior/interior.switchCase2.scope | 61 ++ .../shellscript/key.mapPair.iteration2.scope | 10 + .../scopes/shellscript/key.mapPair2.scope | 16 + .../scopes/shellscript/key.mapPair3.scope | 13 + .../fixtures/scopes/shellscript/list2.scope | 40 ++ .../fixtures/scopes/shellscript/map2.scope | 13 + .../fixtures/scopes/shellscript/map3.scope | 10 + .../name/name.iteration.block5.scope | 34 + .../namedFunction/namedFunction4.scope | 10 + .../statement/statement.function3.scope | 10 + .../statement/statement.function4.scope | 30 + .../statement/statement.functionCall3.scope | 10 + .../statement/statement.functionCall4.scope | 10 + .../statement/statement.functionCall5.scope | 35 + .../statement.iteration.block5.scope | 34 + .../shellscript/value/value.foreach2.scope | 20 + .../value/value.iteration.block5.scope | 34 + .../value/value.mapPair.iteration2.scope | 20 + .../shellscript/value/value.mapPair2.scope | 92 +++ .../shellscript/value/value.mapPair3.scope | 32 + resources/queries/shellscript.scm | 103 ++- 47 files changed, 2164 insertions(+), 15 deletions(-) create mode 100644 resources/fixtures/scopes/shellscript/branch/branch.switchCase3.scope create mode 100644 resources/fixtures/scopes/shellscript/condition/condition.switchCase2.scope create mode 100644 resources/fixtures/scopes/shellscript/condition/condition.switchCase3.scope create mode 100644 resources/fixtures/scopes/shellscript/interior/interior.function3.scope create mode 100644 resources/fixtures/scopes/shellscript/interior/interior.switchCase2.scope create mode 100644 resources/fixtures/scopes/shellscript/key.mapPair.iteration2.scope create mode 100644 resources/fixtures/scopes/shellscript/key.mapPair2.scope create mode 100644 resources/fixtures/scopes/shellscript/key.mapPair3.scope create mode 100644 resources/fixtures/scopes/shellscript/list2.scope create mode 100644 resources/fixtures/scopes/shellscript/map2.scope create mode 100644 resources/fixtures/scopes/shellscript/map3.scope create mode 100644 resources/fixtures/scopes/shellscript/name/name.iteration.block5.scope create mode 100644 resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope create mode 100644 resources/fixtures/scopes/shellscript/statement/statement.function3.scope create mode 100644 resources/fixtures/scopes/shellscript/statement/statement.function4.scope create mode 100644 resources/fixtures/scopes/shellscript/statement/statement.functionCall3.scope create mode 100644 resources/fixtures/scopes/shellscript/statement/statement.functionCall4.scope create mode 100644 resources/fixtures/scopes/shellscript/statement/statement.functionCall5.scope create mode 100644 resources/fixtures/scopes/shellscript/statement/statement.iteration.block5.scope create mode 100644 resources/fixtures/scopes/shellscript/value/value.foreach2.scope create mode 100644 resources/fixtures/scopes/shellscript/value/value.iteration.block5.scope create mode 100644 resources/fixtures/scopes/shellscript/value/value.mapPair.iteration2.scope create mode 100644 resources/fixtures/scopes/shellscript/value/value.mapPair2.scope create mode 100644 resources/fixtures/scopes/shellscript/value/value.mapPair3.scope diff --git a/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json b/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json index 1e0a43e5894..5c32b11fc99 100644 --- a/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json +++ b/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json @@ -262,6 +262,41 @@ } ] }, + { + "name": "scopes/shellscript/branch/branch.switchCase3", + "languageId": "shellscript", + "facet": "branch.switchCase", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-1:9", + "removal": "1:0-2:0" + } + ], + "domain": "1:2-1:9" + }, + { + "targets": [ + { + "content": "2:2-2:10", + "removal": "2:0-3:0" + } + ], + "domain": "2:2-2:10" + }, + { + "targets": [ + { + "content": "3:2-3:9", + "removal": "3:0-4:0" + } + ], + "domain": "3:2-3:9" + } + ] + }, { "name": "scopes/shellscript/branch/branch.ternary.iteration", "languageId": "shellscript", @@ -397,6 +432,58 @@ } ] }, + { + "name": "scopes/shellscript/condition/condition.switchCase2", + "languageId": "shellscript", + "facet": "condition.switchCase", + "code": "case $foo in\n 0|1|2) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-1:7", + "removal": "1:0-1:7" + } + ], + "domain": "1:2-1:13" + } + ] + }, + { + "name": "scopes/shellscript/condition/condition.switchCase3", + "languageId": "shellscript", + "facet": "condition.switchCase", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-1:3", + "removal": "1:0-1:3" + } + ], + "domain": "1:2-1:9" + }, + { + "targets": [ + { + "content": "2:2-2:3", + "removal": "2:0-2:3" + } + ], + "domain": "2:2-2:10" + }, + { + "targets": [ + { + "content": "3:2-3:3", + "removal": "3:0-3:3" + } + ], + "domain": "3:2-3:9" + } + ] + }, { "name": "scopes/shellscript/condition/condition.ternary", "languageId": "shellscript", @@ -601,6 +688,23 @@ } ] }, + { + "name": "scopes/shellscript/interior/interior.function3", + "languageId": "shellscript", + "facet": "interior.function", + "code": "foo() ( : )", + "scopes": [ + { + "targets": [ + { + "content": "0:8-0:9", + "removal": "0:7-0:10" + } + ], + "domain": "0:7-0:10" + } + ] + }, { "name": "scopes/shellscript/interior/interior.if", "languageId": "shellscript", @@ -679,6 +783,50 @@ } ] }, + { + "name": "scopes/shellscript/interior/interior.switchCase2", + "languageId": "shellscript", + "facet": "interior.switchCase", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-3:9", + "removal": "0:12-4:0" + } + ], + "domain": "0:12-4:0" + }, + { + "targets": [ + { + "content": "1:5-1:6", + "removal": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:5-2:6", + "removal": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:5-3:6", + "removal": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/interior/interior.while", "languageId": "shellscript", @@ -729,6 +877,22 @@ } ] }, + { + "name": "scopes/shellscript/key.mapPair.iteration2", + "languageId": "shellscript", + "facet": "key.mapPair.iteration", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "3:7-3:16" + } + ], + "domain": "3:7-3:16" + } + ] + }, { "name": "scopes/shellscript/key.mapPair", "languageId": "shellscript", @@ -755,6 +919,40 @@ } ] }, + { + "name": "scopes/shellscript/key.mapPair2", + "languageId": "shellscript", + "facet": "key.mapPair", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "3:8-3:13", + "removal": "3:8-3:13" + } + ], + "domain": "3:7-3:16" + } + ] + }, + { + "name": "scopes/shellscript/key.mapPair3", + "languageId": "shellscript", + "facet": "key.mapPair", + "code": "foo=([\"aaa\"]=\"bbb\"$bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:6-0:11", + "removal": "0:6-0:11" + } + ], + "domain": "0:5-0:22" + } + ] + }, { "name": "scopes/shellscript/list", "languageId": "shellscript", @@ -772,6 +970,50 @@ } ] }, + { + "name": "scopes/shellscript/list2", + "languageId": "shellscript", + "facet": "list", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:19", + "removal": "0:4-0:19" + } + ], + "domain": "0:4-0:19" + }, + { + "targets": [ + { + "content": "1:4-1:17", + "removal": "1:4-1:17" + } + ], + "domain": "1:4-1:17" + }, + { + "targets": [ + { + "content": "2:4-2:19", + "removal": "2:4-2:19" + } + ], + "domain": "2:4-2:19" + }, + { + "targets": [ + { + "content": "3:6-3:17", + "removal": "3:6-3:17" + } + ], + "domain": "3:6-3:17" + } + ] + }, { "name": "scopes/shellscript/map", "languageId": "shellscript", @@ -789,6 +1031,40 @@ } ] }, + { + "name": "scopes/shellscript/map2", + "languageId": "shellscript", + "facet": "map", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "3:6-3:17", + "removal": "3:6-3:17" + } + ], + "domain": "3:6-3:17" + } + ] + }, + { + "name": "scopes/shellscript/map3", + "languageId": "shellscript", + "facet": "map", + "code": "foo=([\"aaa\"]=\"bbb\"$bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:23", + "removal": "0:4-0:23" + } + ], + "domain": "0:4-0:23" + } + ] + }, { "name": "scopes/shellscript/name/name.assignment.compound", "languageId": "shellscript", @@ -1003,6 +1279,46 @@ } ] }, + { + "name": "scopes/shellscript/name/name.iteration.block5", + "languageId": "shellscript", + "facet": "name.iteration.block", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "0:0-4:4" + } + ], + "domain": "0:0-4:4" + }, + { + "targets": [ + { + "content": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/name/name.iteration.document", "languageId": "shellscript", @@ -1154,6 +1470,23 @@ } ] }, + { + "name": "scopes/shellscript/namedFunction/namedFunction4", + "languageId": "shellscript", + "facet": "namedFunction", + "code": "foo() ( : )", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + } + ] + }, { "name": "scopes/shellscript/regularExpression", "languageId": "shellscript", @@ -1360,6 +1693,49 @@ } ] }, + { + "name": "scopes/shellscript/statement/statement.function3", + "languageId": "shellscript", + "facet": "statement.function", + "code": "function foo() {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/shellscript/statement/statement.function4", + "languageId": "shellscript", + "facet": "statement.function", + "code": "foo() ( : )", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + }, + { + "targets": [ + { + "content": "0:8-0:9", + "removal": "0:8-0:10" + } + ], + "domain": "0:8-0:9" + } + ] + }, { "name": "scopes/shellscript/statement/statement.functionCall", "languageId": "shellscript", @@ -1394,6 +1770,75 @@ } ] }, + { + "name": "scopes/shellscript/statement/statement.functionCall3", + "languageId": "shellscript", + "facet": "statement.functionCall", + "code": "foo | bar | baz", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:15", + "removal": "0:0-0:15" + } + ], + "domain": "0:0-0:15" + } + ] + }, + { + "name": "scopes/shellscript/statement/statement.functionCall4", + "languageId": "shellscript", + "facet": "statement.functionCall", + "code": "foo |& bar", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, + { + "name": "scopes/shellscript/statement/statement.functionCall5", + "languageId": "shellscript", + "facet": "statement.functionCall", + "code": "(foo; bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + }, + { + "targets": [ + { + "content": "0:1-0:4", + "removal": "0:1-0:4" + } + ], + "domain": "0:1-0:4" + }, + { + "targets": [ + { + "content": "0:6-0:9", + "removal": "0:5-0:9" + } + ], + "domain": "0:6-0:9" + } + ] + }, { "name": "scopes/shellscript/statement/statement.if", "languageId": "shellscript", @@ -1593,6 +2038,46 @@ } ] }, + { + "name": "scopes/shellscript/statement/statement.iteration.block5", + "languageId": "shellscript", + "facet": "statement.iteration.block", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "0:0-4:4" + } + ], + "domain": "0:0-4:4" + }, + { + "targets": [ + { + "content": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/statement/statement.iteration.document", "languageId": "shellscript", @@ -1968,6 +2453,23 @@ } ] }, + { + "name": "scopes/shellscript/value/value.foreach2", + "languageId": "shellscript", + "facet": "value.foreach", + "code": "for v in aaa bbb ccc; do :; done", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:20", + "removal": "0:8-0:20" + } + ], + "domain": "0:0-0:32" + } + ] + }, { "name": "scopes/shellscript/value/value.iteration.block", "languageId": "shellscript", @@ -2080,6 +2582,46 @@ } ] }, + { + "name": "scopes/shellscript/value/value.iteration.block5", + "languageId": "shellscript", + "facet": "value.iteration.block", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "0:0-4:4" + } + ], + "domain": "0:0-4:4" + }, + { + "targets": [ + { + "content": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/value/value.iteration.document", "languageId": "shellscript", @@ -2120,6 +2662,30 @@ } ] }, + { + "name": "scopes/shellscript/value/value.mapPair.iteration2", + "languageId": "shellscript", + "facet": "value.mapPair.iteration", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "0:0-3:17" + } + ], + "domain": "0:0-3:17" + }, + { + "targets": [ + { + "content": "3:7-3:16" + } + ], + "domain": "3:7-3:16" + } + ] + }, { "name": "scopes/shellscript/value/value.mapPair", "languageId": "shellscript", @@ -2155,6 +2721,85 @@ } ] }, + { + "name": "scopes/shellscript/value/value.mapPair2", + "languageId": "shellscript", + "facet": "value.mapPair", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:19", + "removal": "0:3-0:19" + } + ], + "domain": "0:0-0:19" + }, + { + "targets": [ + { + "content": "1:4-1:17", + "removal": "1:3-1:17" + } + ], + "domain": "1:0-1:17" + }, + { + "targets": [ + { + "content": "2:4-2:19", + "removal": "2:3-2:19" + } + ], + "domain": "2:0-2:19" + }, + { + "targets": [ + { + "content": "3:6-3:17", + "removal": "3:5-3:17" + } + ], + "domain": "3:0-3:17" + }, + { + "targets": [ + { + "content": "3:15-3:16", + "removal": "3:15-3:16" + } + ], + "domain": "3:7-3:16" + } + ] + }, + { + "name": "scopes/shellscript/value/value.mapPair3", + "languageId": "shellscript", + "facet": "value.mapPair", + "code": "foo=([\"aaa\"]=\"bbb\"$bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:23", + "removal": "0:3-0:23" + } + ], + "domain": "0:0-0:23" + }, + { + "targets": [ + { + "content": "0:13-0:22", + "removal": "0:13-0:22" + } + ], + "domain": "0:5-0:22" + } + ] + }, { "name": "scopes/shellscript/value/value.return", "languageId": "shellscript", diff --git a/packages/app-web-docs/src/docs/user/languages/shellscript.mdx b/packages/app-web-docs/src/docs/user/languages/shellscript.mdx index 314a525ac1e..eabdcfcc2e4 100644 --- a/packages/app-web-docs/src/docs/user/languages/shellscript.mdx +++ b/packages/app-web-docs/src/docs/user/languages/shellscript.mdx @@ -79,6 +79,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 5. Branch: Ternary A branch in a ternary expression @@ -111,12 +113,18 @@ Below are visualizations of all our scope tests for this language. These were cr + + + + #### 2. Key: Map pair (iteration) Iteration scope for keys of key-value pairs in a map: should be between the braces. + + ### Comment #### 1. Comment: Line @@ -145,6 +153,10 @@ Below are visualizations of all our scope tests for this language. These were cr + + + + #### 4. Condition: Ternary A condition in a ternary expression @@ -215,6 +227,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 4. Interior: If The body of an if/elif/else branch @@ -233,6 +247,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 7. Interior: While The body of a while loop @@ -249,6 +265,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + ### Map #### 1. Map @@ -257,6 +275,10 @@ Below are visualizations of all our scope tests for this language. These were cr + + + + ### Name #### 1. Name: Assignment @@ -319,6 +341,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 9. Name (iteration document) Iteration scope for names: the entire document including leading and trailing empty lines. @@ -337,6 +361,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 2. Named function (iteration document) Iteration scope for named functions: the entire document including leading and trailing empty lines. @@ -403,6 +429,10 @@ Below are visualizations of all our scope tests for this language. These were cr + + + + #### 9. Statement: Function call A function call statement @@ -411,6 +441,12 @@ Below are visualizations of all our scope tests for this language. These were cr + + + + + + #### 10. Statement: If An if/elif/else statement @@ -479,6 +515,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 19. Statement (iteration document) Iteration scope for statements: the entire document including leading and trailing empty lines. @@ -511,12 +549,18 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 5. Value: Map pair Value (RHS) of a key-value pair in a map + + + + #### 6. Value: Return Return value of a function @@ -551,6 +595,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + #### 10. Value (iteration document) Iteration scope for values: the entire document including leading and trailing empty lines. @@ -563,6 +609,8 @@ Below are visualizations of all our scope tests for this language. These were cr + + ## Internal scopes The following are internal scopes. They are not intended for user interaction or spoken use. These scopes exist solely for internal Cursorless functionality. diff --git a/packages/app-web-docs/src/docs/user/scopes/branch.mdx b/packages/app-web-docs/src/docs/user/scopes/branch.mdx index baa502a0569..896554cdc0d 100644 --- a/packages/app-web-docs/src/docs/user/scopes/branch.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/branch.mdx @@ -333,6 +333,8 @@ Default: `branch` + + ### Branch: Ternary A branch in a ternary expression diff --git a/packages/app-web-docs/src/docs/user/scopes/collectionKey.mdx b/packages/app-web-docs/src/docs/user/scopes/collectionKey.mdx index 8f65b4494d2..90667124695 100644 --- a/packages/app-web-docs/src/docs/user/scopes/collectionKey.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/collectionKey.mdx @@ -111,6 +111,10 @@ Default: `key` + + + + ##### Talon list @@ -189,6 +193,8 @@ Default: `key` + + ##### Talon list diff --git a/packages/app-web-docs/src/docs/user/scopes/condition.mdx b/packages/app-web-docs/src/docs/user/scopes/condition.mdx index d6d5a1bcafb..21c811de618 100644 --- a/packages/app-web-docs/src/docs/user/scopes/condition.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/condition.mdx @@ -265,6 +265,10 @@ Default: `condition` + + + + ### Condition: Ternary A condition in a ternary expression diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json index 7e7ad75716c..a08cd6e9754 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json @@ -3318,6 +3318,41 @@ } ] }, + { + "name": "scopes/shellscript/branch/branch.switchCase3", + "languageId": "shellscript", + "facet": "branch.switchCase", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-1:9", + "removal": "1:0-2:0" + } + ], + "domain": "1:2-1:9" + }, + { + "targets": [ + { + "content": "2:2-2:10", + "removal": "2:0-3:0" + } + ], + "domain": "2:2-2:10" + }, + { + "targets": [ + { + "content": "3:2-3:9", + "removal": "3:0-4:0" + } + ], + "domain": "3:2-3:9" + } + ] + }, { "name": "scopes/shellscript/branch/branch.ternary.iteration", "languageId": "shellscript", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/collectionKey.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/collectionKey.json index dfa4bed4bae..c18a81fa718 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/collectionKey.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/collectionKey.json @@ -687,6 +687,22 @@ } ] }, + { + "name": "scopes/shellscript/key.mapPair.iteration2", + "languageId": "shellscript", + "facet": "key.mapPair.iteration", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "3:7-3:16" + } + ], + "domain": "3:7-3:16" + } + ] + }, { "name": "scopes/shellscript/key.mapPair", "languageId": "shellscript", @@ -713,6 +729,40 @@ } ] }, + { + "name": "scopes/shellscript/key.mapPair2", + "languageId": "shellscript", + "facet": "key.mapPair", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "3:8-3:13", + "removal": "3:8-3:13" + } + ], + "domain": "3:7-3:16" + } + ] + }, + { + "name": "scopes/shellscript/key.mapPair3", + "languageId": "shellscript", + "facet": "key.mapPair", + "code": "foo=([\"aaa\"]=\"bbb\"$bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:6-0:11", + "removal": "0:6-0:11" + } + ], + "domain": "0:5-0:22" + } + ] + }, { "name": "scopes/talon/key/key.mapPair.iteration", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json index d47bb1f43c8..81ad1e4777c 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json @@ -1793,6 +1793,58 @@ } ] }, + { + "name": "scopes/shellscript/condition/condition.switchCase2", + "languageId": "shellscript", + "facet": "condition.switchCase", + "code": "case $foo in\n 0|1|2) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-1:7", + "removal": "1:0-1:7" + } + ], + "domain": "1:2-1:13" + } + ] + }, + { + "name": "scopes/shellscript/condition/condition.switchCase3", + "languageId": "shellscript", + "facet": "condition.switchCase", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-1:3", + "removal": "1:0-1:3" + } + ], + "domain": "1:2-1:9" + }, + { + "targets": [ + { + "content": "2:2-2:3", + "removal": "2:0-2:3" + } + ], + "domain": "2:2-2:10" + }, + { + "targets": [ + { + "content": "3:2-3:3", + "removal": "3:0-3:3" + } + ], + "domain": "3:2-3:9" + } + ] + }, { "name": "scopes/shellscript/condition/condition.ternary", "languageId": "shellscript", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json index 094669a52eb..25e54c8dc00 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json @@ -4936,6 +4936,23 @@ } ] }, + { + "name": "scopes/shellscript/interior/interior.function3", + "languageId": "shellscript", + "facet": "interior.function", + "code": "foo() ( : )", + "scopes": [ + { + "targets": [ + { + "content": "0:8-0:9", + "removal": "0:7-0:10" + } + ], + "domain": "0:7-0:10" + } + ] + }, { "name": "scopes/shellscript/interior/interior.if", "languageId": "shellscript", @@ -5014,6 +5031,50 @@ } ] }, + { + "name": "scopes/shellscript/interior/interior.switchCase2", + "languageId": "shellscript", + "facet": "interior.switchCase", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "1:2-3:9", + "removal": "0:12-4:0" + } + ], + "domain": "0:12-4:0" + }, + { + "targets": [ + { + "content": "1:5-1:6", + "removal": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:5-2:6", + "removal": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:5-3:6", + "removal": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/interior/interior.while", "languageId": "shellscript", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/list.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/list.json index f81dd46a068..0de4886fd5e 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/list.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/list.json @@ -492,6 +492,50 @@ } ] }, + { + "name": "scopes/shellscript/list2", + "languageId": "shellscript", + "facet": "list", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:19", + "removal": "0:4-0:19" + } + ], + "domain": "0:4-0:19" + }, + { + "targets": [ + { + "content": "1:4-1:17", + "removal": "1:4-1:17" + } + ], + "domain": "1:4-1:17" + }, + { + "targets": [ + { + "content": "2:4-2:19", + "removal": "2:4-2:19" + } + ], + "domain": "2:4-2:19" + }, + { + "targets": [ + { + "content": "3:6-3:17", + "removal": "3:6-3:17" + } + ], + "domain": "3:6-3:17" + } + ] + }, { "name": "scopes/yaml/list", "languageId": "yaml", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/map.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/map.json index 5dcd665e45e..9743c6af2be 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/map.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/map.json @@ -331,6 +331,40 @@ } ] }, + { + "name": "scopes/shellscript/map2", + "languageId": "shellscript", + "facet": "map", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "3:6-3:17", + "removal": "3:6-3:17" + } + ], + "domain": "3:6-3:17" + } + ] + }, + { + "name": "scopes/shellscript/map3", + "languageId": "shellscript", + "facet": "map", + "code": "foo=([\"aaa\"]=\"bbb\"$bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:23", + "removal": "0:4-0:23" + } + ], + "domain": "0:4-0:23" + } + ] + }, { "name": "scopes/yaml/map", "languageId": "yaml", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json index f5e0e352910..e4038d9e6c9 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json @@ -12171,6 +12171,46 @@ } ] }, + { + "name": "scopes/shellscript/name/name.iteration.block5", + "languageId": "shellscript", + "facet": "name.iteration.block", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "0:0-4:4" + } + ], + "domain": "0:0-4:4" + }, + { + "targets": [ + { + "content": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/name/name.iteration.document", "languageId": "shellscript", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json index 5e6d39ad848..8e0f1a412ec 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json @@ -1960,6 +1960,23 @@ } ] }, + { + "name": "scopes/shellscript/namedFunction/namedFunction4", + "languageId": "shellscript", + "facet": "namedFunction", + "code": "foo() ( : )", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + } + ] + }, { "name": "scopes/typescript.core/namedFunction/namedFunction.constructor", "languageId": "typescript.core", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json index fb93209a8cf..29a31dd5a3c 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json @@ -10781,6 +10781,49 @@ } ] }, + { + "name": "scopes/shellscript/statement/statement.function3", + "languageId": "shellscript", + "facet": "statement.function", + "code": "function foo() {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/shellscript/statement/statement.function4", + "languageId": "shellscript", + "facet": "statement.function", + "code": "foo() ( : )", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + }, + { + "targets": [ + { + "content": "0:8-0:9", + "removal": "0:8-0:10" + } + ], + "domain": "0:8-0:9" + } + ] + }, { "name": "scopes/shellscript/statement/statement.functionCall", "languageId": "shellscript", @@ -10815,6 +10858,75 @@ } ] }, + { + "name": "scopes/shellscript/statement/statement.functionCall3", + "languageId": "shellscript", + "facet": "statement.functionCall", + "code": "foo | bar | baz", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:15", + "removal": "0:0-0:15" + } + ], + "domain": "0:0-0:15" + } + ] + }, + { + "name": "scopes/shellscript/statement/statement.functionCall4", + "languageId": "shellscript", + "facet": "statement.functionCall", + "code": "foo |& bar", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, + { + "name": "scopes/shellscript/statement/statement.functionCall5", + "languageId": "shellscript", + "facet": "statement.functionCall", + "code": "(foo; bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + }, + { + "targets": [ + { + "content": "0:1-0:4", + "removal": "0:1-0:4" + } + ], + "domain": "0:1-0:4" + }, + { + "targets": [ + { + "content": "0:6-0:9", + "removal": "0:5-0:9" + } + ], + "domain": "0:6-0:9" + } + ] + }, { "name": "scopes/shellscript/statement/statement.if", "languageId": "shellscript", @@ -11014,6 +11126,46 @@ } ] }, + { + "name": "scopes/shellscript/statement/statement.iteration.block5", + "languageId": "shellscript", + "facet": "statement.iteration.block", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "0:0-4:4" + } + ], + "domain": "0:0-4:4" + }, + { + "targets": [ + { + "content": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/statement/statement.iteration.document", "languageId": "shellscript", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json index 49eecbc5c55..2c7cb357b67 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json @@ -8612,6 +8612,23 @@ } ] }, + { + "name": "scopes/shellscript/value/value.foreach2", + "languageId": "shellscript", + "facet": "value.foreach", + "code": "for v in aaa bbb ccc; do :; done", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:20", + "removal": "0:8-0:20" + } + ], + "domain": "0:0-0:32" + } + ] + }, { "name": "scopes/shellscript/value/value.iteration.block", "languageId": "shellscript", @@ -8724,6 +8741,46 @@ } ] }, + { + "name": "scopes/shellscript/value/value.iteration.block5", + "languageId": "shellscript", + "facet": "value.iteration.block", + "code": "case $foo in\n 0) : ;&\n 1) : ;;&\n *) : ;;\nesac", + "scopes": [ + { + "targets": [ + { + "content": "0:0-4:4" + } + ], + "domain": "0:0-4:4" + }, + { + "targets": [ + { + "content": "1:4-1:7" + } + ], + "domain": "1:4-1:7" + }, + { + "targets": [ + { + "content": "2:4-2:7" + } + ], + "domain": "2:4-2:7" + }, + { + "targets": [ + { + "content": "3:4-3:7" + } + ], + "domain": "3:4-3:7" + } + ] + }, { "name": "scopes/shellscript/value/value.iteration.document", "languageId": "shellscript", @@ -8764,6 +8821,30 @@ } ] }, + { + "name": "scopes/shellscript/value/value.mapPair.iteration2", + "languageId": "shellscript", + "facet": "value.mapPair.iteration", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "0:0-3:17" + } + ], + "domain": "0:0-3:17" + }, + { + "targets": [ + { + "content": "3:7-3:16" + } + ], + "domain": "3:7-3:16" + } + ] + }, { "name": "scopes/shellscript/value/value.mapPair", "languageId": "shellscript", @@ -8799,6 +8880,85 @@ } ] }, + { + "name": "scopes/shellscript/value/value.mapPair2", + "languageId": "shellscript", + "facet": "value.mapPair", + "code": "foo=(\"aaa\"$bar bbb)\nbar=([\"aaa\"] bbb)\nbaz=(\"[aaa]=0\" bbb)\nbongo=([\"aaa\"]=0)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:19", + "removal": "0:3-0:19" + } + ], + "domain": "0:0-0:19" + }, + { + "targets": [ + { + "content": "1:4-1:17", + "removal": "1:3-1:17" + } + ], + "domain": "1:0-1:17" + }, + { + "targets": [ + { + "content": "2:4-2:19", + "removal": "2:3-2:19" + } + ], + "domain": "2:0-2:19" + }, + { + "targets": [ + { + "content": "3:6-3:17", + "removal": "3:5-3:17" + } + ], + "domain": "3:0-3:17" + }, + { + "targets": [ + { + "content": "3:15-3:16", + "removal": "3:15-3:16" + } + ], + "domain": "3:7-3:16" + } + ] + }, + { + "name": "scopes/shellscript/value/value.mapPair3", + "languageId": "shellscript", + "facet": "value.mapPair", + "code": "foo=([\"aaa\"]=\"bbb\"$bar)", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:23", + "removal": "0:3-0:23" + } + ], + "domain": "0:0-0:23" + }, + { + "targets": [ + { + "content": "0:13-0:22", + "removal": "0:13-0:22" + } + ], + "domain": "0:5-0:22" + } + ] + }, { "name": "scopes/shellscript/value/value.return", "languageId": "shellscript", diff --git a/packages/app-web-docs/src/docs/user/scopes/interior.mdx b/packages/app-web-docs/src/docs/user/scopes/interior.mdx index f4119efe721..8e477ba7975 100644 --- a/packages/app-web-docs/src/docs/user/scopes/interior.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/interior.mdx @@ -429,6 +429,8 @@ Cursorless ID: `interior` + + ### Interior: If The body of an if/elif/else branch @@ -849,6 +851,8 @@ Cursorless ID: `interior` + + ### Interior: Try The body of a try/catch/finally branch diff --git a/packages/app-web-docs/src/docs/user/scopes/list.mdx b/packages/app-web-docs/src/docs/user/scopes/list.mdx index 7542c4c56c9..f840614333e 100644 --- a/packages/app-web-docs/src/docs/user/scopes/list.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/list.mdx @@ -125,6 +125,8 @@ Default: `list` + + ##### YAML diff --git a/packages/app-web-docs/src/docs/user/scopes/map.mdx b/packages/app-web-docs/src/docs/user/scopes/map.mdx index 650e173dcb3..2882c2f7a4e 100644 --- a/packages/app-web-docs/src/docs/user/scopes/map.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/map.mdx @@ -97,6 +97,10 @@ Default: `map` + + + + ##### YAML diff --git a/packages/app-web-docs/src/docs/user/scopes/name.mdx b/packages/app-web-docs/src/docs/user/scopes/name.mdx index 54049c31570..3cb0c52e784 100644 --- a/packages/app-web-docs/src/docs/user/scopes/name.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/name.mdx @@ -1599,6 +1599,8 @@ Default: `name` + + ##### Talon diff --git a/packages/app-web-docs/src/docs/user/scopes/namedFunction.mdx b/packages/app-web-docs/src/docs/user/scopes/namedFunction.mdx index fb8a5f4ba58..c524b98ecb6 100644 --- a/packages/app-web-docs/src/docs/user/scopes/namedFunction.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/namedFunction.mdx @@ -155,6 +155,8 @@ Default: `funk` + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/statement.mdx b/packages/app-web-docs/src/docs/user/scopes/statement.mdx index acb28847df8..7252f79c8ee 100644 --- a/packages/app-web-docs/src/docs/user/scopes/statement.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/statement.mdx @@ -835,6 +835,10 @@ Default: `state` + + + + ### Statement: Function call A function call statement @@ -905,6 +909,12 @@ Default: `state` + + + + + + ##### Talon @@ -2003,6 +2013,8 @@ Default: `state` + + ##### Talon diff --git a/packages/app-web-docs/src/docs/user/scopes/value.mdx b/packages/app-web-docs/src/docs/user/scopes/value.mdx index 73db810d635..55bf69acac9 100644 --- a/packages/app-web-docs/src/docs/user/scopes/value.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/value.mdx @@ -611,6 +611,8 @@ Default: `value` + + ##### Talon @@ -679,6 +681,10 @@ Default: `value` + + + + ##### Talon list @@ -1281,6 +1287,8 @@ Default: `value` + + ##### Talon @@ -1713,6 +1721,8 @@ Default: `value` + + ##### Talon list diff --git a/resources/fixtures/scopes/shellscript/branch/branch.switchCase3.scope b/resources/fixtures/scopes/shellscript/branch/branch.switchCase3.scope new file mode 100644 index 00000000000..e0845c7383e --- /dev/null +++ b/resources/fixtures/scopes/shellscript/branch/branch.switchCase3.scope @@ -0,0 +1,59 @@ +case $foo in + 0) : ;& + 1) : ;;& + *) : ;; +esac +--- + +[#1 Content] = +[#1 Domain] = 1:2-1:9 + >-------< +1| 0) : ;& + +[#1 Removal] = 1:0-2:0 + >--------- +1| 0) : ;& +2| 1) : ;;& + < + +[#1 Leading delimiter] = 1:0-1:2 + >--< +1| 0) : ;& + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:2-2:10 + >--------< +2| 1) : ;;& + +[#2 Removal] = 2:0-3:0 + >---------- +2| 1) : ;;& +3| *) : ;; + < + +[#2 Leading delimiter] = 2:0-2:2 + >--< +2| 1) : ;;& + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 3:2-3:9 + >-------< +3| *) : ;; + +[#3 Removal] = 3:0-4:0 + >--------- +3| *) : ;; +4| esac + < + +[#3 Leading delimiter] = 3:0-3:2 + >--< +3| *) : ;; + +[#3 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/shellscript/condition/condition.switchCase2.scope b/resources/fixtures/scopes/shellscript/condition/condition.switchCase2.scope new file mode 100644 index 00000000000..1257bec1a9d --- /dev/null +++ b/resources/fixtures/scopes/shellscript/condition/condition.switchCase2.scope @@ -0,0 +1,22 @@ +case $foo in + 0|1|2) : ;; +esac +--- + +[Content] = 1:2-1:7 + >-----< +1| 0|1|2) : ;; + +[Removal] = 1:0-1:7 + >-------< +1| 0|1|2) : ;; + +[Leading delimiter] = 1:0-1:2 + >--< +1| 0|1|2) : ;; + +[Domain] = 1:2-1:13 + >-----------< +1| 0|1|2) : ;; + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/condition/condition.switchCase3.scope b/resources/fixtures/scopes/shellscript/condition/condition.switchCase3.scope new file mode 100644 index 00000000000..7590aa6b5d7 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/condition/condition.switchCase3.scope @@ -0,0 +1,62 @@ +case $foo in + 0) : ;& + 1) : ;;& + *) : ;; +esac +--- + +[#1 Content] = 1:2-1:3 + >-< +1| 0) : ;& + +[#1 Removal] = 1:0-1:3 + >---< +1| 0) : ;& + +[#1 Leading delimiter] = 1:0-1:2 + >--< +1| 0) : ;& + +[#1 Domain] = 1:2-1:9 + >-------< +1| 0) : ;& + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:2-2:3 + >-< +2| 1) : ;;& + +[#2 Removal] = 2:0-2:3 + >---< +2| 1) : ;;& + +[#2 Leading delimiter] = 2:0-2:2 + >--< +2| 1) : ;;& + +[#2 Domain] = 2:2-2:10 + >--------< +2| 1) : ;;& + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 3:2-3:3 + >-< +3| *) : ;; + +[#3 Removal] = 3:0-3:3 + >---< +3| *) : ;; + +[#3 Leading delimiter] = 3:0-3:2 + >--< +3| *) : ;; + +[#3 Domain] = 3:2-3:9 + >-------< +3| *) : ;; + +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/interior/interior.function3.scope b/resources/fixtures/scopes/shellscript/interior/interior.function3.scope new file mode 100644 index 00000000000..b23a53b7f4b --- /dev/null +++ b/resources/fixtures/scopes/shellscript/interior/interior.function3.scope @@ -0,0 +1,13 @@ +foo() ( : ) +--- + +[Content] = 0:8-0:9 + >-< +0| foo() ( : ) + +[Removal] = +[Domain] = 0:7-0:10 + >---< +0| foo() ( : ) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/interior/interior.switchCase2.scope b/resources/fixtures/scopes/shellscript/interior/interior.switchCase2.scope new file mode 100644 index 00000000000..2e25951098e --- /dev/null +++ b/resources/fixtures/scopes/shellscript/interior/interior.switchCase2.scope @@ -0,0 +1,61 @@ +case $foo in + 0) : ;& + 1) : ;;& + *) : ;; +esac +--- + +[#1 Content] = 1:2-3:9 + >------- +1| 0) : ;& +2| 1) : ;;& +3| *) : ;; + ---------< + +[#1 Removal] = +[#1 Domain] = 0:12-4:0 + > +0| case $foo in +1| 0) : ;& +2| 1) : ;;& +3| *) : ;; +4| esac + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:5-1:6 + >-< +1| 0) : ;& + +[#2 Removal] = +[#2 Domain] = 1:4-1:7 + >---< +1| 0) : ;& + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:5-2:6 + >-< +2| 1) : ;;& + +[#3 Removal] = +[#3 Domain] = 2:4-2:7 + >---< +2| 1) : ;;& + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 3:5-3:6 + >-< +3| *) : ;; + +[#4 Removal] = +[#4 Domain] = 3:4-3:7 + >---< +3| *) : ;; + +[#4 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/key.mapPair.iteration2.scope b/resources/fixtures/scopes/shellscript/key.mapPair.iteration2.scope new file mode 100644 index 00000000000..221cbbed1ad --- /dev/null +++ b/resources/fixtures/scopes/shellscript/key.mapPair.iteration2.scope @@ -0,0 +1,10 @@ +foo=("aaa"$bar bbb) +bar=(["aaa"] bbb) +baz=("[aaa]=0" bbb) +bongo=(["aaa"]=0) +--- + +[Content] = +[Domain] = 3:7-3:16 + >---------< +3| bongo=(["aaa"]=0) diff --git a/resources/fixtures/scopes/shellscript/key.mapPair2.scope b/resources/fixtures/scopes/shellscript/key.mapPair2.scope new file mode 100644 index 00000000000..894a8ed7937 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/key.mapPair2.scope @@ -0,0 +1,16 @@ +foo=("aaa"$bar bbb) +bar=(["aaa"] bbb) +baz=("[aaa]=0" bbb) +bongo=(["aaa"]=0) +--- + +[Content] = +[Removal] = 3:8-3:13 + >-----< +3| bongo=(["aaa"]=0) + +[Domain] = 3:7-3:16 + >---------< +3| bongo=(["aaa"]=0) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/key.mapPair3.scope b/resources/fixtures/scopes/shellscript/key.mapPair3.scope new file mode 100644 index 00000000000..0ebd2404dba --- /dev/null +++ b/resources/fixtures/scopes/shellscript/key.mapPair3.scope @@ -0,0 +1,13 @@ +foo=(["aaa"]="bbb"$bar) +--- + +[Content] = +[Removal] = 0:6-0:11 + >-----< +0| foo=(["aaa"]="bbb"$bar) + +[Domain] = 0:5-0:22 + >-----------------< +0| foo=(["aaa"]="bbb"$bar) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/list2.scope b/resources/fixtures/scopes/shellscript/list2.scope new file mode 100644 index 00000000000..d1ea91eb0e2 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/list2.scope @@ -0,0 +1,40 @@ +foo=("aaa"$bar bbb) +bar=(["aaa"] bbb) +baz=("[aaa]=0" bbb) +bongo=(["aaa"]=0) +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:4-0:19 + >---------------< +0| foo=("aaa"$bar bbb) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:4-1:17 + >-------------< +1| bar=(["aaa"] bbb) + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:4-2:19 + >---------------< +2| baz=("[aaa]=0" bbb) + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = +[#4 Domain] = 3:6-3:17 + >-----------< +3| bongo=(["aaa"]=0) + +[#4 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/map2.scope b/resources/fixtures/scopes/shellscript/map2.scope new file mode 100644 index 00000000000..9ea7791aa9d --- /dev/null +++ b/resources/fixtures/scopes/shellscript/map2.scope @@ -0,0 +1,13 @@ +foo=("aaa"$bar bbb) +bar=(["aaa"] bbb) +baz=("[aaa]=0" bbb) +bongo=(["aaa"]=0) +--- + +[Content] = +[Removal] = +[Domain] = 3:6-3:17 + >-----------< +3| bongo=(["aaa"]=0) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/map3.scope b/resources/fixtures/scopes/shellscript/map3.scope new file mode 100644 index 00000000000..0ba3376ef34 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/map3.scope @@ -0,0 +1,10 @@ +foo=(["aaa"]="bbb"$bar) +--- + +[Content] = +[Removal] = +[Domain] = 0:4-0:23 + >-------------------< +0| foo=(["aaa"]="bbb"$bar) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/name/name.iteration.block5.scope b/resources/fixtures/scopes/shellscript/name/name.iteration.block5.scope new file mode 100644 index 00000000000..6d8496b4340 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/name/name.iteration.block5.scope @@ -0,0 +1,34 @@ +case $foo in + 0) : ;& + 1) : ;;& + *) : ;; +esac +--- + +[#1 Content] = +[#1 Domain] = 0:0-4:4 + >------------ +0| case $foo in +1| 0) : ;& +2| 1) : ;;& +3| *) : ;; +4| esac + ----< + + +[#2 Content] = +[#2 Domain] = 1:4-1:7 + >---< +1| 0) : ;& + + +[#3 Content] = +[#3 Domain] = 2:4-2:7 + >---< +2| 1) : ;;& + + +[#4 Content] = +[#4 Domain] = 3:4-3:7 + >---< +3| *) : ;; diff --git a/resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope b/resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope new file mode 100644 index 00000000000..0b1f053b521 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope @@ -0,0 +1,10 @@ +foo() ( : ) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| foo() ( : ) + +[Insertion delimiter] = "\n\n" diff --git a/resources/fixtures/scopes/shellscript/statement/statement.function3.scope b/resources/fixtures/scopes/shellscript/statement/statement.function3.scope new file mode 100644 index 00000000000..5880898ab11 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/statement/statement.function3.scope @@ -0,0 +1,10 @@ +function foo() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| function foo() {} + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/shellscript/statement/statement.function4.scope b/resources/fixtures/scopes/shellscript/statement/statement.function4.scope new file mode 100644 index 00000000000..017d69101a4 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/statement/statement.function4.scope @@ -0,0 +1,30 @@ +foo() ( : ) +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:11 + >-----------< +0| foo() ( : ) + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 0:8-0:9 + >-< +0| foo() ( : ) + +[#2 Removal] = 0:8-0:10 + >--< +0| foo() ( : ) + +[#2 Leading delimiter] = 0:7-0:8 + >-< +0| foo() ( : ) + +[#2 Trailing delimiter] = 0:9-0:10 + >-< +0| foo() ( : ) + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/shellscript/statement/statement.functionCall3.scope b/resources/fixtures/scopes/shellscript/statement/statement.functionCall3.scope new file mode 100644 index 00000000000..cd65a150c1f --- /dev/null +++ b/resources/fixtures/scopes/shellscript/statement/statement.functionCall3.scope @@ -0,0 +1,10 @@ +foo | bar | baz +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| foo | bar | baz + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/shellscript/statement/statement.functionCall4.scope b/resources/fixtures/scopes/shellscript/statement/statement.functionCall4.scope new file mode 100644 index 00000000000..e86f15031aa --- /dev/null +++ b/resources/fixtures/scopes/shellscript/statement/statement.functionCall4.scope @@ -0,0 +1,10 @@ +foo |& bar +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:10 + >----------< +0| foo |& bar + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/shellscript/statement/statement.functionCall5.scope b/resources/fixtures/scopes/shellscript/statement/statement.functionCall5.scope new file mode 100644 index 00000000000..b998a65f3ff --- /dev/null +++ b/resources/fixtures/scopes/shellscript/statement/statement.functionCall5.scope @@ -0,0 +1,35 @@ +(foo; bar) +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:10 + >----------< +0| (foo; bar) + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:1-0:4 + >---< +0| (foo; bar) + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 0:6-0:9 + >---< +0| (foo; bar) + +[#3 Removal] = 0:5-0:9 + >----< +0| (foo; bar) + +[#3 Leading delimiter] = 0:5-0:6 + >-< +0| (foo; bar) + +[#3 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/shellscript/statement/statement.iteration.block5.scope b/resources/fixtures/scopes/shellscript/statement/statement.iteration.block5.scope new file mode 100644 index 00000000000..6d8496b4340 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/statement/statement.iteration.block5.scope @@ -0,0 +1,34 @@ +case $foo in + 0) : ;& + 1) : ;;& + *) : ;; +esac +--- + +[#1 Content] = +[#1 Domain] = 0:0-4:4 + >------------ +0| case $foo in +1| 0) : ;& +2| 1) : ;;& +3| *) : ;; +4| esac + ----< + + +[#2 Content] = +[#2 Domain] = 1:4-1:7 + >---< +1| 0) : ;& + + +[#3 Content] = +[#3 Domain] = 2:4-2:7 + >---< +2| 1) : ;;& + + +[#4 Content] = +[#4 Domain] = 3:4-3:7 + >---< +3| *) : ;; diff --git a/resources/fixtures/scopes/shellscript/value/value.foreach2.scope b/resources/fixtures/scopes/shellscript/value/value.foreach2.scope new file mode 100644 index 00000000000..86214ba2f1e --- /dev/null +++ b/resources/fixtures/scopes/shellscript/value/value.foreach2.scope @@ -0,0 +1,20 @@ +for v in aaa bbb ccc; do :; done +--- + +[Content] = 0:9-0:20 + >-----------< +0| for v in aaa bbb ccc; do :; done + +[Removal] = 0:8-0:20 + >------------< +0| for v in aaa bbb ccc; do :; done + +[Leading delimiter] = 0:8-0:9 + >-< +0| for v in aaa bbb ccc; do :; done + +[Domain] = 0:0-0:32 + >--------------------------------< +0| for v in aaa bbb ccc; do :; done + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/value/value.iteration.block5.scope b/resources/fixtures/scopes/shellscript/value/value.iteration.block5.scope new file mode 100644 index 00000000000..6d8496b4340 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/value/value.iteration.block5.scope @@ -0,0 +1,34 @@ +case $foo in + 0) : ;& + 1) : ;;& + *) : ;; +esac +--- + +[#1 Content] = +[#1 Domain] = 0:0-4:4 + >------------ +0| case $foo in +1| 0) : ;& +2| 1) : ;;& +3| *) : ;; +4| esac + ----< + + +[#2 Content] = +[#2 Domain] = 1:4-1:7 + >---< +1| 0) : ;& + + +[#3 Content] = +[#3 Domain] = 2:4-2:7 + >---< +2| 1) : ;;& + + +[#4 Content] = +[#4 Domain] = 3:4-3:7 + >---< +3| *) : ;; diff --git a/resources/fixtures/scopes/shellscript/value/value.mapPair.iteration2.scope b/resources/fixtures/scopes/shellscript/value/value.mapPair.iteration2.scope new file mode 100644 index 00000000000..124db45b789 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/value/value.mapPair.iteration2.scope @@ -0,0 +1,20 @@ +foo=("aaa"$bar bbb) +bar=(["aaa"] bbb) +baz=("[aaa]=0" bbb) +bongo=(["aaa"]=0) +--- + +[#1 Content] = +[#1 Domain] = 0:0-3:17 + >------------------- +0| foo=("aaa"$bar bbb) +1| bar=(["aaa"] bbb) +2| baz=("[aaa]=0" bbb) +3| bongo=(["aaa"]=0) + -----------------< + + +[#2 Content] = +[#2 Domain] = 3:7-3:16 + >---------< +3| bongo=(["aaa"]=0) diff --git a/resources/fixtures/scopes/shellscript/value/value.mapPair2.scope b/resources/fixtures/scopes/shellscript/value/value.mapPair2.scope new file mode 100644 index 00000000000..0d8d0500188 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/value/value.mapPair2.scope @@ -0,0 +1,92 @@ +foo=("aaa"$bar bbb) +bar=(["aaa"] bbb) +baz=("[aaa]=0" bbb) +bongo=(["aaa"]=0) +--- + +[#1 Content] = 0:4-0:19 + >---------------< +0| foo=("aaa"$bar bbb) + +[#1 Removal] = 0:3-0:19 + >----------------< +0| foo=("aaa"$bar bbb) + +[#1 Leading delimiter] = 0:3-0:4 + >-< +0| foo=("aaa"$bar bbb) + +[#1 Domain] = 0:0-0:19 + >-------------------< +0| foo=("aaa"$bar bbb) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:17 + >-------------< +1| bar=(["aaa"] bbb) + +[#2 Removal] = 1:3-1:17 + >--------------< +1| bar=(["aaa"] bbb) + +[#2 Leading delimiter] = 1:3-1:4 + >-< +1| bar=(["aaa"] bbb) + +[#2 Domain] = 1:0-1:17 + >-----------------< +1| bar=(["aaa"] bbb) + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:4-2:19 + >---------------< +2| baz=("[aaa]=0" bbb) + +[#3 Removal] = 2:3-2:19 + >----------------< +2| baz=("[aaa]=0" bbb) + +[#3 Leading delimiter] = 2:3-2:4 + >-< +2| baz=("[aaa]=0" bbb) + +[#3 Domain] = 2:0-2:19 + >-------------------< +2| baz=("[aaa]=0" bbb) + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 3:6-3:17 + >-----------< +3| bongo=(["aaa"]=0) + +[#4 Removal] = 3:5-3:17 + >------------< +3| bongo=(["aaa"]=0) + +[#4 Leading delimiter] = 3:5-3:6 + >-< +3| bongo=(["aaa"]=0) + +[#4 Domain] = 3:0-3:17 + >-----------------< +3| bongo=(["aaa"]=0) + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 3:15-3:16 + >-< +3| bongo=(["aaa"]=0) + +[#5 Domain] = 3:7-3:16 + >---------< +3| bongo=(["aaa"]=0) + +[#5 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/shellscript/value/value.mapPair3.scope b/resources/fixtures/scopes/shellscript/value/value.mapPair3.scope new file mode 100644 index 00000000000..95bb987c922 --- /dev/null +++ b/resources/fixtures/scopes/shellscript/value/value.mapPair3.scope @@ -0,0 +1,32 @@ +foo=(["aaa"]="bbb"$bar) +--- + +[#1 Content] = 0:4-0:23 + >-------------------< +0| foo=(["aaa"]="bbb"$bar) + +[#1 Removal] = 0:3-0:23 + >--------------------< +0| foo=(["aaa"]="bbb"$bar) + +[#1 Leading delimiter] = 0:3-0:4 + >-< +0| foo=(["aaa"]="bbb"$bar) + +[#1 Domain] = 0:0-0:23 + >-----------------------< +0| foo=(["aaa"]="bbb"$bar) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:13-0:22 + >---------< +0| foo=(["aaa"]="bbb"$bar) + +[#2 Domain] = 0:5-0:22 + >-----------------< +0| foo=(["aaa"]="bbb"$bar) + +[#2 Insertion delimiter] = " " diff --git a/resources/queries/shellscript.scm b/resources/queries/shellscript.scm index cf60da6b3aa..34e3df25c17 100644 --- a/resources/queries/shellscript.scm +++ b/resources/queries/shellscript.scm @@ -6,12 +6,17 @@ (function_definition) (declaration_command) (case_statement) - (subshell) (list) + (pipeline) (redirected_statement) (test_command) ] @statement +( + (subshell) @statement + (#not-parent-type? @statement function_definition) +) + ( [ (variable_assignment) @@ -22,6 +27,7 @@ declaration_command c_style_for_statement list + pipeline redirected_statement if_statement elif_clause @@ -63,31 +69,71 @@ ;;!! foo=(["aaa"]=0 ["bbb"]=1) ;;! ^^^^^^^^^^^^^^^^^^^^^ ;;! ^^^^^^^^^^^^^^^^^^^ -(array - "(" @collectionKey.iteration.start.endOf @value.iteration.start.endOf - (concatenation) - ")" @collectionKey.iteration.end.startOf @value.iteration.end.startOf -) @map +;; Bash represents ["key"]=value as concatenated words and a string. +;; Require the brackets and assignment before treating an array as a map. +( + (array + "(" @collectionKey.iteration.start.endOf @value.iteration.start.endOf + (concatenation + . + (word) @_open + . + (string) + . + (word) @_close + . + (word) @_assignment + ) + ")" @collectionKey.iteration.end.startOf @value.iteration.end.startOf + ) @map + (#eq? @_open "[") + (#eq? @_close "]") + (#match? @_assignment "^=") +) ;;!! foo=(["aaa"]=0 ["bbb"]=1) ;;! ^^^^^ ^^^^^ ;;! ^ ^ (array (concatenation + . + (word) @_open + . (string) @collectionKey - (_) @value + . + (word) @_close + . + (word) @value.start + (_)? @value.end . ) @_.domain - (#character-range! @value 1) + (#eq? @_open "[") + (#eq? @_close "]") + (#match? @value.start "^=") + (#character-range! @value.start 1) ) ;;!! for v in values; do :; done ;;! ^ ;;! ^^^^^^ -(for_statement - variable: (_) @name - value: (_) @value -) @_.domain +[ + (for_statement + variable: (_) @name + . + value: (_) @value + . + body: (do_group) + ) + (for_statement + variable: (_) @name + . + value: (_) @value.start + value: (_)* + value: (_) @value.end + . + body: (do_group) + ) +] @_.domain ;;!! for ((i = 0; i < 2; i++)); do :; done ;;! ^^^^^ @@ -178,11 +224,31 @@ ;;!! 0) : ;; ;;! ^ +[ + (case_item + . + value: (_) @condition + . + ")" + ) + (case_item + . + value: (_) @condition.start + value: (_)* + value: (_) @condition.end + . + ")" + ) +] @condition.domain + (case_item - value: (_) @condition ")" @interior.start.endOf @statementNameValue.iteration.start.endOf - ";;" @interior.end.startOf @statementNameValue.iteration.end.startOf -) @branch @condition.domain + [ + ";;" + ";&" + ";;&" + ] @interior.end.startOf @statementNameValue.iteration.end.startOf +) @branch ;;!! return 0 ;;! ^ @@ -210,6 +276,13 @@ "}" @interior.end.startOf @statementNameValue.iteration.end.startOf ) +;;!! foo() ( : ) +;;! ^^^ +(subshell + "(" @interior.start.endOf @statementNameValue.iteration.start.endOf + ")" @interior.end.startOf @statementNameValue.iteration.end.startOf +) + ;;!! # foo ;;! ^^^^^ (comment) @comment @textFragment From c6d8a27ec5cc1342dfc2ae624d58e1395be8bba3 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 10 Sep 2026 07:59:27 +0200 Subject: [PATCH 2/4] More tests --- .../user/languages/fixtures/shellscript.json | 25 +++++--------- .../user/scopes/fixtures/namedFunction.json | 8 ++--- .../docs/user/scopes/fixtures/statement.json | 17 +++------- .../namedFunction/namedFunction4.scope | 8 ++--- .../statement/statement.function4.scope | 34 ++++--------------- resources/queries/shellscript.scm | 1 + 6 files changed, 28 insertions(+), 65 deletions(-) diff --git a/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json b/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json index 5c32b11fc99..8e9c243685c 100644 --- a/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json +++ b/packages/app-web-docs/src/docs/user/languages/fixtures/shellscript.json @@ -1474,16 +1474,16 @@ "name": "scopes/shellscript/namedFunction/namedFunction4", "languageId": "shellscript", "facet": "namedFunction", - "code": "foo() ( : )", + "code": "foo() ()", "scopes": [ { "targets": [ { - "content": "0:0-0:11", - "removal": "0:0-0:11" + "content": "0:0-0:8", + "removal": "0:0-0:8" } ], - "domain": "0:0-0:11" + "domain": "0:0-0:8" } ] }, @@ -1714,25 +1714,16 @@ "name": "scopes/shellscript/statement/statement.function4", "languageId": "shellscript", "facet": "statement.function", - "code": "foo() ( : )", + "code": "foo() ()", "scopes": [ { "targets": [ { - "content": "0:0-0:11", - "removal": "0:0-0:11" - } - ], - "domain": "0:0-0:11" - }, - { - "targets": [ - { - "content": "0:8-0:9", - "removal": "0:8-0:10" + "content": "0:0-0:8", + "removal": "0:0-0:8" } ], - "domain": "0:8-0:9" + "domain": "0:0-0:8" } ] }, diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json index 8e0f1a412ec..e20c1b706f7 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/namedFunction.json @@ -1964,16 +1964,16 @@ "name": "scopes/shellscript/namedFunction/namedFunction4", "languageId": "shellscript", "facet": "namedFunction", - "code": "foo() ( : )", + "code": "foo() ()", "scopes": [ { "targets": [ { - "content": "0:0-0:11", - "removal": "0:0-0:11" + "content": "0:0-0:8", + "removal": "0:0-0:8" } ], - "domain": "0:0-0:11" + "domain": "0:0-0:8" } ] }, diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json index 29a31dd5a3c..2573e483a0e 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json @@ -10802,25 +10802,16 @@ "name": "scopes/shellscript/statement/statement.function4", "languageId": "shellscript", "facet": "statement.function", - "code": "foo() ( : )", + "code": "foo() ()", "scopes": [ { "targets": [ { - "content": "0:0-0:11", - "removal": "0:0-0:11" - } - ], - "domain": "0:0-0:11" - }, - { - "targets": [ - { - "content": "0:8-0:9", - "removal": "0:8-0:10" + "content": "0:0-0:8", + "removal": "0:0-0:8" } ], - "domain": "0:8-0:9" + "domain": "0:0-0:8" } ] }, diff --git a/resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope b/resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope index 0b1f053b521..15bcd66e4b2 100644 --- a/resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope +++ b/resources/fixtures/scopes/shellscript/namedFunction/namedFunction4.scope @@ -1,10 +1,10 @@ -foo() ( : ) +foo() () --- [Content] = [Removal] = -[Domain] = 0:0-0:11 - >-----------< -0| foo() ( : ) +[Domain] = 0:0-0:8 + >--------< +0| foo() () [Insertion delimiter] = "\n\n" diff --git a/resources/fixtures/scopes/shellscript/statement/statement.function4.scope b/resources/fixtures/scopes/shellscript/statement/statement.function4.scope index 017d69101a4..112383fb14f 100644 --- a/resources/fixtures/scopes/shellscript/statement/statement.function4.scope +++ b/resources/fixtures/scopes/shellscript/statement/statement.function4.scope @@ -1,30 +1,10 @@ -foo() ( : ) +foo() () --- -[#1 Content] = -[#1 Removal] = -[#1 Domain] = 0:0-0:11 - >-----------< -0| foo() ( : ) +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| foo() () -[#1 Insertion delimiter] = "\n" - - -[#2 Content] = -[#2 Domain] = 0:8-0:9 - >-< -0| foo() ( : ) - -[#2 Removal] = 0:8-0:10 - >--< -0| foo() ( : ) - -[#2 Leading delimiter] = 0:7-0:8 - >-< -0| foo() ( : ) - -[#2 Trailing delimiter] = 0:9-0:10 - >-< -0| foo() ( : ) - -[#2 Insertion delimiter] = "\n" +[Insertion delimiter] = "\n" diff --git a/resources/queries/shellscript.scm b/resources/queries/shellscript.scm index 34e3df25c17..74e9142da09 100644 --- a/resources/queries/shellscript.scm +++ b/resources/queries/shellscript.scm @@ -33,6 +33,7 @@ elif_clause while_statement ) + (#not-eq? @statement "") ) ;; Capture body statements without including commands before "then". From 1b2556720eddb156da499bc2cccaaa5436c770f7 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 10 Sep 2026 08:25:40 +0200 Subject: [PATCH 3/4] Fixed pipeline --- resources/queries/shellscript.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/queries/shellscript.scm b/resources/queries/shellscript.scm index 74e9142da09..7b2e5eefa05 100644 --- a/resources/queries/shellscript.scm +++ b/resources/queries/shellscript.scm @@ -7,7 +7,6 @@ (declaration_command) (case_statement) (list) - (pipeline) (redirected_statement) (test_command) ] @statement @@ -21,6 +20,7 @@ [ (variable_assignment) (command) + (pipeline) ] @statement (#not-parent-type? @statement @@ -43,6 +43,7 @@ [ (command) (variable_assignment) + (pipeline) ] @statement ) (elif_clause @@ -50,6 +51,7 @@ [ (command) (variable_assignment) + (pipeline) ] @statement ) ] From 1ce96035e54c39b3af11c99bdc2e4da37bada989 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 10 Sep 2026 08:37:57 +0200 Subject: [PATCH 4/4] fix --- resources/queries/shellscript.scm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/queries/shellscript.scm b/resources/queries/shellscript.scm index 7b2e5eefa05..c03be380982 100644 --- a/resources/queries/shellscript.scm +++ b/resources/queries/shellscript.scm @@ -72,7 +72,7 @@ ;;!! foo=(["aaa"]=0 ["bbb"]=1) ;;! ^^^^^^^^^^^^^^^^^^^^^ ;;! ^^^^^^^^^^^^^^^^^^^ -;; Bash represents ["key"]=value as concatenated words and a string. +;; Bash represents bracketed entries as concatenated key/value fragments. ;; Require the brackets and assignment before treating an array as a map. ( (array @@ -81,7 +81,7 @@ . (word) @_open . - (string) + (_) . (word) @_close . @@ -102,7 +102,7 @@ . (word) @_open . - (string) @collectionKey + (_) @collectionKey . (word) @_close . @@ -125,6 +125,8 @@ . value: (_) @value . + (comment)* + . body: (do_group) ) (for_statement @@ -134,6 +136,8 @@ value: (_)* value: (_) @value.end . + (comment)* + . body: (do_group) ) ] @_.domain