diff --git a/packages/common/src/scopeSupportFacets/html.ts b/packages/common/src/scopeSupportFacets/html.ts index f0d718c8d9..d04b150943 100644 --- a/packages/common/src/scopeSupportFacets/html.ts +++ b/packages/common/src/scopeSupportFacets/html.ts @@ -43,7 +43,7 @@ export const htmlScopeSupport: LanguageScopeSupportFacetMap = { "namedFunction.method": notApplicable, "string.multiLine": notApplicable, "string.singleLine": notApplicable, - "type.assignment": notApplicable, + "type.variable": notApplicable, "type.field": notApplicable, "type.foreach": notApplicable, "type.formalParameter": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/javascript.ts b/packages/common/src/scopeSupportFacets/javascript.ts index c13329896f..9908bd85fa 100644 --- a/packages/common/src/scopeSupportFacets/javascript.ts +++ b/packages/common/src/scopeSupportFacets/javascript.ts @@ -60,6 +60,8 @@ export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { "name.foreach": supported, "name.assignment": supported, "name.assignment.pattern": supported, + "name.variable": supported, + "name.variable.pattern": supported, "name.function": supported, "name.class": supported, "name.field": supported, @@ -70,6 +72,7 @@ export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { "value.mapPair": supported, "value.mapPair.iteration": supported, "value.assignment": supported, + "value.variable": supported, "value.foreach": supported, "value.return": supported, "value.return.lambda": supported, @@ -83,7 +86,7 @@ export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { "key.attribute": supported, "value.attribute": supported, - "type.assignment": notApplicable, + "type.variable": notApplicable, "type.formalParameter": notApplicable, "type.return": notApplicable, "type.field": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index e5781be5a6..2659f64df2 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -223,6 +223,15 @@ export const scopeSupportFacetInfos: Record< description: "LHS of an assignment with pattern destructuring", scopeType: "name", }, + "name.variable": { + description: "Name (LHS) of a variable declaration", + scopeType: "name", + }, + "name.variable.pattern": { + description: + "Name (LHS) of a variable declaration with pattern destructuring", + scopeType: "name", + }, "name.foreach": { description: "Iteration variable name in a for each loop", scopeType: "name", @@ -269,6 +278,10 @@ export const scopeSupportFacetInfos: Record< description: "Value (RHS) of an assignment", scopeType: "value", }, + "value.variable": { + description: "Value (RHS) of a variable declaration", + scopeType: "value", + }, "value.mapPair": { description: "Value (RHS) of a key-value pair in a map", scopeType: "value", @@ -314,8 +327,8 @@ export const scopeSupportFacetInfos: Record< isIteration: true, }, - "type.assignment": { - description: "Type of variable in an assignment", + "type.variable": { + description: "Type of variable in a variable declaration", scopeType: "type", }, "type.formalParameter": { diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index cde875d921..7c9b75e85e 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -59,6 +59,8 @@ const scopeSupportFacets = [ "name.assignment", "name.assignment.pattern", + "name.variable", + "name.variable.pattern", "name.foreach", "name.function", "name.class", @@ -71,6 +73,7 @@ const scopeSupportFacets = [ "key.mapPair.iteration", "value.assignment", + "value.variable", "value.mapPair", "value.mapPair.iteration", "value.attribute", @@ -82,7 +85,7 @@ const scopeSupportFacets = [ "value.resource", "value.resource.iteration", - "type.assignment", + "type.variable", "type.formalParameter", "type.return", "type.field", diff --git a/packages/common/src/scopeSupportFacets/typescript.ts b/packages/common/src/scopeSupportFacets/typescript.ts index 80a715dc1f..a9c5d4c240 100644 --- a/packages/common/src/scopeSupportFacets/typescript.ts +++ b/packages/common/src/scopeSupportFacets/typescript.ts @@ -8,7 +8,7 @@ import { const { supported } = ScopeSupportFacetLevel; export const typescriptScopeSupport: LanguageScopeSupportFacetMap = { - "type.assignment": supported, + "type.variable": supported, "type.formalParameter": supported, "type.return": supported, "type.field": supported, diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.pattern.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.pattern.scope index c075b0ed1d..1e26816f41 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.pattern.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.pattern.scope @@ -1,24 +1,20 @@ -const { aaa: bbb } = ccc; +{ aaa: bbb } = ccc; --- -[Content] = 0:6-0:18 -0| const { aaa: bbb } = ccc; - >------------< +[Content] = 0:0-0:12 +0| { aaa: bbb } = ccc; + >------------< -[Removal] = 0:0-0:21 -0| const { aaa: bbb } = ccc; - >---------------------< +[Removal] = 0:0-0:15 +0| { aaa: bbb } = ccc; + >---------------< -[Leading delimiter] = 0:5-0:6 -0| const { aaa: bbb } = ccc; - >-< +[Trailing delimiter] = 0:12-0:15 +0| { aaa: bbb } = ccc; + >---< -[Trailing delimiter] = 0:18-0:19 -0| const { aaa: bbb } = ccc; - >-< - -[Domain] = 0:0-0:25 -0| const { aaa: bbb } = ccc; - >-------------------------< +[Domain] = 0:0-0:19 +0| { aaa: bbb } = ccc; + >-------------------< [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.scope index 5923a0157a..0631628fcb 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.assignment.scope @@ -1,24 +1,20 @@ -const name = "Hello world"; +aaa = bbb; --- -[Content] = 0:6-0:10 -0| const name = "Hello world"; - >----< +[Content] = 0:0-0:3 +0| aaa = bbb; + >---< -[Removal] = 0:0-0:13 -0| const name = "Hello world"; - >-------------< +[Removal] = 0:0-0:6 +0| aaa = bbb; + >------< -[Leading delimiter] = 0:5-0:6 -0| const name = "Hello world"; - >-< +[Trailing delimiter] = 0:3-0:6 +0| aaa = bbb; + >---< -[Trailing delimiter] = 0:10-0:11 -0| const name = "Hello world"; - >-< - -[Domain] = 0:0-0:27 -0| const name = "Hello world"; - >---------------------------< +[Domain] = 0:0-0:10 +0| aaa = bbb; + >----------< [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.variable.pattern.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.variable.pattern.scope new file mode 100644 index 0000000000..4bbf83df80 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.variable.pattern.scope @@ -0,0 +1,24 @@ +const {aaa: bbb} = ccc; +--- + +[Content] = 0:6-0:16 +0| const {aaa: bbb} = ccc; + >----------< + +[Removal] = 0:0-0:19 +0| const {aaa: bbb} = ccc; + >-------------------< + +[Leading delimiter] = 0:5-0:6 +0| const {aaa: bbb} = ccc; + >-< + +[Trailing delimiter] = 0:16-0:17 +0| const {aaa: bbb} = ccc; + >-< + +[Domain] = 0:0-0:23 +0| const {aaa: bbb} = ccc; + >-----------------------< + +[Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.variable.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.variable.scope new file mode 100644 index 0000000000..5923a0157a --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.variable.scope @@ -0,0 +1,24 @@ +const name = "Hello world"; +--- + +[Content] = 0:6-0:10 +0| const name = "Hello world"; + >----< + +[Removal] = 0:0-0:13 +0| const name = "Hello world"; + >-------------< + +[Leading delimiter] = 0:5-0:6 +0| const name = "Hello world"; + >-< + +[Trailing delimiter] = 0:10-0:11 +0| const name = "Hello world"; + >-< + +[Domain] = 0:0-0:27 +0| const name = "Hello world"; + >---------------------------< + +[Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.assignment.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.assignment.scope index caa452d3f8..5147ce1719 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.assignment.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.assignment.scope @@ -1,20 +1,20 @@ -const name = "Hello world"; +aaa = bbb; --- -[Content] = 0:13-0:26 -0| const name = "Hello world"; - >-------------< +[Content] = 0:6-0:9 +0| aaa = bbb; + >---< -[Removal] = 0:10-0:26 -0| const name = "Hello world"; - >----------------< +[Removal] = 0:3-0:9 +0| aaa = bbb; + >------< -[Leading delimiter] = 0:10-0:13 -0| const name = "Hello world"; - >---< +[Leading delimiter] = 0:3-0:6 +0| aaa = bbb; + >---< -[Domain] = 0:0-0:27 -0| const name = "Hello world"; - >---------------------------< +[Domain] = 0:0-0:10 +0| aaa = bbb; + >----------< [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.variable.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.variable.scope new file mode 100644 index 0000000000..caa452d3f8 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.variable.scope @@ -0,0 +1,20 @@ +const name = "Hello world"; +--- + +[Content] = 0:13-0:26 +0| const name = "Hello world"; + >-------------< + +[Removal] = 0:10-0:26 +0| const name = "Hello world"; + >----------------< + +[Leading delimiter] = 0:10-0:13 +0| const name = "Hello world"; + >---< + +[Domain] = 0:0-0:27 +0| const name = "Hello world"; + >---------------------------< + +[Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.assignment.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.variable.scope similarity index 100% rename from packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.assignment.scope rename to packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.variable.scope