From 62b0f85b3f468ae6b189ff0cdc2312533aa15b6b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 24 Apr 2025 11:50:57 +0200 Subject: [PATCH 01/12] Added argument list scope --- cursorless-talon/src/spoken_forms.json | 1 + .../scopeSupportFacets.types.ts | 2 ++ .../command/PartialTargetDescriptor.types.ts | 1 + .../queryPredicateOperators.ts | 34 +++++++++++++++++++ .../src/scopeProviders/ScopeInfoProvider.ts | 1 + .../spokenForms/defaultSpokenFormMapCore.ts | 1 + queries/javascript.core.scm | 10 ++++++ 7 files changed, 50 insertions(+) diff --git a/cursorless-talon/src/spoken_forms.json b/cursorless-talon/src/spoken_forms.json index 22d30775dc..cde8bcef99 100644 --- a/cursorless-talon/src/spoken_forms.json +++ b/cursorless-talon/src/spoken_forms.json @@ -125,6 +125,7 @@ "modifier_scope_types.csv": { "scope_type": { "arg": "argumentOrParameter", + "arg list": "argumentList", "attribute": "attribute", "call": "functionCall", "callee": "functionCallee", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 3941b09149..586648348a 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -70,6 +70,8 @@ export const scopeSupportFacets = [ "argument.formal.constructor", "argument.formal.constructor.iteration", + "argumentList.formal", + "comment.line", "comment.block", diff --git a/packages/common/src/types/command/PartialTargetDescriptor.types.ts b/packages/common/src/types/command/PartialTargetDescriptor.types.ts index 8ee0a2ed3c..ef59a14e1c 100644 --- a/packages/common/src/types/command/PartialTargetDescriptor.types.ts +++ b/packages/common/src/types/command/PartialTargetDescriptor.types.ts @@ -141,6 +141,7 @@ export type SurroundingPairName = export const simpleScopeTypeTypes = [ "argumentOrParameter", + "argumentList", "anonymousFunction", "attribute", "branch", diff --git a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts index bf80bb9be2..59b18084aa 100644 --- a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts +++ b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts @@ -318,6 +318,39 @@ class SingleOrMultilineDelimiter extends QueryPredicateOperator { + name = "has-children-or-not-delimiter!" as const; + schema = z.tuple([q.node, q.node, q.string, q.string]); + + run( + nodeInfo: MutableQueryCapture, + conditionNodeInfo: MutableQueryCapture, + insertionDelimiterConsequence: string, + insertionDelimiterAlternative: string, + ) { + nodeInfo.insertionDelimiter = conditionNodeInfo.node.children.some( + (child) => child.isNamed, + ) + ? insertionDelimiterConsequence + : insertionDelimiterAlternative; + + return true; + } +} + export const queryPredicateOperators = [ new Log(), new NotType(), @@ -331,5 +364,6 @@ export const queryPredicateOperators = [ new AllowMultiple(), new InsertionDelimiter(), new SingleOrMultilineDelimiter(), + new HasChildrenOrNotDelimiter(), new HasMultipleChildrenOfType(), ]; diff --git a/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts b/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts index 4ca19be2c2..5815fc5fc2 100644 --- a/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts +++ b/packages/cursorless-engine/src/scopeProviders/ScopeInfoProvider.ts @@ -111,6 +111,7 @@ function isLanguageSpecific(scopeType: ScopeType): boolean { switch (scopeType.type) { case "string": case "argumentOrParameter": + case "argumentList": case "anonymousFunction": case "attribute": case "branch": diff --git a/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts b/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts index a790304c57..5cc5e677ee 100644 --- a/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts +++ b/packages/cursorless-engine/src/spokenForms/defaultSpokenFormMapCore.ts @@ -40,6 +40,7 @@ export const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = { simpleScopeTypeType: { argumentOrParameter: "arg", + argumentList: "arg list", attribute: "attribute", functionCall: "call", functionCallee: "callee", diff --git a/queries/javascript.core.scm b/queries/javascript.core.scm index d4ce227e94..2a120acda4 100644 --- a/queries/javascript.core.scm +++ b/queries/javascript.core.scm @@ -748,6 +748,16 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) +;;!! foo(name) {} +;;! ^^^^ +(_ + (formal_parameters + "(" @argumentList.start.endOf + ")" @argumentList.end.startOf + ) @_dummy + (#has-children-or-not-delimiter! @argumentList.start.endOf @_dummy ", " "") +) @argumentList.domain + ;;!! foo("bar") ;;! ^^^^^ ( From 2a2fc06ec8ec6e4be7f7a86ef59deb0bc0b674c3 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 24 Apr 2025 11:53:27 +0200 Subject: [PATCH 02/12] Added facets --- .../scopeSupportFacets/scopeSupportFacetInfos.ts | 13 +++++++++++++ .../scopeSupportFacets/scopeSupportFacets.types.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 59eef32b94..5d96fc0887 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -272,6 +272,19 @@ export const scopeSupportFacetInfos: Record< isIteration: true, }, + "argumentList.formal": { + description: "A list of arguments in a function declaration", + scopeType: "argumentList", + }, + "argumentList.formal.method": { + description: "A list of arguments in a class method declaration", + scopeType: "argumentList", + }, + "argumentList.formal.constructor": { + description: "A list of arguments in a constructor declaration", + scopeType: "argumentList", + }, + "comment.line": { description: "A line comment", scopeType: "comment", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 586648348a..dd1fa0c2e3 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -71,6 +71,8 @@ export const scopeSupportFacets = [ "argument.formal.constructor.iteration", "argumentList.formal", + "argumentList.formal.method", + "argumentList.formal.constructor", "comment.line", "comment.block", From e0df39fc55b57cf470a05a511b8db6d9000a4840 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 24 Apr 2025 11:54:57 +0200 Subject: [PATCH 03/12] Added more facets --- .../common/src/scopeSupportFacets/scopeSupportFacets.types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index dd1fa0c2e3..b1847c6ff6 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -69,10 +69,13 @@ export const scopeSupportFacets = [ "argument.formal.method.iteration", "argument.formal.constructor", "argument.formal.constructor.iteration", + "argument.formal.lambda", + "argument.formal.lambda.iteration", "argumentList.formal", "argumentList.formal.method", "argumentList.formal.constructor", + "argumentList.formal.lambda", "comment.line", "comment.block", From 6c7c39c14899fdf15ea1c5e158bc43d4dd041b23 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 24 Apr 2025 11:58:57 +0200 Subject: [PATCH 04/12] Added facet infos --- .../scopeSupportFacets/scopeSupportFacetInfos.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 5d96fc0887..7273eda762 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -271,6 +271,16 @@ export const scopeSupportFacetInfos: Record< scopeType: "argumentOrParameter", isIteration: true, }, + "argument.formal.lambda": { + description: "A parameter in a lambda declaration", + scopeType: "argumentOrParameter", + }, + "argument.formal.lambda.iteration": { + description: + "Iteration scope of the formal parameters of a lambda declaration; should be the whole parameter list. The domain should be the entire function.", + scopeType: "argumentOrParameter", + isIteration: true, + }, "argumentList.formal": { description: "A list of arguments in a function declaration", @@ -284,6 +294,10 @@ export const scopeSupportFacetInfos: Record< description: "A list of arguments in a constructor declaration", scopeType: "argumentList", }, + "argumentList.formal.lambda": { + description: "A list of arguments in a lambda declaration", + scopeType: "argumentList", + }, "comment.line": { description: "A line comment", From 7ac4d62e009be0d4fd945b82529f6be02fed9a98 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 09:03:52 +0200 Subject: [PATCH 05/12] Add facets to javascript --- .../argument.formal.lambda.iteration.scope | 10 ++++++ .../argument.formal.lambda.iteration2.scope | 10 ++++++ .../argument.formal.lambda.scope | 33 +++++++++++++++++++ .../argument.formal.lambda2.scope | 33 +++++++++++++++++++ .../argumentList.formal.constructor.scope | 15 +++++++++ .../argumentList.formal.constructor2.scope | 15 +++++++++ .../argumentList.formal.lambda.scope | 13 ++++++++ .../argumentList.formal.lambda2.scope | 13 ++++++++ .../argumentList.formal.lambda3.scope | 13 ++++++++ .../argumentList.formal.lambda4.scope | 13 ++++++++ .../argumentList.formal.method.scope | 15 +++++++++ .../argumentList.formal.method2.scope | 15 +++++++++ .../javascript.core/argumentList.formal.scope | 13 ++++++++ .../argumentList.formal2.scope | 13 ++++++++ .../src/scopeSupportFacets/javascript.ts | 7 ++++ 15 files changed, 231 insertions(+) create mode 100644 data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration2.scope create mode 100644 data/fixtures/scopes/javascript.core/argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/javascript.core/argument.formal.lambda2.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.constructor.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.lambda.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.method.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal2.scope diff --git a/data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..7561b7c28a --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration.scope @@ -0,0 +1,10 @@ +(aaa, bbb) => { } +--- + +[Range] = 0:1-0:9 + >--------< +0| (aaa, bbb) => { } + +[Domain] = 0:0-0:17 + >-----------------< +0| (aaa, bbb) => { } diff --git a/data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration2.scope b/data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration2.scope new file mode 100644 index 0000000000..1151d0840b --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argument.formal.lambda.iteration2.scope @@ -0,0 +1,10 @@ +function (aaa, bbb) { } +--- + +[Range] = 0:10-0:18 + >--------< +0| function (aaa, bbb) { } + +[Domain] = 0:0-0:23 + >-----------------------< +0| function (aaa, bbb) { } diff --git a/data/fixtures/scopes/javascript.core/argument.formal.lambda.scope b/data/fixtures/scopes/javascript.core/argument.formal.lambda.scope new file mode 100644 index 0000000000..b6b49f57b3 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argument.formal.lambda.scope @@ -0,0 +1,33 @@ +(aaa, bbb) => { } +--- + +[#1 Content] = +[#1 Domain] = 0:1-0:4 + >---< +0| (aaa, bbb) => { } + +[#1 Removal] = 0:1-0:6 + >-----< +0| (aaa, bbb) => { } + +[#1 Trailing delimiter] = 0:4-0:6 + >--< +0| (aaa, bbb) => { } + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:6-0:9 + >---< +0| (aaa, bbb) => { } + +[#2 Removal] = 0:4-0:9 + >-----< +0| (aaa, bbb) => { } + +[#2 Leading delimiter] = 0:4-0:6 + >--< +0| (aaa, bbb) => { } + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argument.formal.lambda2.scope b/data/fixtures/scopes/javascript.core/argument.formal.lambda2.scope new file mode 100644 index 0000000000..1fdc4be718 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argument.formal.lambda2.scope @@ -0,0 +1,33 @@ +function (aaa, bbb) { } +--- + +[#1 Content] = +[#1 Domain] = 0:10-0:13 + >---< +0| function (aaa, bbb) { } + +[#1 Removal] = 0:10-0:15 + >-----< +0| function (aaa, bbb) { } + +[#1 Trailing delimiter] = 0:13-0:15 + >--< +0| function (aaa, bbb) { } + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:15-0:18 + >---< +0| function (aaa, bbb) { } + +[#2 Removal] = 0:13-0:18 + >-----< +0| function (aaa, bbb) { } + +[#2 Leading delimiter] = 0:13-0:15 + >--< +0| function (aaa, bbb) { } + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.constructor.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor.scope new file mode 100644 index 0000000000..13a0cbdedd --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor.scope @@ -0,0 +1,15 @@ +class MyClass { + constructor(aaa, bbb) { } +} +--- + +[Content] = +[Removal] = 1:14-1:22 + >--------< +1| constructor(aaa, bbb) { } + +[Domain] = 1:2-1:27 + >-------------------------< +1| constructor(aaa, bbb) { } + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope new file mode 100644 index 0000000000..6ad780ad8d --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope @@ -0,0 +1,15 @@ +class MyClass { + constructor() { } +} +--- + +[Content] = +[Removal] = 1:14-1:14 + >< +1| constructor() { } + +[Domain] = 1:2-1:19 + >-----------------< +1| constructor() { } + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda.scope new file mode 100644 index 0000000000..30b60eaf01 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda.scope @@ -0,0 +1,13 @@ +(aaa, bbb) => { } +--- + +[Content] = +[Removal] = 0:1-0:9 + >--------< +0| (aaa, bbb) => { } + +[Domain] = 0:0-0:17 + >-----------------< +0| (aaa, bbb) => { } + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope new file mode 100644 index 0000000000..7783f73527 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope @@ -0,0 +1,13 @@ +() => { } +--- + +[Content] = +[Removal] = 0:1-0:1 + >< +0| () => { } + +[Domain] = 0:0-0:9 + >---------< +0| () => { } + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope new file mode 100644 index 0000000000..99b36bc73f --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope @@ -0,0 +1,13 @@ +function (aaa, bbb) { } +--- + +[Content] = +[Removal] = 0:10-0:18 + >--------< +0| function (aaa, bbb) { } + +[Domain] = 0:0-0:23 + >-----------------------< +0| function (aaa, bbb) { } + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope new file mode 100644 index 0000000000..49ae698c96 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope @@ -0,0 +1,13 @@ +function () { } +--- + +[Content] = +[Removal] = 0:10-0:10 + >< +0| function () { } + +[Domain] = 0:0-0:15 + >---------------< +0| function () { } + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.method.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.method.scope new file mode 100644 index 0000000000..aeadb987a3 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.method.scope @@ -0,0 +1,15 @@ +class MyClass { + myFunk(aaa, bbb) { } +} +--- + +[Content] = +[Removal] = 1:9-1:17 + >--------< +1| myFunk(aaa, bbb) { } + +[Domain] = 1:2-1:22 + >--------------------< +1| myFunk(aaa, bbb) { } + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope new file mode 100644 index 0000000000..60d13ae256 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope @@ -0,0 +1,15 @@ +class MyClass { + myFunk() { } +} +--- + +[Content] = +[Removal] = 1:9-1:9 + >< +1| myFunk() { } + +[Domain] = 1:2-1:14 + >------------< +1| myFunk() { } + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.scope new file mode 100644 index 0000000000..d86990597e --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.scope @@ -0,0 +1,13 @@ +function myFunk(aaa, bbb) { } +--- + +[Content] = +[Removal] = 0:16-0:24 + >--------< +0| function myFunk(aaa, bbb) { } + +[Domain] = 0:0-0:29 + >-----------------------------< +0| function myFunk(aaa, bbb) { } + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal2.scope new file mode 100644 index 0000000000..a98608fdc3 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal2.scope @@ -0,0 +1,13 @@ +function myFunk() { } +--- + +[Content] = +[Removal] = 0:16-0:16 + >< +0| function myFunk() { } + +[Domain] = 0:0-0:21 + >---------------------< +0| function myFunk() { } + +[Insertion delimiter] = "" diff --git a/packages/common/src/scopeSupportFacets/javascript.ts b/packages/common/src/scopeSupportFacets/javascript.ts index 5bce8eed13..d6a6bfe9d1 100644 --- a/packages/common/src/scopeSupportFacets/javascript.ts +++ b/packages/common/src/scopeSupportFacets/javascript.ts @@ -61,6 +61,13 @@ export const javascriptCoreScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.method.iteration": supported, "argument.formal.constructor": supported, "argument.formal.constructor.iteration": supported, + "argument.formal.lambda": supported, + "argument.formal.lambda.iteration": supported, + + "argumentList.formal": supported, + "argumentList.formal.method": supported, + "argumentList.formal.constructor": supported, + "argumentList.formal.lambda": supported, "comment.line": supported, "comment.block": supported, From eba47a52b1f2bc1ce0a5c84037d8f6653f4428b8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 09:58:27 +0200 Subject: [PATCH 06/12] More facets --- .../java/argument.formal.constructor2.scope | 46 +++++++++++++++ .../java/argument.formal.iteration.scope | 12 ---- .../java/argument.formal.iteration2.scope | 12 ---- .../argument.formal.lambda.iteration.scope | 10 ++++ .../scopes/java/argument.formal.lambda.scope | 33 +++++++++++ .../scopes/java/argument.formal.lambda2.scope | 44 ++++++++++++++ .../scopes/java/argument.formal.method2.scope | 46 +++++++++++++++ .../scopes/java/argument.formal.scope | 35 ----------- .../scopes/java/argument.formal2.scope | 46 --------------- .../scopes/java/argument.formal3.scope | 35 ----------- .../argumentList.formal.constructor.scope | 15 +++++ .../argumentList.formal.constructor2.scope | 26 ++++++++ .../argumentList.formal.constructor3.scope | 15 +++++ .../java/argumentList.formal.lambda.scope | 13 ++++ .../java/argumentList.formal.lambda2.scope | 24 ++++++++ .../java/argumentList.formal.lambda3.scope | 13 ++++ .../java/argumentList.formal.method.scope | 15 +++++ .../java/argumentList.formal.method2.scope | 26 ++++++++ .../java/argumentList.formal.method3.scope | 15 +++++ .../argument.formal.lambda.scope | 59 +++++++++++-------- .../argument.formal.lambda3.scope | 33 +++++++++++ .../argumentList.formal.constructor2.scope | 27 ++++++--- .../argumentList.formal.constructor3.scope | 15 +++++ .../argumentList.formal.lambda2.scope | 27 ++++++--- .../argumentList.formal.lambda3.scope | 16 ++--- .../argumentList.formal.lambda4.scope | 16 ++--- .../argumentList.formal.lambda5.scope | 24 ++++++++ .../argumentList.formal.lambda6.scope | 13 ++++ .../argumentList.formal.method2.scope | 27 ++++++--- .../argumentList.formal.method3.scope | 15 +++++ .../argumentList.formal2.scope | 27 ++++++--- .../argumentList.formal3.scope | 13 ++++ .../common/src/scopeSupportFacets/java.ts | 13 +++- .../queryPredicateOperators.ts | 43 ++++++++------ queries/java.scm | 15 ++--- queries/javascript.core.scm | 19 ++---- 36 files changed, 630 insertions(+), 253 deletions(-) create mode 100644 data/fixtures/scopes/java/argument.formal.constructor2.scope delete mode 100644 data/fixtures/scopes/java/argument.formal.iteration.scope delete mode 100644 data/fixtures/scopes/java/argument.formal.iteration2.scope create mode 100644 data/fixtures/scopes/java/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/java/argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/java/argument.formal.lambda2.scope create mode 100644 data/fixtures/scopes/java/argument.formal.method2.scope delete mode 100644 data/fixtures/scopes/java/argument.formal.scope delete mode 100644 data/fixtures/scopes/java/argument.formal2.scope delete mode 100644 data/fixtures/scopes/java/argument.formal3.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.constructor.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.constructor2.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.constructor3.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.lambda.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.lambda2.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.lambda3.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.method.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.method2.scope create mode 100644 data/fixtures/scopes/java/argumentList.formal.method3.scope create mode 100644 data/fixtures/scopes/javascript.core/argument.formal.lambda3.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.constructor3.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.lambda5.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.lambda6.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal.method3.scope create mode 100644 data/fixtures/scopes/javascript.core/argumentList.formal3.scope diff --git a/data/fixtures/scopes/java/argument.formal.constructor2.scope b/data/fixtures/scopes/java/argument.formal.constructor2.scope new file mode 100644 index 0000000000..274cf2d097 --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.constructor2.scope @@ -0,0 +1,46 @@ +public class MyClass { + public MyClass( + String name, + int age + ) {} +} +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:19 + >-----------< +2| String name, + +[#1 Removal] = 2:8-3:8 + >------------ +2| String name, +3| int age + --------< + +[#1 Trailing delimiter] = 2:19-3:8 + >- +2| String name, +3| int age + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:15 + >-------< +3| int age + +[#2 Removal] = 2:19-3:15 + >- +2| String name, +3| int age + ---------------< + +[#2 Leading delimiter] = 2:19-3:8 + >- +2| String name, +3| int age + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/argument.formal.iteration.scope b/data/fixtures/scopes/java/argument.formal.iteration.scope deleted file mode 100644 index 0fb99f6888..0000000000 --- a/data/fixtures/scopes/java/argument.formal.iteration.scope +++ /dev/null @@ -1,12 +0,0 @@ -public class MyClass { - public void myFunk(int value, String name) { } -} ---- - -[Range] = 1:23-1:45 - >----------------------< -1| public void myFunk(int value, String name) { } - -[Domain] = 1:4-1:50 - >----------------------------------------------< -1| public void myFunk(int value, String name) { } diff --git a/data/fixtures/scopes/java/argument.formal.iteration2.scope b/data/fixtures/scopes/java/argument.formal.iteration2.scope deleted file mode 100644 index 86992e9b8c..0000000000 --- a/data/fixtures/scopes/java/argument.formal.iteration2.scope +++ /dev/null @@ -1,12 +0,0 @@ -class MyClass { - MyClass(int value, String name) { } -} ---- - -[Range] = 1:12-1:34 - >----------------------< -1| MyClass(int value, String name) { } - -[Domain] = 1:4-1:39 - >-----------------------------------< -1| MyClass(int value, String name) { } diff --git a/data/fixtures/scopes/java/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/java/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..0459cda209 --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.lambda.iteration.scope @@ -0,0 +1,10 @@ +(aaa, bbb) -> { }; +--- + +[Range] = 0:1-0:9 + >--------< +0| (aaa, bbb) -> { }; + +[Domain] = 0:0-0:17 + >-----------------< +0| (aaa, bbb) -> { }; diff --git a/data/fixtures/scopes/java/argument.formal.lambda.scope b/data/fixtures/scopes/java/argument.formal.lambda.scope new file mode 100644 index 0000000000..01a0159cf9 --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.lambda.scope @@ -0,0 +1,33 @@ +(aaa, bbb) -> { }; +--- + +[#1 Content] = +[#1 Domain] = 0:1-0:4 + >---< +0| (aaa, bbb) -> { }; + +[#1 Removal] = 0:1-0:6 + >-----< +0| (aaa, bbb) -> { }; + +[#1 Trailing delimiter] = 0:4-0:6 + >--< +0| (aaa, bbb) -> { }; + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:6-0:9 + >---< +0| (aaa, bbb) -> { }; + +[#2 Removal] = 0:4-0:9 + >-----< +0| (aaa, bbb) -> { }; + +[#2 Leading delimiter] = 0:4-0:6 + >--< +0| (aaa, bbb) -> { }; + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argument.formal.lambda2.scope b/data/fixtures/scopes/java/argument.formal.lambda2.scope new file mode 100644 index 0000000000..4057c29da4 --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.lambda2.scope @@ -0,0 +1,44 @@ +( + aaa, + bbb +) -> { }; +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:7 + >---< +1| aaa, + +[#1 Removal] = 1:4-2:4 + >---- +1| aaa, +2| bbb + ----< + +[#1 Trailing delimiter] = 1:7-2:4 + >- +1| aaa, +2| bbb + ----< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:7 + >---< +2| bbb + +[#2 Removal] = 1:7-2:7 + >- +1| aaa, +2| bbb + -------< + +[#2 Leading delimiter] = 1:7-2:4 + >- +1| aaa, +2| bbb + ----< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/argument.formal.method2.scope b/data/fixtures/scopes/java/argument.formal.method2.scope new file mode 100644 index 0000000000..9251481a17 --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.method2.scope @@ -0,0 +1,46 @@ +public class MyClass { + public void foo( + String name, + int age + ) {} +} +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:19 + >-----------< +2| String name, + +[#1 Removal] = 2:8-3:8 + >------------ +2| String name, +3| int age + --------< + +[#1 Trailing delimiter] = 2:19-3:8 + >- +2| String name, +3| int age + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:15 + >-------< +3| int age + +[#2 Removal] = 2:19-3:15 + >- +2| String name, +3| int age + ---------------< + +[#2 Leading delimiter] = 2:19-3:8 + >- +2| String name, +3| int age + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/argument.formal.scope b/data/fixtures/scopes/java/argument.formal.scope deleted file mode 100644 index 4c05d7734f..0000000000 --- a/data/fixtures/scopes/java/argument.formal.scope +++ /dev/null @@ -1,35 +0,0 @@ -public class MyClass { - public void myFunk(int value, String name) { } -} ---- - -[#1 Content] = -[#1 Domain] = 1:23-1:32 - >---------< -1| public void myFunk(int value, String name) { } - -[#1 Removal] = 1:23-1:34 - >-----------< -1| public void myFunk(int value, String name) { } - -[#1 Trailing delimiter] = 1:32-1:34 - >--< -1| public void myFunk(int value, String name) { } - -[#1 Insertion delimiter] = ", " - - -[#2 Content] = -[#2 Domain] = 1:34-1:45 - >-----------< -1| public void myFunk(int value, String name) { } - -[#2 Removal] = 1:32-1:45 - >-------------< -1| public void myFunk(int value, String name) { } - -[#2 Leading delimiter] = 1:32-1:34 - >--< -1| public void myFunk(int value, String name) { } - -[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argument.formal2.scope b/data/fixtures/scopes/java/argument.formal2.scope deleted file mode 100644 index 1cd135a95e..0000000000 --- a/data/fixtures/scopes/java/argument.formal2.scope +++ /dev/null @@ -1,46 +0,0 @@ -public class MyClass { - public void myFunk( - int value, - String name - ) { } -} ---- - -[#1 Content] = -[#1 Domain] = 2:8-2:17 - >---------< -2| int value, - -[#1 Removal] = 2:8-3:8 - >---------- -2| int value, -3| String name - --------< - -[#1 Trailing delimiter] = 2:17-3:8 - >- -2| int value, -3| String name - --------< - -[#1 Insertion delimiter] = ",\n" - - -[#2 Content] = -[#2 Domain] = 3:8-3:19 - >-----------< -3| String name - -[#2 Removal] = 2:17-3:19 - >- -2| int value, -3| String name - -------------------< - -[#2 Leading delimiter] = 2:17-3:8 - >- -2| int value, -3| String name - --------< - -[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/argument.formal3.scope b/data/fixtures/scopes/java/argument.formal3.scope deleted file mode 100644 index 6a257480ac..0000000000 --- a/data/fixtures/scopes/java/argument.formal3.scope +++ /dev/null @@ -1,35 +0,0 @@ -class MyClass { - MyClass(int value, String name) { } -} ---- - -[#1 Content] = -[#1 Domain] = 1:12-1:21 - >---------< -1| MyClass(int value, String name) { } - -[#1 Removal] = 1:12-1:23 - >-----------< -1| MyClass(int value, String name) { } - -[#1 Trailing delimiter] = 1:21-1:23 - >--< -1| MyClass(int value, String name) { } - -[#1 Insertion delimiter] = ", " - - -[#2 Content] = -[#2 Domain] = 1:23-1:34 - >-----------< -1| MyClass(int value, String name) { } - -[#2 Removal] = 1:21-1:34 - >-------------< -1| MyClass(int value, String name) { } - -[#2 Leading delimiter] = 1:21-1:23 - >--< -1| MyClass(int value, String name) { } - -[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argumentList.formal.constructor.scope b/data/fixtures/scopes/java/argumentList.formal.constructor.scope new file mode 100644 index 0000000000..8ecf6205b1 --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.constructor.scope @@ -0,0 +1,15 @@ +public class MyClass { + public MyClass(String name, int age) {} +} +--- + +[Content] = +[Removal] = 1:19-1:39 + >--------------------< +1| public MyClass(String name, int age) {} + +[Domain] = 1:4-1:43 + >---------------------------------------< +1| public MyClass(String name, int age) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argumentList.formal.constructor2.scope b/data/fixtures/scopes/java/argumentList.formal.constructor2.scope new file mode 100644 index 0000000000..835d5eb47e --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.constructor2.scope @@ -0,0 +1,26 @@ +public class MyClass { + public MyClass( + String name, + int age + ) {} +} +--- + +[Content] = +[Removal] = 1:19-4:4 + > +1| public MyClass( +2| String name, +3| int age +4| ) {} + ----< + +[Domain] = 1:4-4:8 + >--------------- +1| public MyClass( +2| String name, +3| int age +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/argumentList.formal.constructor3.scope b/data/fixtures/scopes/java/argumentList.formal.constructor3.scope new file mode 100644 index 0000000000..e91e8c777d --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.constructor3.scope @@ -0,0 +1,15 @@ +public class MyClass { + public MyClass() {} +} +--- + +[Content] = +[Removal] = 1:19-1:19 + >< +1| public MyClass() {} + +[Domain] = 1:4-1:23 + >-------------------< +1| public MyClass() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/java/argumentList.formal.lambda.scope b/data/fixtures/scopes/java/argumentList.formal.lambda.scope new file mode 100644 index 0000000000..adc12d6cb2 --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.lambda.scope @@ -0,0 +1,13 @@ +(aaa, bbb) -> { }; +--- + +[Content] = +[Removal] = 0:1-0:9 + >--------< +0| (aaa, bbb) -> { }; + +[Domain] = 0:0-0:17 + >-----------------< +0| (aaa, bbb) -> { }; + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argumentList.formal.lambda2.scope b/data/fixtures/scopes/java/argumentList.formal.lambda2.scope new file mode 100644 index 0000000000..e6ecc66df1 --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.lambda2.scope @@ -0,0 +1,24 @@ +( + aaa, + bbb +) -> { }; +--- + +[Content] = +[Removal] = 0:1-3:0 + > +0| ( +1| aaa, +2| bbb +3| ) -> { }; + < + +[Domain] = 0:0-3:8 + >- +0| ( +1| aaa, +2| bbb +3| ) -> { }; + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/argumentList.formal.lambda3.scope b/data/fixtures/scopes/java/argumentList.formal.lambda3.scope new file mode 100644 index 0000000000..b3aee8883e --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.lambda3.scope @@ -0,0 +1,13 @@ +() -> { }; +--- + +[Content] = +[Removal] = 0:1-0:1 + >< +0| () -> { }; + +[Domain] = 0:0-0:9 + >---------< +0| () -> { }; + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/java/argumentList.formal.method.scope b/data/fixtures/scopes/java/argumentList.formal.method.scope new file mode 100644 index 0000000000..4fdc540857 --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.method.scope @@ -0,0 +1,15 @@ +public class MyClass { + public void foo(String name, int age) {} +} +--- + +[Content] = +[Removal] = 1:20-1:40 + >--------------------< +1| public void foo(String name, int age) {} + +[Domain] = 1:4-1:44 + >----------------------------------------< +1| public void foo(String name, int age) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argumentList.formal.method2.scope b/data/fixtures/scopes/java/argumentList.formal.method2.scope new file mode 100644 index 0000000000..5df05519c9 --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.method2.scope @@ -0,0 +1,26 @@ +public class MyClass { + public void foo( + String name, + int age + ) {} +} +--- + +[Content] = +[Removal] = 1:20-4:4 + > +1| public void foo( +2| String name, +3| int age +4| ) {} + ----< + +[Domain] = 1:4-4:8 + >---------------- +1| public void foo( +2| String name, +3| int age +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/argumentList.formal.method3.scope b/data/fixtures/scopes/java/argumentList.formal.method3.scope new file mode 100644 index 0000000000..698e5e2831 --- /dev/null +++ b/data/fixtures/scopes/java/argumentList.formal.method3.scope @@ -0,0 +1,15 @@ +public class MyClass { + public void foo() {} +} +--- + +[Content] = +[Removal] = 1:20-1:20 + >< +1| public void foo() {} + +[Domain] = 1:4-1:24 + >--------------------< +1| public void foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argument.formal.lambda.scope b/data/fixtures/scopes/javascript.core/argument.formal.lambda.scope index b6b49f57b3..114ed3561b 100644 --- a/data/fixtures/scopes/javascript.core/argument.formal.lambda.scope +++ b/data/fixtures/scopes/javascript.core/argument.formal.lambda.scope @@ -1,33 +1,44 @@ -(aaa, bbb) => { } +( + aaa, + bbb +) => { } --- [#1 Content] = -[#1 Domain] = 0:1-0:4 - >---< -0| (aaa, bbb) => { } +[#1 Domain] = 1:2-1:5 + >---< +1| aaa, -[#1 Removal] = 0:1-0:6 - >-----< -0| (aaa, bbb) => { } +[#1 Removal] = 1:2-2:2 + >---- +1| aaa, +2| bbb + --< -[#1 Trailing delimiter] = 0:4-0:6 - >--< -0| (aaa, bbb) => { } +[#1 Trailing delimiter] = 1:5-2:2 + >- +1| aaa, +2| bbb + --< -[#1 Insertion delimiter] = ", " +[#1 Insertion delimiter] = ",\n" [#2 Content] = -[#2 Domain] = 0:6-0:9 - >---< -0| (aaa, bbb) => { } - -[#2 Removal] = 0:4-0:9 - >-----< -0| (aaa, bbb) => { } - -[#2 Leading delimiter] = 0:4-0:6 - >--< -0| (aaa, bbb) => { } - -[#2 Insertion delimiter] = ", " +[#2 Domain] = 2:2-2:5 + >---< +2| bbb + +[#2 Removal] = 1:5-2:5 + >- +1| aaa, +2| bbb + -----< + +[#2 Leading delimiter] = 1:5-2:2 + >- +1| aaa, +2| bbb + --< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/javascript.core/argument.formal.lambda3.scope b/data/fixtures/scopes/javascript.core/argument.formal.lambda3.scope new file mode 100644 index 0000000000..1fdc4be718 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argument.formal.lambda3.scope @@ -0,0 +1,33 @@ +function (aaa, bbb) { } +--- + +[#1 Content] = +[#1 Domain] = 0:10-0:13 + >---< +0| function (aaa, bbb) { } + +[#1 Removal] = 0:10-0:15 + >-----< +0| function (aaa, bbb) { } + +[#1 Trailing delimiter] = 0:13-0:15 + >--< +0| function (aaa, bbb) { } + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:15-0:18 + >---< +0| function (aaa, bbb) { } + +[#2 Removal] = 0:13-0:18 + >-----< +0| function (aaa, bbb) { } + +[#2 Leading delimiter] = 0:13-0:15 + >--< +0| function (aaa, bbb) { } + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope index 6ad780ad8d..3d87ffa5f0 100644 --- a/data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor2.scope @@ -1,15 +1,26 @@ class MyClass { - constructor() { } + constructor( + aaa, + bbb + ) { } } --- [Content] = -[Removal] = 1:14-1:14 - >< -1| constructor() { } +[Removal] = 1:14-4:2 + > +1| constructor( +2| aaa, +3| bbb +4| ) { } + --< -[Domain] = 1:2-1:19 - >-----------------< -1| constructor() { } +[Domain] = 1:2-4:7 + >------------ +1| constructor( +2| aaa, +3| bbb +4| ) { } + -------< -[Insertion delimiter] = "" +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.constructor3.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor3.scope new file mode 100644 index 0000000000..6ad780ad8d --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.constructor3.scope @@ -0,0 +1,15 @@ +class MyClass { + constructor() { } +} +--- + +[Content] = +[Removal] = 1:14-1:14 + >< +1| constructor() { } + +[Domain] = 1:2-1:19 + >-----------------< +1| constructor() { } + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope index 7783f73527..b2fae2bb40 100644 --- a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda2.scope @@ -1,13 +1,24 @@ -() => { } +( + aaa, + bbb +) => { } --- [Content] = -[Removal] = 0:1-0:1 - >< -0| () => { } +[Removal] = 0:1-3:0 + > +0| ( +1| aaa, +2| bbb +3| ) => { } + < -[Domain] = 0:0-0:9 - >---------< -0| () => { } +[Domain] = 0:0-3:8 + >- +0| ( +1| aaa, +2| bbb +3| ) => { } + --------< -[Insertion delimiter] = "" +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope index 99b36bc73f..7783f73527 100644 --- a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda3.scope @@ -1,13 +1,13 @@ -function (aaa, bbb) { } +() => { } --- [Content] = -[Removal] = 0:10-0:18 - >--------< -0| function (aaa, bbb) { } +[Removal] = 0:1-0:1 + >< +0| () => { } -[Domain] = 0:0-0:23 - >-----------------------< -0| function (aaa, bbb) { } +[Domain] = 0:0-0:9 + >---------< +0| () => { } -[Insertion delimiter] = ", " +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope index 49ae698c96..99b36bc73f 100644 --- a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda4.scope @@ -1,13 +1,13 @@ -function () { } +function (aaa, bbb) { } --- [Content] = -[Removal] = 0:10-0:10 - >< -0| function () { } +[Removal] = 0:10-0:18 + >--------< +0| function (aaa, bbb) { } -[Domain] = 0:0-0:15 - >---------------< -0| function () { } +[Domain] = 0:0-0:23 + >-----------------------< +0| function (aaa, bbb) { } -[Insertion delimiter] = "" +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda5.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda5.scope new file mode 100644 index 0000000000..0a389a608a --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda5.scope @@ -0,0 +1,24 @@ +function ( + aaa, + bbb +) { } +--- + +[Content] = +[Removal] = 0:10-3:0 + > +0| function ( +1| aaa, +2| bbb +3| ) { } + < + +[Domain] = 0:0-3:5 + >---------- +0| function ( +1| aaa, +2| bbb +3| ) { } + -----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.lambda6.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda6.scope new file mode 100644 index 0000000000..49ae698c96 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.lambda6.scope @@ -0,0 +1,13 @@ +function () { } +--- + +[Content] = +[Removal] = 0:10-0:10 + >< +0| function () { } + +[Domain] = 0:0-0:15 + >---------------< +0| function () { } + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope index 60d13ae256..79e7255d39 100644 --- a/data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.method2.scope @@ -1,15 +1,26 @@ class MyClass { - myFunk() { } + myFunk( + aaa, + bbb + ) { } } --- [Content] = -[Removal] = 1:9-1:9 - >< -1| myFunk() { } +[Removal] = 1:9-4:2 + > +1| myFunk( +2| aaa, +3| bbb +4| ) { } + --< -[Domain] = 1:2-1:14 - >------------< -1| myFunk() { } +[Domain] = 1:2-4:7 + >------- +1| myFunk( +2| aaa, +3| bbb +4| ) { } + -------< -[Insertion delimiter] = "" +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal.method3.scope b/data/fixtures/scopes/javascript.core/argumentList.formal.method3.scope new file mode 100644 index 0000000000..60d13ae256 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal.method3.scope @@ -0,0 +1,15 @@ +class MyClass { + myFunk() { } +} +--- + +[Content] = +[Removal] = 1:9-1:9 + >< +1| myFunk() { } + +[Domain] = 1:2-1:14 + >------------< +1| myFunk() { } + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal2.scope b/data/fixtures/scopes/javascript.core/argumentList.formal2.scope index a98608fdc3..243c69de07 100644 --- a/data/fixtures/scopes/javascript.core/argumentList.formal2.scope +++ b/data/fixtures/scopes/javascript.core/argumentList.formal2.scope @@ -1,13 +1,24 @@ -function myFunk() { } +function myFunk( + aaa, + bbb +) { } --- [Content] = -[Removal] = 0:16-0:16 - >< -0| function myFunk() { } +[Removal] = 0:16-3:0 + > +0| function myFunk( +1| aaa, +2| bbb +3| ) { } + < -[Domain] = 0:0-0:21 - >---------------------< -0| function myFunk() { } +[Domain] = 0:0-3:5 + >---------------- +0| function myFunk( +1| aaa, +2| bbb +3| ) { } + -----< -[Insertion delimiter] = "" +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/javascript.core/argumentList.formal3.scope b/data/fixtures/scopes/javascript.core/argumentList.formal3.scope new file mode 100644 index 0000000000..a98608fdc3 --- /dev/null +++ b/data/fixtures/scopes/javascript.core/argumentList.formal3.scope @@ -0,0 +1,13 @@ +function myFunk() { } +--- + +[Content] = +[Removal] = 0:16-0:16 + >< +0| function myFunk() { } + +[Domain] = 0:0-0:21 + >---------------------< +0| function myFunk() { } + +[Insertion delimiter] = "" diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 8440f990d1..e444156853 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -15,12 +15,16 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "argument.actual.constructor.iteration": supported, "argument.actual.method": supported, "argument.actual.method.iteration": supported, - "argument.formal": supported, - "argument.formal.iteration": supported, "argument.formal.constructor": supported, "argument.formal.constructor.iteration": supported, "argument.formal.method": supported, "argument.formal.method.iteration": supported, + "argument.formal.lambda": supported, + "argument.formal.lambda.iteration": supported, + + "argumentList.formal.method": supported, + "argumentList.formal.constructor": supported, + "argumentList.formal.lambda": supported, "collectionItem.unenclosed": supported, "collectionItem.unenclosed.iteration": supported, @@ -138,6 +142,11 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { // Not Applicable + "argument.formal": notApplicable, + "argument.formal.iteration": notApplicable, + + "argumentList.formal": notApplicable, + "name.assignment.pattern": notApplicable, "name.argument.actual": notApplicable, "name.argument.actual.iteration": notApplicable, diff --git a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts index 59b18084aa..76312bf048 100644 --- a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts +++ b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts @@ -319,33 +319,40 @@ class SingleOrMultilineDelimiter extends QueryPredicateOperator { - name = "has-children-or-not-delimiter!" as const; - schema = z.tuple([q.node, q.node, q.string, q.string]); +class EmptySingleMultiDelimiter extends QueryPredicateOperator { + name = "empty-single-multi-delimiter!" as const; + schema = z.tuple([q.node, q.node, q.string, q.string, q.string]); run( nodeInfo: MutableQueryCapture, conditionNodeInfo: MutableQueryCapture, - insertionDelimiterConsequence: string, - insertionDelimiterAlternative: string, + insertionDelimiterEmpty: string, + insertionDelimiterSingleLine: string, + insertionDelimiterMultiline: string, ) { - nodeInfo.insertionDelimiter = conditionNodeInfo.node.children.some( + const isEmpty = !conditionNodeInfo.node.children.some( (child) => child.isNamed, - ) - ? insertionDelimiterConsequence - : insertionDelimiterAlternative; + ); + + nodeInfo.insertionDelimiter = (() => { + if (isEmpty) { + return insertionDelimiterEmpty; + } + if (conditionNodeInfo.range.isSingleLine) { + return insertionDelimiterSingleLine; + } + return insertionDelimiterMultiline; + })(); return true; } @@ -364,6 +371,6 @@ export const queryPredicateOperators = [ new AllowMultiple(), new InsertionDelimiter(), new SingleOrMultilineDelimiter(), - new HasChildrenOrNotDelimiter(), + new EmptySingleMultiDelimiter(), new HasMultipleChildrenOfType(), ]; diff --git a/queries/java.scm b/queries/java.scm index 7650d05ee1..18e4b849c4 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -497,8 +497,8 @@ ) ;;!! foo(name: string) {} ;;! ^^^^^^^^^^^^ -( - (formal_parameters +(_ + parameters: (_ (_)? @_.leading.endOf . (_) @argumentOrParameter @@ -524,11 +524,12 @@ ) (_ - (formal_parameters - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf - ) -) @argumentOrParameter.iteration.domain + parameters: (_ + "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf + ) @_dummy + (#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n") +) @argumentList.domain @argumentOrParameter.iteration.domain (argument_list "(" @argumentOrParameter.iteration.start.endOf diff --git a/queries/javascript.core.scm b/queries/javascript.core.scm index 2a120acda4..5e8f312847 100644 --- a/queries/javascript.core.scm +++ b/queries/javascript.core.scm @@ -748,16 +748,6 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) -;;!! foo(name) {} -;;! ^^^^ -(_ - (formal_parameters - "(" @argumentList.start.endOf - ")" @argumentList.end.startOf - ) @_dummy - (#has-children-or-not-delimiter! @argumentList.start.endOf @_dummy ", " "") -) @argumentList.domain - ;;!! foo("bar") ;;! ^^^^^ ( @@ -774,10 +764,11 @@ (_ (formal_parameters - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf - ) -) @argumentOrParameter.iteration.domain + "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf + ) @_dummy + (#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n") +) @argumentList.domain @argumentOrParameter.iteration.domain (arguments "(" @argumentOrParameter.iteration.start.endOf From a7b18f532f2f0d3f7738b43f46f2f15c207fcafd Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 10:39:36 +0200 Subject: [PATCH 07/12] Python --- .../python/argument.formal.constructor2.scope | 73 +++++++++++++++++++ .../argument.formal.lambda.iteration.scope | 10 +++ .../python/argument.formal.lambda.scope | 33 +++++++++ .../python/argument.formal.method2.scope | 46 ++++++++++++ .../argumentList.formal.constructor.scope | 17 +++++ .../argumentList.formal.constructor2.scope | 30 ++++++++ .../argumentList.formal.constructor3.scope | 17 +++++ .../python/argumentList.formal.lambda.scope | 20 +++++ .../python/argumentList.formal.lambda2.scope | 13 ++++ .../python/argumentList.formal.method.scope | 17 +++++ .../python/argumentList.formal.method2.scope | 27 +++++++ .../python/argumentList.formal.method3.scope | 17 +++++ .../scopes/python/argumentList.formal.scope | 16 ++++ .../scopes/python/argumentList.formal2.scope | 26 +++++++ .../scopes/python/argumentList.formal3.scope | 16 ++++ packages/common/src/scopeSupportFacets/css.ts | 6 ++ .../common/src/scopeSupportFacets/html.ts | 6 ++ .../common/src/scopeSupportFacets/json.ts | 6 ++ .../common/src/scopeSupportFacets/markdown.ts | 6 ++ .../common/src/scopeSupportFacets/python.ts | 6 ++ packages/common/src/scopeSupportFacets/scm.ts | 6 ++ .../common/src/scopeSupportFacets/talon.ts | 6 ++ packages/common/src/scopeSupportFacets/xml.ts | 6 ++ .../common/src/scopeSupportFacets/yaml.ts | 6 ++ .../queryPredicateOperators.ts | 14 ++-- queries/python.scm | 26 +++++-- 26 files changed, 457 insertions(+), 15 deletions(-) create mode 100644 data/fixtures/scopes/python/argument.formal.constructor2.scope create mode 100644 data/fixtures/scopes/python/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/python/argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/python/argument.formal.method2.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.constructor.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.constructor2.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.constructor3.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.lambda.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.lambda2.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.method.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.method2.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.method3.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal2.scope create mode 100644 data/fixtures/scopes/python/argumentList.formal3.scope diff --git a/data/fixtures/scopes/python/argument.formal.constructor2.scope b/data/fixtures/scopes/python/argument.formal.constructor2.scope new file mode 100644 index 0000000000..8d77cf5de9 --- /dev/null +++ b/data/fixtures/scopes/python/argument.formal.constructor2.scope @@ -0,0 +1,73 @@ +class Foo: + def __init__( + self, + aaa: str, + bbb: int + ): + pass +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:12 + >----< +2| self, + +[#1 Removal] = 2:8-3:8 + >----- +2| self, +3| aaa: str, + --------< + +[#1 Trailing delimiter] = 2:12-3:8 + >- +2| self, +3| aaa: str, + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:16 + >--------< +3| aaa: str, + +[#2 Removal] = 3:8-4:8 + >--------- +3| aaa: str, +4| bbb: int + --------< + +[#2 Leading delimiter] = 2:12-3:8 + >- +2| self, +3| aaa: str, + --------< + +[#2 Trailing delimiter] = 3:16-4:8 + >- +3| aaa: str, +4| bbb: int + --------< + +[#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 4:8-4:16 + >--------< +4| bbb: int + +[#3 Removal] = 3:16-4:16 + >- +3| aaa: str, +4| bbb: int + ----------------< + +[#3 Leading delimiter] = 3:16-4:8 + >- +3| aaa: str, +4| bbb: int + --------< + +[#3 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/python/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/python/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..e3037349fa --- /dev/null +++ b/data/fixtures/scopes/python/argument.formal.lambda.iteration.scope @@ -0,0 +1,10 @@ +lambda a, b: pass +--- + +[Range] = 0:7-0:11 + >----< +0| lambda a, b: pass + +[Domain] = 0:0-0:17 + >-----------------< +0| lambda a, b: pass diff --git a/data/fixtures/scopes/python/argument.formal.lambda.scope b/data/fixtures/scopes/python/argument.formal.lambda.scope new file mode 100644 index 0000000000..5adf6669e6 --- /dev/null +++ b/data/fixtures/scopes/python/argument.formal.lambda.scope @@ -0,0 +1,33 @@ +lambda a, b: pass +--- + +[#1 Content] = +[#1 Domain] = 0:7-0:8 + >-< +0| lambda a, b: pass + +[#1 Removal] = 0:7-0:10 + >---< +0| lambda a, b: pass + +[#1 Trailing delimiter] = 0:8-0:10 + >--< +0| lambda a, b: pass + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:10-0:11 + >-< +0| lambda a, b: pass + +[#2 Removal] = 0:8-0:11 + >---< +0| lambda a, b: pass + +[#2 Leading delimiter] = 0:8-0:10 + >--< +0| lambda a, b: pass + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/python/argument.formal.method2.scope b/data/fixtures/scopes/python/argument.formal.method2.scope new file mode 100644 index 0000000000..886af41601 --- /dev/null +++ b/data/fixtures/scopes/python/argument.formal.method2.scope @@ -0,0 +1,46 @@ +class Foo: + def bar( + aaa: str, + bbb: int + ): + pass +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:16 + >--------< +2| aaa: str, + +[#1 Removal] = 2:8-3:8 + >--------- +2| aaa: str, +3| bbb: int + --------< + +[#1 Trailing delimiter] = 2:16-3:8 + >- +2| aaa: str, +3| bbb: int + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:16 + >--------< +3| bbb: int + +[#2 Removal] = 2:16-3:16 + >- +2| aaa: str, +3| bbb: int + ----------------< + +[#2 Leading delimiter] = 2:16-3:8 + >- +2| aaa: str, +3| bbb: int + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/python/argumentList.formal.constructor.scope b/data/fixtures/scopes/python/argumentList.formal.constructor.scope new file mode 100644 index 0000000000..63d0ad239c --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.constructor.scope @@ -0,0 +1,17 @@ +class Foo: + def __init__(self, aaa: str, bbb: int): + pass +--- + +[Content] = +[Removal] = 1:17-1:41 + >------------------------< +1| def __init__(self, aaa: str, bbb: int): + +[Domain] = 1:4-2:12 + >--------------------------------------- +1| def __init__(self, aaa: str, bbb: int): +2| pass + ------------< + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/python/argumentList.formal.constructor2.scope b/data/fixtures/scopes/python/argumentList.formal.constructor2.scope new file mode 100644 index 0000000000..35e43de29e --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.constructor2.scope @@ -0,0 +1,30 @@ +class Foo: + def __init__( + self, + aaa: str, + bbb: int + ): + pass +--- + +[Content] = +[Removal] = 1:17-5:4 + > +1| def __init__( +2| self, +3| aaa: str, +4| bbb: int +5| ): + ----< + +[Domain] = 1:4-6:12 + >------------- +1| def __init__( +2| self, +3| aaa: str, +4| bbb: int +5| ): +6| pass + ------------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/python/argumentList.formal.constructor3.scope b/data/fixtures/scopes/python/argumentList.formal.constructor3.scope new file mode 100644 index 0000000000..938990a30e --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.constructor3.scope @@ -0,0 +1,17 @@ +class Foo: + def __init__(): + pass +--- + +[Content] = +[Removal] = 1:17-1:17 + >< +1| def __init__(): + +[Domain] = 1:4-2:12 + >--------------- +1| def __init__(): +2| pass + ------------< + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/python/argumentList.formal.lambda.scope b/data/fixtures/scopes/python/argumentList.formal.lambda.scope new file mode 100644 index 0000000000..d00cbcf3f0 --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.lambda.scope @@ -0,0 +1,20 @@ +lambda a, b: pass +--- + +[Content] = 0:7-0:11 + >----< +0| lambda a, b: pass + +[Removal] = 0:6-0:11 + >-----< +0| lambda a, b: pass + +[Leading delimiter] = 0:6-0:7 + >-< +0| lambda a, b: pass + +[Domain] = 0:0-0:17 + >-----------------< +0| lambda a, b: pass + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/python/argumentList.formal.lambda2.scope b/data/fixtures/scopes/python/argumentList.formal.lambda2.scope new file mode 100644 index 0000000000..f45a6ee6be --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.lambda2.scope @@ -0,0 +1,13 @@ +lambda: pass +--- + +[Content] = +[Removal] = 0:6-0:6 + >< +0| lambda: pass + +[Domain] = 0:0-0:12 + >------------< +0| lambda: pass + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/python/argumentList.formal.method.scope b/data/fixtures/scopes/python/argumentList.formal.method.scope new file mode 100644 index 0000000000..32cb62c3e3 --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.method.scope @@ -0,0 +1,17 @@ +class Foo: + def bar(aaa: str, bbb: int): + pass +--- + +[Content] = +[Removal] = 1:12-1:30 + >------------------< +1| def bar(aaa: str, bbb: int): + +[Domain] = 1:4-2:12 + >---------------------------- +1| def bar(aaa: str, bbb: int): +2| pass + ------------< + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/python/argumentList.formal.method2.scope b/data/fixtures/scopes/python/argumentList.formal.method2.scope new file mode 100644 index 0000000000..9f9c431dbd --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.method2.scope @@ -0,0 +1,27 @@ +class Foo: + def bar( + aaa: str, + bbb: int + ): + pass +--- + +[Content] = +[Removal] = 1:12-4:4 + > +1| def bar( +2| aaa: str, +3| bbb: int +4| ): + ----< + +[Domain] = 1:4-5:12 + >-------- +1| def bar( +2| aaa: str, +3| bbb: int +4| ): +5| pass + ------------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/python/argumentList.formal.method3.scope b/data/fixtures/scopes/python/argumentList.formal.method3.scope new file mode 100644 index 0000000000..6d6fb449e5 --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.method3.scope @@ -0,0 +1,17 @@ +class Foo: + def bar(): + pass +--- + +[Content] = +[Removal] = 1:12-1:12 + >< +1| def bar(): + +[Domain] = 1:4-2:12 + >---------- +1| def bar(): +2| pass + ------------< + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/python/argumentList.formal.scope b/data/fixtures/scopes/python/argumentList.formal.scope new file mode 100644 index 0000000000..689577d9ac --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal.scope @@ -0,0 +1,16 @@ +def for(name: str, value: int): + pass +--- + +[Content] = +[Removal] = 0:8-0:29 + >---------------------< +0| def for(name: str, value: int): + +[Domain] = 0:0-1:8 + >------------------------------- +0| def for(name: str, value: int): +1| pass + --------< + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/python/argumentList.formal2.scope b/data/fixtures/scopes/python/argumentList.formal2.scope new file mode 100644 index 0000000000..34dce296ee --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal2.scope @@ -0,0 +1,26 @@ +def foo( + aaa, + bbb, +): + pass +--- + +[Content] = +[Removal] = 0:8-3:0 + > +0| def foo( +1| aaa, +2| bbb, +3| ): + < + +[Domain] = 0:0-4:8 + >-------- +0| def foo( +1| aaa, +2| bbb, +3| ): +4| pass + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/python/argumentList.formal3.scope b/data/fixtures/scopes/python/argumentList.formal3.scope new file mode 100644 index 0000000000..8cc064e417 --- /dev/null +++ b/data/fixtures/scopes/python/argumentList.formal3.scope @@ -0,0 +1,16 @@ +def for(): + pass +--- + +[Content] = +[Removal] = 0:8-0:8 + >< +0| def for(): + +[Domain] = 0:0-1:8 + >---------- +0| def for(): +1| pass + --------< + +[Insertion delimiter] = "" diff --git a/packages/common/src/scopeSupportFacets/css.ts b/packages/common/src/scopeSupportFacets/css.ts index e79d96aeba..fd7d2c7452 100644 --- a/packages/common/src/scopeSupportFacets/css.ts +++ b/packages/common/src/scopeSupportFacets/css.ts @@ -46,6 +46,12 @@ export const cssScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.method.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, attribute: notApplicable, "branch.if.iteration": notApplicable, "branch.if": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/html.ts b/packages/common/src/scopeSupportFacets/html.ts index 47dde0a787..c87104ff68 100644 --- a/packages/common/src/scopeSupportFacets/html.ts +++ b/packages/common/src/scopeSupportFacets/html.ts @@ -32,6 +32,12 @@ export const htmlScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.method.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, "branch.if.iteration": notApplicable, "branch.if": notApplicable, "branch.loop": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/json.ts b/packages/common/src/scopeSupportFacets/json.ts index 8089ee0f2d..ac62464842 100644 --- a/packages/common/src/scopeSupportFacets/json.ts +++ b/packages/common/src/scopeSupportFacets/json.ts @@ -36,6 +36,12 @@ export const jsonScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal.method.iteration": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, attribute: notApplicable, "branch.if": notApplicable, "branch.if.iteration": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/markdown.ts b/packages/common/src/scopeSupportFacets/markdown.ts index 4600a7ab4a..c841d94614 100644 --- a/packages/common/src/scopeSupportFacets/markdown.ts +++ b/packages/common/src/scopeSupportFacets/markdown.ts @@ -36,6 +36,12 @@ export const markdownScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal.method.iteration": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, attribute: notApplicable, "branch.if": notApplicable, "branch.if.iteration": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 9673bda4e1..c642e03cb0 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -73,6 +73,12 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.constructor.iteration": supported, "argument.formal.method": supported, "argument.formal.method.iteration": supported, + "argument.formal.lambda": supported, + "argument.formal.lambda.iteration": supported, + "argumentList.formal": supported, + "argumentList.formal.method": supported, + "argumentList.formal.constructor": supported, + "argumentList.formal.lambda": supported, "collectionItem.unenclosed": supported, "collectionItem.unenclosed.iteration": supported, diff --git a/packages/common/src/scopeSupportFacets/scm.ts b/packages/common/src/scopeSupportFacets/scm.ts index f5ade133a0..782986963f 100644 --- a/packages/common/src/scopeSupportFacets/scm.ts +++ b/packages/common/src/scopeSupportFacets/scm.ts @@ -29,6 +29,12 @@ export const scmScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal.method.iteration": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, attribute: notApplicable, "branch.if": notApplicable, "branch.if.iteration": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/talon.ts b/packages/common/src/scopeSupportFacets/talon.ts index 39ced3b085..8864d4159e 100644 --- a/packages/common/src/scopeSupportFacets/talon.ts +++ b/packages/common/src/scopeSupportFacets/talon.ts @@ -43,6 +43,12 @@ export const talonScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal.method.iteration": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, attribute: notApplicable, "branch.if": notApplicable, "branch.if.iteration": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/xml.ts b/packages/common/src/scopeSupportFacets/xml.ts index 8f19d84a63..5830eb01aa 100644 --- a/packages/common/src/scopeSupportFacets/xml.ts +++ b/packages/common/src/scopeSupportFacets/xml.ts @@ -33,6 +33,12 @@ export const xmlScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal.method.iteration": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, "branch.if": notApplicable, "branch.if.iteration": notApplicable, "branch.loop": notApplicable, diff --git a/packages/common/src/scopeSupportFacets/yaml.ts b/packages/common/src/scopeSupportFacets/yaml.ts index d12ba86b94..737fc5b416 100644 --- a/packages/common/src/scopeSupportFacets/yaml.ts +++ b/packages/common/src/scopeSupportFacets/yaml.ts @@ -42,6 +42,12 @@ export const yamlScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.iteration": notApplicable, "argument.formal.method": notApplicable, "argument.formal.method.iteration": notApplicable, + "argument.formal.lambda": notApplicable, + "argument.formal.lambda.iteration": notApplicable, + "argumentList.formal": notApplicable, + "argumentList.formal.method": notApplicable, + "argumentList.formal.constructor": notApplicable, + "argumentList.formal.lambda": notApplicable, attribute: notApplicable, "branch.if": notApplicable, "branch.if.iteration": notApplicable, diff --git a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts index 76312bf048..80f689c840 100644 --- a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts +++ b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts @@ -344,15 +344,11 @@ class EmptySingleMultiDelimiter extends QueryPredicateOperator child.isNamed, ); - nodeInfo.insertionDelimiter = (() => { - if (isEmpty) { - return insertionDelimiterEmpty; - } - if (conditionNodeInfo.range.isSingleLine) { - return insertionDelimiterSingleLine; - } - return insertionDelimiterMultiline; - })(); + nodeInfo.insertionDelimiter = isEmpty + ? insertionDelimiterEmpty + : conditionNodeInfo.range.isSingleLine + ? insertionDelimiterSingleLine + : insertionDelimiterMultiline; return true; } diff --git a/queries/python.scm b/queries/python.scm index 396d492949..72980a10e8 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -605,8 +605,8 @@ ;;!! def foo(name) {} ;;! ^^^^ -( - (parameters +(_ + parameters: (_ (_)? @_.leading.endOf . (_) @argumentOrParameter @@ -644,12 +644,26 @@ ) ) +(lambda + (lambda_parameters) @argumentList @argumentOrParameter.iteration + (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") +) @argumentList.domain @argumentOrParameter.iteration.domain + +(lambda + . + "lambda" @argumentList.start.endOf + . + ":" + (#insertion-delimiter! @argumentList.start.endOf " ") +) @argumentList.domain + (_ (parameters - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf - ) -) @argumentOrParameter.iteration.domain + "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf + ) @_dummy + (#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n") +) @argumentList.domain @argumentOrParameter.iteration.domain (argument_list "(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf From 27e1cb65cc731920c000dcf276510130effbeb50 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 10:41:59 +0200 Subject: [PATCH 08/12] Empty line --- packages/common/src/scopeSupportFacets/python.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index c642e03cb0..19d57982ff 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -75,6 +75,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.method.iteration": supported, "argument.formal.lambda": supported, "argument.formal.lambda.iteration": supported, + "argumentList.formal": supported, "argumentList.formal.method": supported, "argumentList.formal.constructor": supported, From 458f6b6ee007aa659a09241c4193451741317038 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 10:43:57 +0200 Subject: [PATCH 09/12] Consistent naming of parameters --- .../src/scopeSupportFacets/scopeSupportFacetInfos.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 7273eda762..0730be6242 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -283,19 +283,19 @@ export const scopeSupportFacetInfos: Record< }, "argumentList.formal": { - description: "A list of arguments in a function declaration", + description: "A list of parameters in a function declaration", scopeType: "argumentList", }, "argumentList.formal.method": { - description: "A list of arguments in a class method declaration", + description: "A list of parameters in a class method declaration", scopeType: "argumentList", }, "argumentList.formal.constructor": { - description: "A list of arguments in a constructor declaration", + description: "A list of parameters in a constructor declaration", scopeType: "argumentList", }, "argumentList.formal.lambda": { - description: "A list of arguments in a lambda declaration", + description: "A list of parameters in a lambda declaration", scopeType: "argumentList", }, From d0f1ee7aef45dbcc7cbe40c94db9b3275ed6910e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 10:49:17 +0200 Subject: [PATCH 10/12] Comments --- queries/python.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/queries/python.scm b/queries/python.scm index 72980a10e8..aab9f75436 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -644,11 +644,14 @@ ) ) +;;!! lambda a, b: pass +;;! ^^^^ (lambda (lambda_parameters) @argumentList @argumentOrParameter.iteration - (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") + (#insertion-delimiter! @argumentList.start.endOf ", ") ) @argumentList.domain @argumentOrParameter.iteration.domain +;;!! lambda: pass (lambda . "lambda" @argumentList.start.endOf @@ -657,6 +660,8 @@ (#insertion-delimiter! @argumentList.start.endOf " ") ) @argumentList.domain +;;!! def (a, b): pass +;;! ^^^^ (_ (parameters "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf From ef4a4b6b8b3f96cafc30fab6c4a091e1ef9409b3 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 10:50:10 +0200 Subject: [PATCH 11/12] fix --- queries/python.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries/python.scm b/queries/python.scm index aab9f75436..39bec07d4f 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -648,7 +648,7 @@ ;;! ^^^^ (lambda (lambda_parameters) @argumentList @argumentOrParameter.iteration - (#insertion-delimiter! @argumentList.start.endOf ", ") + (#insertion-delimiter! @argumentList ", ") ) @argumentList.domain @argumentOrParameter.iteration.domain ;;!! lambda: pass From f2cfe198cda2ce3e27b423fa0fcfed6c0bb35ac5 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 25 Apr 2025 16:19:59 +0200 Subject: [PATCH 12/12] Update cheat sheet and changelog --- changelog/2025-04-addedArgumentListScope.md | 6 ++++++ .../src/lib/sampleSpokenFormInfos/defaults.json | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 changelog/2025-04-addedArgumentListScope.md diff --git a/changelog/2025-04-addedArgumentListScope.md b/changelog/2025-04-addedArgumentListScope.md new file mode 100644 index 0000000000..7c07c1c1a2 --- /dev/null +++ b/changelog/2025-04-addedArgumentListScope.md @@ -0,0 +1,6 @@ +--- +tags: [enhancement] +pullRequest: 2907 +--- + +- Added `"arg list"` scope. The argument list is the entire list of arguments in a declared function. diff --git a/packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json b/packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json index 28e3ea93b1..b2aaceb889 100644 --- a/packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json +++ b/packages/cheatsheet/src/lib/sampleSpokenFormInfos/defaults.json @@ -1196,6 +1196,16 @@ } ] }, + { + "id": "argumentList", + "type": "scopeType", + "variations": [ + { + "spokenForm": "arg list", + "description": "Argument list" + } + ] + }, { "id": "argumentOrParameter", "type": "scopeType",