From bd8f6aba5ad4e89570fd3033c5360190b71f6acd Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 30 Jun 2025 15:39:57 +0200 Subject: [PATCH 1/6] Replace `private.switchStatementSubject` with value scope --- cursorless-talon/src/spoken_forms.py | 1 - .../recorded/languages/cpp/clearSubject.yml | 7 ++--- .../recorded/languages/cpp/clearSubject2.yml | 7 ++--- .../recorded/languages/java/clearSubject.yml | 7 ++--- .../recorded/languages/java/clearSubject2.yml | 7 ++--- .../languages/python/clearSubject.yml | 7 ++--- .../recorded/languages/rust/changeSubject.yml | 7 ++--- .../recorded/languages/scala/clearSubject.yml | 7 ++--- .../languages/typescript/clearSubject.yml | 7 ++--- .../languages/typescript/clearSubject2.yml | 7 ++--- ...tementSubject.scope => value.switch.scope} | 0 .../scopes/cpp/switchStatementSubject.scope | 13 -------- data/fixtures/scopes/cpp/value.switch.scope | 13 ++++++++ .../csharp/switchStatementSubject.scope | 20 ------------ .../csharp/switchStatementSubject2.scope | 20 ------------ .../fixtures/scopes/csharp/value.switch.scope | 13 ++++++++ .../scopes/java/switchStatementSubject.scope | 13 -------- data/fixtures/scopes/java/value.switch.scope | 13 ++++++++ .../switchStatementSubject.scope | 18 ----------- .../scopes/javascript.core/value.switch.scope | 13 ++++++++ ...tementSubject.scope => value.switch.scope} | 0 packages/common/src/scopeSupportFacets/c.ts | 2 +- .../common/src/scopeSupportFacets/csharp.ts | 2 +- packages/common/src/scopeSupportFacets/css.ts | 2 +- .../common/src/scopeSupportFacets/html.ts | 2 +- .../common/src/scopeSupportFacets/java.ts | 2 +- .../src/scopeSupportFacets/javascript.ts | 2 +- .../common/src/scopeSupportFacets/json.ts | 2 +- .../common/src/scopeSupportFacets/markdown.ts | 2 +- .../common/src/scopeSupportFacets/python.ts | 3 +- packages/common/src/scopeSupportFacets/r.ts | 2 +- packages/common/src/scopeSupportFacets/scm.ts | 2 +- .../scopeSupportFacetInfos.ts | 8 ++--- .../scopeSupportFacets.types.ts | 2 +- .../common/src/scopeSupportFacets/talon.ts | 2 +- packages/common/src/scopeSupportFacets/xml.ts | 2 +- .../common/src/scopeSupportFacets/yaml.ts | 2 +- .../command/PartialTargetDescriptor.types.ts | 1 - .../src/scopeProviders/ScopeInfoProvider.ts | 1 - .../spokenForms/defaultSpokenFormMapCore.ts | 1 - .../runCustomSpokenFormScopeInfoTest.ts | 31 ------------------- queries/c.scm | 4 +-- queries/csharp.scm | 4 +-- queries/java.scm | 4 +-- queries/javascript.core.scm | 6 ++-- queries/kotlin.scm | 4 +-- queries/python.scm | 2 +- queries/rust.scm | 2 +- queries/scala.scm | 2 +- 49 files changed, 103 insertions(+), 198 deletions(-) rename data/fixtures/scopes/c/{switchStatementSubject.scope => value.switch.scope} (100%) delete mode 100644 data/fixtures/scopes/cpp/switchStatementSubject.scope create mode 100644 data/fixtures/scopes/cpp/value.switch.scope delete mode 100644 data/fixtures/scopes/csharp/switchStatementSubject.scope delete mode 100644 data/fixtures/scopes/csharp/switchStatementSubject2.scope create mode 100644 data/fixtures/scopes/csharp/value.switch.scope delete mode 100644 data/fixtures/scopes/java/switchStatementSubject.scope create mode 100644 data/fixtures/scopes/java/value.switch.scope delete mode 100644 data/fixtures/scopes/javascript.core/switchStatementSubject.scope create mode 100644 data/fixtures/scopes/javascript.core/value.switch.scope rename data/fixtures/scopes/python/{switchStatementSubject.scope => value.switch.scope} (100%) diff --git a/cursorless-talon/src/spoken_forms.py b/cursorless-talon/src/spoken_forms.py index d41add5d9d..f04f9cb348 100644 --- a/cursorless-talon/src/spoken_forms.py +++ b/cursorless-talon/src/spoken_forms.py @@ -156,7 +156,6 @@ def handle_new_values(csv_name: str, values: list[SpokenFormEntry]): ], extra_allowed_values=[ "private.fieldAccess", - "private.switchStatementSubject", "textFragment", "disqualifyDelimiter", "pairDelimiter", diff --git a/data/fixtures/recorded/languages/cpp/clearSubject.yml b/data/fixtures/recorded/languages/cpp/clearSubject.yml index f8e26ce57a..0de333d671 100644 --- a/data/fixtures/recorded/languages/cpp/clearSubject.yml +++ b/data/fixtures/recorded/languages/cpp/clearSubject.yml @@ -1,18 +1,15 @@ languageId: cpp command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: | int main() { diff --git a/data/fixtures/recorded/languages/cpp/clearSubject2.yml b/data/fixtures/recorded/languages/cpp/clearSubject2.yml index 0da97e7df2..2074efd3e5 100644 --- a/data/fixtures/recorded/languages/cpp/clearSubject2.yml +++ b/data/fixtures/recorded/languages/cpp/clearSubject2.yml @@ -1,18 +1,15 @@ languageId: cpp command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: false -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: | int main() { diff --git a/data/fixtures/recorded/languages/java/clearSubject.yml b/data/fixtures/recorded/languages/java/clearSubject.yml index 5689baf160..e180dbf739 100644 --- a/data/fixtures/recorded/languages/java/clearSubject.yml +++ b/data/fixtures/recorded/languages/java/clearSubject.yml @@ -1,18 +1,15 @@ languageId: java command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: | class Aaa { diff --git a/data/fixtures/recorded/languages/java/clearSubject2.yml b/data/fixtures/recorded/languages/java/clearSubject2.yml index 121a3cabbe..7b3d6417d8 100644 --- a/data/fixtures/recorded/languages/java/clearSubject2.yml +++ b/data/fixtures/recorded/languages/java/clearSubject2.yml @@ -1,18 +1,15 @@ languageId: java command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: | class Aaa { diff --git a/data/fixtures/recorded/languages/python/clearSubject.yml b/data/fixtures/recorded/languages/python/clearSubject.yml index cfe7f8e9fb..43540b02f2 100644 --- a/data/fixtures/recorded/languages/python/clearSubject.yml +++ b/data/fixtures/recorded/languages/python/clearSubject.yml @@ -1,18 +1,15 @@ languageId: python command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: | match 0: diff --git a/data/fixtures/recorded/languages/rust/changeSubject.yml b/data/fixtures/recorded/languages/rust/changeSubject.yml index 053e4422b5..5513bf172d 100644 --- a/data/fixtures/recorded/languages/rust/changeSubject.yml +++ b/data/fixtures/recorded/languages/rust/changeSubject.yml @@ -1,18 +1,15 @@ languageId: rust command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: | match user { diff --git a/data/fixtures/recorded/languages/scala/clearSubject.yml b/data/fixtures/recorded/languages/scala/clearSubject.yml index 7db719aaa3..1a3e6d81ed 100644 --- a/data/fixtures/recorded/languages/scala/clearSubject.yml +++ b/data/fixtures/recorded/languages/scala/clearSubject.yml @@ -1,18 +1,15 @@ languageId: scala command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: | def matchTest(x: Int): String = x match { diff --git a/data/fixtures/recorded/languages/typescript/clearSubject.yml b/data/fixtures/recorded/languages/typescript/clearSubject.yml index f8f6a484f7..658da855de 100644 --- a/data/fixtures/recorded/languages/typescript/clearSubject.yml +++ b/data/fixtures/recorded/languages/typescript/clearSubject.yml @@ -1,18 +1,15 @@ languageId: typescript command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: |- switch(aaa) { diff --git a/data/fixtures/recorded/languages/typescript/clearSubject2.yml b/data/fixtures/recorded/languages/typescript/clearSubject2.yml index a40be6bb41..57dbc66097 100644 --- a/data/fixtures/recorded/languages/typescript/clearSubject2.yml +++ b/data/fixtures/recorded/languages/typescript/clearSubject2.yml @@ -1,18 +1,15 @@ languageId: typescript command: version: 6 - spokenForm: change subject + spokenForm: change value action: name: clearAndSetSelection target: type: primitive modifiers: - type: containingScope - scopeType: {type: private.switchStatementSubject} + scopeType: {type: value} usePrePhraseSnapshot: true -spokenFormError: >- - simple scope type type with id private.switchStatementSubject; this is a - private spoken form currently only for internal experimentation initialState: documentContents: |- switch(aaa + 1) { diff --git a/data/fixtures/scopes/c/switchStatementSubject.scope b/data/fixtures/scopes/c/value.switch.scope similarity index 100% rename from data/fixtures/scopes/c/switchStatementSubject.scope rename to data/fixtures/scopes/c/value.switch.scope diff --git a/data/fixtures/scopes/cpp/switchStatementSubject.scope b/data/fixtures/scopes/cpp/switchStatementSubject.scope deleted file mode 100644 index 6cc122d5a9..0000000000 --- a/data/fixtures/scopes/cpp/switchStatementSubject.scope +++ /dev/null @@ -1,13 +0,0 @@ -switch (int i = rand() % 100; i) {} ---- - -[Content] = -[Removal] = 0:8-0:31 - >-----------------------< -0| switch (int i = rand() % 100; i) {} - -[Domain] = 0:0-0:35 - >-----------------------------------< -0| switch (int i = rand() % 100; i) {} - -[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/value.switch.scope b/data/fixtures/scopes/cpp/value.switch.scope new file mode 100644 index 0000000000..67688ae8d0 --- /dev/null +++ b/data/fixtures/scopes/cpp/value.switch.scope @@ -0,0 +1,13 @@ +switch (value) {} +--- + +[Content] = +[Removal] = 0:8-0:13 + >-----< +0| switch (value) {} + +[Domain] = 0:0-0:17 + >-----------------< +0| switch (value) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/switchStatementSubject.scope b/data/fixtures/scopes/csharp/switchStatementSubject.scope deleted file mode 100644 index 3c3642eeb0..0000000000 --- a/data/fixtures/scopes/csharp/switchStatementSubject.scope +++ /dev/null @@ -1,20 +0,0 @@ -switch (aaa) { - default: - break; -} ---- - -[Content] = -[Removal] = 0:8-0:11 - >---< -0| switch (aaa) { - -[Domain] = 0:0-3:1 - >-------------- -0| switch (aaa) { -1| default: -2| break; -3| } - -< - -[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/switchStatementSubject2.scope b/data/fixtures/scopes/csharp/switchStatementSubject2.scope deleted file mode 100644 index 06e3f48526..0000000000 --- a/data/fixtures/scopes/csharp/switchStatementSubject2.scope +++ /dev/null @@ -1,20 +0,0 @@ -switch (aaa + 1) { - default: - break; -} ---- - -[Content] = -[Removal] = 0:8-0:15 - >-------< -0| switch (aaa + 1) { - -[Domain] = 0:0-3:1 - >------------------ -0| switch (aaa + 1) { -1| default: -2| break; -3| } - -< - -[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.switch.scope b/data/fixtures/scopes/csharp/value.switch.scope new file mode 100644 index 0000000000..67688ae8d0 --- /dev/null +++ b/data/fixtures/scopes/csharp/value.switch.scope @@ -0,0 +1,13 @@ +switch (value) {} +--- + +[Content] = +[Removal] = 0:8-0:13 + >-----< +0| switch (value) {} + +[Domain] = 0:0-0:17 + >-----------------< +0| switch (value) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/switchStatementSubject.scope b/data/fixtures/scopes/java/switchStatementSubject.scope deleted file mode 100644 index d8df9f3d58..0000000000 --- a/data/fixtures/scopes/java/switchStatementSubject.scope +++ /dev/null @@ -1,13 +0,0 @@ -switch (value) { } ---- - -[Content] = -[Removal] = 0:8-0:13 - >-----< -0| switch (value) { } - -[Domain] = 0:0-0:18 - >------------------< -0| switch (value) { } - -[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/value.switch.scope b/data/fixtures/scopes/java/value.switch.scope new file mode 100644 index 0000000000..67688ae8d0 --- /dev/null +++ b/data/fixtures/scopes/java/value.switch.scope @@ -0,0 +1,13 @@ +switch (value) {} +--- + +[Content] = +[Removal] = 0:8-0:13 + >-----< +0| switch (value) {} + +[Domain] = 0:0-0:17 + >-----------------< +0| switch (value) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/switchStatementSubject.scope b/data/fixtures/scopes/javascript.core/switchStatementSubject.scope deleted file mode 100644 index 5098b692ac..0000000000 --- a/data/fixtures/scopes/javascript.core/switchStatementSubject.scope +++ /dev/null @@ -1,18 +0,0 @@ -switch (value) { - -} ---- - -[Content] = -[Removal] = 0:8-0:13 - >-----< -0| switch (value) { - -[Domain] = 0:0-2:1 - >---------------- -0| switch (value) { -1| -2| } - -< - -[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/javascript.core/value.switch.scope b/data/fixtures/scopes/javascript.core/value.switch.scope new file mode 100644 index 0000000000..67688ae8d0 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/value.switch.scope @@ -0,0 +1,13 @@ +switch (value) {} +--- + +[Content] = +[Removal] = 0:8-0:13 + >-----< +0| switch (value) {} + +[Domain] = 0:0-0:17 + >-----------------< +0| switch (value) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/python/switchStatementSubject.scope b/data/fixtures/scopes/python/value.switch.scope similarity index 100% rename from data/fixtures/scopes/python/switchStatementSubject.scope rename to data/fixtures/scopes/python/value.switch.scope diff --git a/packages/common/src/scopeSupportFacets/c.ts b/packages/common/src/scopeSupportFacets/c.ts index ed9cdd8004..7af0d31987 100644 --- a/packages/common/src/scopeSupportFacets/c.ts +++ b/packages/common/src/scopeSupportFacets/c.ts @@ -6,7 +6,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { list: supported, disqualifyDelimiter: supported, - switchStatementSubject: supported, ifStatement: supported, statement: supported, @@ -82,6 +81,7 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { "value.assignment": supported, "value.variable": supported, "value.return": supported, + "value.switch": supported, "type.variable": supported, "type.argument.formal": supported, diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index 86c4da63bc..27a24f7cc2 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -4,7 +4,6 @@ import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const csharpScopeSupport: LanguageScopeSupportFacetMap = { - switchStatementSubject: supported, anonymousFunction: supported, map: supported, list: supported, @@ -88,6 +87,7 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "value.return": supported, "value.variable": supported, "value.yield": supported, + "value.switch": supported, "type.argument.formal": supported, "type.argument.formal.iteration": supported, diff --git a/packages/common/src/scopeSupportFacets/css.ts b/packages/common/src/scopeSupportFacets/css.ts index 87546b4a9b..a72c06f1af 100644 --- a/packages/common/src/scopeSupportFacets/css.ts +++ b/packages/common/src/scopeSupportFacets/css.ts @@ -172,7 +172,6 @@ export const cssScopeSupport: LanguageScopeSupportFacetMap = { "statement.iteration.block": notApplicable, "statement.class": notApplicable, "string.multiLine": notApplicable, - switchStatementSubject: notApplicable, tags: notApplicable, "textFragment.comment.line": notApplicable, "textFragment.element": notApplicable, @@ -217,4 +216,5 @@ export const cssScopeSupport: LanguageScopeSupportFacetMap = { "value.variable.pattern": notApplicable, "value.variable": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/html.ts b/packages/common/src/scopeSupportFacets/html.ts index 58818832fa..57184ee97b 100644 --- a/packages/common/src/scopeSupportFacets/html.ts +++ b/packages/common/src/scopeSupportFacets/html.ts @@ -185,6 +185,7 @@ export const htmlScopeSupport: LanguageScopeSupportFacetMap = { "value.variable.pattern": notApplicable, "value.variable": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, anonymousFunction: notApplicable, class: notApplicable, className: notApplicable, @@ -204,7 +205,6 @@ export const htmlScopeSupport: LanguageScopeSupportFacetMap = { regularExpression: notApplicable, section: notApplicable, statement: notApplicable, - switchStatementSubject: notApplicable, selector: notApplicable, unit: notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 3eec6e205e..3a427587d0 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -7,7 +7,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, anonymousFunction: supported, list: supported, - switchStatementSubject: supported, "argument.actual": supported, "argument.actual.iteration": supported, @@ -138,6 +137,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.return.lambda": supported, "value.variable": supported, "value.resource": supported, + "value.switch": supported, "interior.class": supported, "interior.constructor": supported, diff --git a/packages/common/src/scopeSupportFacets/javascript.ts b/packages/common/src/scopeSupportFacets/javascript.ts index 63a4f750d3..1bece5db7c 100644 --- a/packages/common/src/scopeSupportFacets/javascript.ts +++ b/packages/common/src/scopeSupportFacets/javascript.ts @@ -7,7 +7,6 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { list: supported, map: supported, regularExpression: supported, - switchStatementSubject: supported, fieldAccess: supported, disqualifyDelimiter: supported, pairDelimiter: supported, @@ -150,6 +149,7 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { "value.return.lambda": supported, "value.field": supported, "value.yield": supported, + "value.switch": supported, "type.class": supported, diff --git a/packages/common/src/scopeSupportFacets/json.ts b/packages/common/src/scopeSupportFacets/json.ts index d7d6930b97..081b9f4720 100644 --- a/packages/common/src/scopeSupportFacets/json.ts +++ b/packages/common/src/scopeSupportFacets/json.ts @@ -165,7 +165,6 @@ export const jsonScopeSupport: LanguageScopeSupportFacetMap = { "statement.iteration.block": notApplicable, "statement.iteration.document": notApplicable, "string.multiLine": notApplicable, - switchStatementSubject: notApplicable, tags: notApplicable, "textFragment.element": notApplicable, "textFragment.string.multiLine": notApplicable, @@ -209,6 +208,7 @@ export const jsonScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": notApplicable, "value.variable.pattern": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, selector: notApplicable, unit: notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/markdown.ts b/packages/common/src/scopeSupportFacets/markdown.ts index ad507a1a79..425a24a608 100644 --- a/packages/common/src/scopeSupportFacets/markdown.ts +++ b/packages/common/src/scopeSupportFacets/markdown.ts @@ -160,7 +160,6 @@ export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "statement.iteration.document": notApplicable, "string.multiLine": notApplicable, "string.singleLine": notApplicable, - switchStatementSubject: notApplicable, tags: notApplicable, "textFragment.element": notApplicable, "textFragment.string.multiLine": notApplicable, @@ -208,6 +207,7 @@ export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": notApplicable, "value.variable.pattern": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, selector: notApplicable, unit: notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 3b8a402399..11dc61435a 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -47,6 +47,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "value.return.lambda": supported, "value.variable": supported, "value.variable.pattern": supported, + "value.switch": supported, "type.argument.formal.constructor": supported, "type.argument.formal.constructor.iteration": supported, @@ -145,8 +146,6 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "interior.while": supported, "interior.resource": supported, - switchStatementSubject: supported, - "condition.if": supported, "condition.switchCase": supported, "condition.switchCase.iteration": supported, diff --git a/packages/common/src/scopeSupportFacets/r.ts b/packages/common/src/scopeSupportFacets/r.ts index 9771532caa..aa40ba816c 100644 --- a/packages/common/src/scopeSupportFacets/r.ts +++ b/packages/common/src/scopeSupportFacets/r.ts @@ -66,6 +66,7 @@ export const rScopeSupport: LanguageScopeSupportFacetMap = { "value.attribute": unsupported, "value.foreach": unsupported, "value.return": unsupported, + "value.switch": unsupported, attribute: unsupported, class: unsupported, className: unsupported, @@ -73,7 +74,6 @@ export const rScopeSupport: LanguageScopeSupportFacetMap = { fieldAccess: unsupported, map: unsupported, regularExpression: unsupported, - switchStatementSubject: unsupported, // Not applicable diff --git a/packages/common/src/scopeSupportFacets/scm.ts b/packages/common/src/scopeSupportFacets/scm.ts index 2e01eed71a..1a7018779f 100644 --- a/packages/common/src/scopeSupportFacets/scm.ts +++ b/packages/common/src/scopeSupportFacets/scm.ts @@ -162,7 +162,6 @@ export const scmScopeSupport: LanguageScopeSupportFacetMap = { "statement.iteration.block": notApplicable, "statement.iteration.document": notApplicable, "string.multiLine": notApplicable, - switchStatementSubject: notApplicable, tags: notApplicable, "textFragment.comment.block": notApplicable, "textFragment.element": notApplicable, @@ -209,6 +208,7 @@ export const scmScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": notApplicable, "value.variable.pattern": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, selector: notApplicable, unit: notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 716f3c3b49..a696a725ee 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -71,10 +71,6 @@ export const scopeSupportFacetInfos: Record< description: "A regular expression", scopeType: "regularExpression", }, - switchStatementSubject: { - description: "The subject of a switch statement", - scopeType: "private.switchStatementSubject", - }, fieldAccess: { description: "A field access", scopeType: "private.fieldAccess", @@ -704,6 +700,10 @@ export const scopeSupportFacetInfos: Record< description: "Value of a yield statement", scopeType: "value", }, + "value.switch": { + description: "The value / subject of a switch statement", + scopeType: "value", + }, "value.resource": { description: "Value of a 'with' / 'use' / 'using' statement", scopeType: "value", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 3aa2462aef..2e5107af61 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -20,7 +20,6 @@ export const scopeSupportFacets = [ "map", "ifStatement", "regularExpression", - "switchStatementSubject", "fieldAccess", "statement", @@ -172,6 +171,7 @@ export const scopeSupportFacets = [ "value.return.lambda", "value.field", "value.yield", + "value.switch", "value.resource", "value.resource.iteration", "value.argument.actual", diff --git a/packages/common/src/scopeSupportFacets/talon.ts b/packages/common/src/scopeSupportFacets/talon.ts index f15b9d5f8a..e93d557076 100644 --- a/packages/common/src/scopeSupportFacets/talon.ts +++ b/packages/common/src/scopeSupportFacets/talon.ts @@ -172,7 +172,6 @@ export const talonScopeSupport: LanguageScopeSupportFacetMap = { "section.iteration.parent": notApplicable, startTag: notApplicable, "statement.class": notApplicable, - switchStatementSubject: notApplicable, tags: notApplicable, "textFragment.comment.block": notApplicable, "textFragment.element": notApplicable, @@ -215,6 +214,7 @@ export const talonScopeSupport: LanguageScopeSupportFacetMap = { "value.typeAlias": notApplicable, "value.variable.pattern": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, "string.multiLine": notApplicable, "textFragment.string.multiLine": notApplicable, selector: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/xml.ts b/packages/common/src/scopeSupportFacets/xml.ts index cf20a018bf..239b93c300 100644 --- a/packages/common/src/scopeSupportFacets/xml.ts +++ b/packages/common/src/scopeSupportFacets/xml.ts @@ -161,7 +161,6 @@ export const xmlScopeSupport: LanguageScopeSupportFacetMap = { "statement.iteration.block": notApplicable, "statement.iteration.document": notApplicable, "string.multiLine": notApplicable, - switchStatementSubject: notApplicable, "textFragment.comment.line": notApplicable, "textFragment.string.multiLine": notApplicable, "type.alias": notApplicable, @@ -205,6 +204,7 @@ export const xmlScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": notApplicable, "value.variable.pattern": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, selector: notApplicable, unit: notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/yaml.ts b/packages/common/src/scopeSupportFacets/yaml.ts index d12e609d85..6460bf9fbb 100644 --- a/packages/common/src/scopeSupportFacets/yaml.ts +++ b/packages/common/src/scopeSupportFacets/yaml.ts @@ -168,7 +168,6 @@ export const yamlScopeSupport: LanguageScopeSupportFacetMap = { "statement.class": notApplicable, "statement.iteration.block": notApplicable, "statement.iteration.document": notApplicable, - switchStatementSubject: notApplicable, tags: notApplicable, "textFragment.comment.block": notApplicable, "textFragment.element": notApplicable, @@ -212,6 +211,7 @@ export const yamlScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": notApplicable, "value.variable.pattern": notApplicable, "value.yield": notApplicable, + "value.switch": notApplicable, selector: notApplicable, unit: notApplicable, }; diff --git a/packages/common/src/types/command/PartialTargetDescriptor.types.ts b/packages/common/src/types/command/PartialTargetDescriptor.types.ts index ef59a14e1c..e76184644e 100644 --- a/packages/common/src/types/command/PartialTargetDescriptor.types.ts +++ b/packages/common/src/types/command/PartialTargetDescriptor.types.ts @@ -174,7 +174,6 @@ export const simpleScopeTypeTypes = [ "sectionLevelFive", "sectionLevelSix", "selector", - "private.switchStatementSubject", "unit", "xmlBothTags", "xmlElement", diff --git a/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts b/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts index 5815fc5fc2..b5600bee97 100644 --- a/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts +++ b/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts @@ -145,7 +145,6 @@ function isLanguageSpecific(scopeType: ScopeType): boolean { case "sectionLevelFive": case "sectionLevelSix": case "selector": - case "private.switchStatementSubject": case "unit": case "xmlBothTags": case "xmlElement": diff --git a/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts b/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts index 5cc5e677ee..064117a802 100644 --- a/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts +++ b/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts @@ -107,7 +107,6 @@ export const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = { disqualifyDelimiter: isPrivate("disqualify delimiter"), pairDelimiter: isPrivate("pair delimiter"), ["private.fieldAccess"]: isPrivate("access"), - ["private.switchStatementSubject"]: isPrivate("subject"), }, complexScopeTypeType: { glyph: "glyph", diff --git a/packages/cursorless-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts b/packages/cursorless-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts index 88c846da81..07a15e0ad8 100644 --- a/packages/cursorless-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts +++ b/packages/cursorless-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts @@ -24,7 +24,6 @@ export async function runCustomSpokenFormScopeInfoTest() { lambdaStandard, statementStandard, squareStandard, - subjectStandard, ); await writeFile( @@ -33,7 +32,6 @@ export async function runCustomSpokenFormScopeInfoTest() { ); await assertCalledWithScopeInfo( fake, - subjectCustom, roundCustom, namedFunctionCustom, lambdaCustom, @@ -49,7 +47,6 @@ export async function runCustomSpokenFormScopeInfoTest() { lambdaStandard, statementStandard, squareStandard, - subjectStandard, ); } finally { disposable.dispose(); @@ -75,11 +72,6 @@ const spokenFormJsonContents = { id: "parentheses", spokenForms: ["custom round", "alternate custom round"], }, - { - type: "simpleScopeTypeType", - id: "private.switchStatementSubject", - spokenForms: ["custom subject"], - }, { type: "simpleScopeTypeType", id: "namedFunction", @@ -93,29 +85,6 @@ const spokenFormJsonContents = { ], }; -const subjectStandard: ScopeTypeInfo = { - humanReadableName: "private switch statement subject", - isLanguageSpecific: true, - scopeType: { type: "private.switchStatementSubject" }, - spokenForm: { - isPrivate: true, - reason: - "simple scope type type with id private.switchStatementSubject; this is a private spoken form currently only for internal experimentation", - requiresTalonUpdate: false, - type: "error", - }, -}; - -const subjectCustom: ScopeTypeInfo = { - humanReadableName: "private switch statement subject", - isLanguageSpecific: true, - scopeType: { type: "private.switchStatementSubject" }, - spokenForm: { - spokenForms: ["custom subject"], - type: "success", - }, -}; - const roundStandard: ScopeTypeInfo = { humanReadableName: "Matching pair of parentheses", isLanguageSpecific: false, diff --git a/queries/c.scm b/queries/c.scm index 47956df039..f9ef3d9c2c 100644 --- a/queries/c.scm +++ b/queries/c.scm @@ -355,8 +355,8 @@ ;;! ^^^^ (switch_statement condition: (_ - "(" @private.switchStatementSubject.start.endOf - ")" @private.switchStatementSubject.end.startOf + "(" @value.start.endOf + ")" @value.end.startOf ) body: (_ "{" @branch.iteration.start.endOf @condition.iteration.start.endOf @interior.start.endOf diff --git a/queries/csharp.scm b/queries/csharp.scm index 3c89d4caeb..6e2d8d31f9 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -285,11 +285,11 @@ ] @_.domain (switch_statement - (tuple_expression) @private.switchStatementSubject + (tuple_expression) @value ) @_.domain (switch_statement - value: (_) @private.switchStatementSubject + value: (_) @value ) @_.domain (_ diff --git a/queries/java.scm b/queries/java.scm index e98080cf48..b1c1cee6a0 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -298,8 +298,8 @@ ;;! ^^^^^ ;;! ----------------- (switch_expression - condition: (_) @private.switchStatementSubject - (#child-range! @private.switchStatementSubject 0 -1 true true) + condition: (_) @value + (#child-range! @value 0 -1 true true) ) @_.domain ;;!! true ? 1 : 2 diff --git a/queries/javascript.core.scm b/queries/javascript.core.scm index 40d597a380..6bc7a2c63f 100644 --- a/queries/javascript.core.scm +++ b/queries/javascript.core.scm @@ -611,13 +611,13 @@ ;;! ^^^^^ ;;! ^ (switch_statement - value: (_) @private.switchStatementSubject + value: (_) @value 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 + (#child-range! @value 0 -1 true true) +) @branch.iteration.domain @condition.iteration.domain @value.domain ;;!! case 0: break; ;;! ^^^^^^^^^^^^^^ diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 582be892f3..b604afef0e 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -149,8 +149,8 @@ ) @_.domain (when_expression - (when_subject) @private.switchStatementSubject - (#child-range! @private.switchStatementSubject 0 -1 true true) + (when_subject) @value + (#child-range! @value 0 -1 true true) ) @_.domain ;; diff --git a/queries/python.scm b/queries/python.scm index d346acea4a..7e53b100b1 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -418,7 +418,7 @@ ;;!! match value: ;;! ^^^^^ (match_statement - subject: (_) @private.switchStatementSubject + subject: (_) @value body: (_) @interior ) @_.domain diff --git a/queries/rust.scm b/queries/rust.scm index feb66480a0..989fc7ac02 100644 --- a/queries/rust.scm +++ b/queries/rust.scm @@ -180,7 +180,7 @@ ] @list (match_expression - value: (_) @private.switchStatementSubject + value: (_) @value ) @_.domain ;;!! #[derive(Debug)] diff --git a/queries/scala.scm b/queries/scala.scm index 33048fa4ec..8b95d19af5 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -35,7 +35,7 @@ ) @namedFunction @functionName.domain (match_expression - value: (_) @private.switchStatementSubject + value: (_) @value ) @_.domain (_ From efcfc259f40644897e6b04b6aa047fcc9e87cf7e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 4 Jul 2025 15:46:46 +0200 Subject: [PATCH 2/6] restore order --- .../common/src/scopeSupportFacets/scopeSupportFacets.types.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 74f1fbfc05..6dc33534b5 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -25,8 +25,6 @@ export const scopeSupportFacets = [ "map", "ifStatement", - "regularExpression", - "fieldAccess", "statement", "statement.class", From 4477e9f7189d159b4b3b961df3fb25fb0de5ea6b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 4 Jul 2025 15:52:09 +0200 Subject: [PATCH 3/6] Fix merge issues --- packages/common/src/scopeSupportFacets/java.ts | 11 +---------- packages/common/src/scopeSupportFacets/javascript.ts | 2 -- packages/common/src/scopeSupportFacets/talon.ts | 2 -- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 9e28d03936..6885e7fb42 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -135,7 +135,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.iteration.enum": supported, "name.iteration.block": supported, "name.resource": supported, - + "value.switch": supported, "value.assignment": supported, "value.foreach": supported, "value.field.class": supported, @@ -164,15 +164,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "type.class": supported, "type.enum": supported, "type.interface": supported, - - "value.assignment": supported, - "value.foreach": supported, - "value.field": supported, - "value.return": supported, - "value.return.lambda": supported, - "value.variable": supported, - "value.resource": supported, - "value.switch": supported, "type.iteration.block": supported, "type.iteration.class": supported, "type.iteration.interface": supported, diff --git a/packages/common/src/scopeSupportFacets/javascript.ts b/packages/common/src/scopeSupportFacets/javascript.ts index e52e1011ef..2de099cb1b 100644 --- a/packages/common/src/scopeSupportFacets/javascript.ts +++ b/packages/common/src/scopeSupportFacets/javascript.ts @@ -164,8 +164,6 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { "value.field.class": supported, "value.yield": supported, "value.switch": supported, - - "type.class": supported, "value.iteration.block": supported, "value.iteration.class": supported, "value.iteration.document": supported, diff --git a/packages/common/src/scopeSupportFacets/talon.ts b/packages/common/src/scopeSupportFacets/talon.ts index 9bceb2e68a..1b9abc91ab 100644 --- a/packages/common/src/scopeSupportFacets/talon.ts +++ b/packages/common/src/scopeSupportFacets/talon.ts @@ -224,8 +224,6 @@ export const talonScopeSupport: LanguageScopeSupportFacetMap = { "section.iteration.document": notApplicable, "section.iteration.parent": notApplicable, startTag: notApplicable, - "statement.class": notApplicable, - switchStatementSubject: notApplicable, tags: notApplicable, "textFragment.comment.block": notApplicable, "textFragment.element": notApplicable, From 3fcf46c06237e6fa55e1036a481562eb889bb991 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 4 Jul 2025 15:53:16 +0200 Subject: [PATCH 4/6] restore new line --- packages/common/src/scopeSupportFacets/java.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 6885e7fb42..13245b3f23 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -135,9 +135,10 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.iteration.enum": supported, "name.iteration.block": supported, "name.resource": supported, - "value.switch": supported, + "value.assignment": supported, "value.foreach": supported, + "value.switch": supported, "value.field.class": supported, "value.return": supported, "value.return.lambda": supported, From e637c7f90f0a9bf983e4c7179e1392baea4f3483 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 4 Jul 2025 15:56:23 +0200 Subject: [PATCH 5/6] Updates scopeSupportFacetInfos.md --- data/scopeSupportFacetInfos.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/data/scopeSupportFacetInfos.md b/data/scopeSupportFacetInfos.md index 11c7a0097b..eadd7c4c85 100644 --- a/data/scopeSupportFacetInfos.md +++ b/data/scopeSupportFacetInfos.md @@ -323,10 +323,6 @@ - `surroundingPair` A delimiter pair, such as parentheses or quotes - `surroundingPair.iteration` The iteration scope for delimiter pairs -### private.switchStatementSubject - -- `switchStatementSubject` The subject of a switch statement - ### xmlBothTags - `tags` Both tags in a xml element @@ -405,6 +401,7 @@ - `value.resource.iteration` Iteration scope for values in a 'with' / 'use' / 'using' statement: the resource list. The domain should be the entire statement. - `value.return` Return value of a function - `value.return.lambda` Implicit return value from a lambda +- `value.switch` The value / subject of a switch statement - `value.typeAlias` Value of a type alias declaration - `value.variable` Value (RHS) of a variable declaration - `value.variable.pattern` Value (RHS) of a variable declaration with pattern destructuring From 88b316c70ea74a1d5772cd7c64860d0312dcdedb Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 5 Jul 2025 17:34:46 +0200 Subject: [PATCH 6/6] Update fixture --- .../scopes/java/value/value.yield.scope | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/data/fixtures/scopes/java/value/value.yield.scope b/data/fixtures/scopes/java/value/value.yield.scope index 3452293027..a25b643c0b 100644 --- a/data/fixtures/scopes/java/value/value.yield.scope +++ b/data/fixtures/scopes/java/value/value.yield.scope @@ -6,39 +6,57 @@ switch (value) { } --- -[#1 Content] = 2:14-2:19 +[#1 Content] = +[#1 Removal] = 0:8-0:13 + >-----< +0| switch (value) { + +[#1 Domain] = 0:0-5:1 + >---------------- +0| switch (value) { +1| case 1: +2| yield "foo"; +3| default: +4| yield "bar"; +5| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:14-2:19 >-----< 2| yield "foo"; -[#1 Removal] = 2:13-2:19 +[#2 Removal] = 2:13-2:19 >------< 2| yield "foo"; -[#1 Leading delimiter] = 2:13-2:14 +[#2 Leading delimiter] = 2:13-2:14 >-< 2| yield "foo"; -[#1 Domain] = 2:8-2:20 +[#2 Domain] = 2:8-2:20 >------------< 2| yield "foo"; -[#1 Insertion delimiter] = " " +[#2 Insertion delimiter] = " " -[#2 Content] = 4:14-4:19 +[#3 Content] = 4:14-4:19 >-----< 4| yield "bar"; -[#2 Removal] = 4:13-4:19 +[#3 Removal] = 4:13-4:19 >------< 4| yield "bar"; -[#2 Leading delimiter] = 4:13-4:14 +[#3 Leading delimiter] = 4:13-4:14 >-< 4| yield "bar"; -[#2 Domain] = 4:8-4:20 +[#3 Domain] = 4:8-4:20 >------------< 4| yield "bar"; -[#2 Insertion delimiter] = " " +[#3 Insertion delimiter] = " "