Skip to content

Commit 220e381

Browse files
Added iteration scope for python arguments (#2757)
Fixes #2729 ## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet
1 parent d016357 commit 220e381

File tree

8 files changed

+134
-4
lines changed

8 files changed

+134
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
aaa(bbb=0, ccc=1)
2+
---
3+
4+
[#1 Range] =
5+
[#1 Domain] = 0:0-0:17
6+
>-----------------<
7+
0| aaa(bbb=0, ccc=1)
8+
9+
10+
[#2 Range] = 0:4-0:16
11+
>------------<
12+
0| aaa(bbb=0, ccc=1)
13+
14+
[#2 Domain] = 0:3-0:17
15+
>--------------<
16+
0| aaa(bbb=0, ccc=1)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
aaa(bbb=0, ccc=1)
2+
---
3+
4+
[#1 Content] =
5+
[#1 Removal] = 0:4-0:7
6+
>---<
7+
0| aaa(bbb=0, ccc=1)
8+
9+
[#1 Domain] = 0:4-0:9
10+
>-----<
11+
0| aaa(bbb=0, ccc=1)
12+
13+
[#1 Insertion delimiter] = " "
14+
15+
16+
[#2 Content] =
17+
[#2 Removal] = 0:11-0:14
18+
>---<
19+
0| aaa(bbb=0, ccc=1)
20+
21+
[#2 Leading delimiter] = 0:10-0:11
22+
>-<
23+
0| aaa(bbb=0, ccc=1)
24+
25+
[#2 Domain] = 0:11-0:16
26+
>-----<
27+
0| aaa(bbb=0, ccc=1)
28+
29+
[#2 Insertion delimiter] = " "
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
aaa(bbb=0, ccc=1)
2+
---
3+
4+
[#1 Range] =
5+
[#1 Domain] = 0:0-0:17
6+
>-----------------<
7+
0| aaa(bbb=0, ccc=1)
8+
9+
10+
[#2 Range] = 0:4-0:16
11+
>------------<
12+
0| aaa(bbb=0, ccc=1)
13+
14+
[#2 Domain] = 0:3-0:17
15+
>--------------<
16+
0| aaa(bbb=0, ccc=1)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
aaa(bbb=0, ccc=1)
2+
---
3+
4+
[#1 Content] = 0:8-0:9
5+
>-<
6+
0| aaa(bbb=0, ccc=1)
7+
8+
[#1 Removal] = 0:7-0:9
9+
>--<
10+
0| aaa(bbb=0, ccc=1)
11+
12+
[#1 Leading delimiter] = 0:7-0:8
13+
>-<
14+
0| aaa(bbb=0, ccc=1)
15+
16+
[#1 Domain] = 0:4-0:9
17+
>-----<
18+
0| aaa(bbb=0, ccc=1)
19+
20+
[#1 Insertion delimiter] = " "
21+
22+
23+
[#2 Content] = 0:15-0:16
24+
>-<
25+
0| aaa(bbb=0, ccc=1)
26+
27+
[#2 Removal] = 0:14-0:16
28+
>--<
29+
0| aaa(bbb=0, ccc=1)
30+
31+
[#2 Leading delimiter] = 0:14-0:15
32+
>-<
33+
0| aaa(bbb=0, ccc=1)
34+
35+
[#2 Domain] = 0:11-0:16
36+
>-----<
37+
0| aaa(bbb=0, ccc=1)
38+
39+
[#2 Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/python.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
77
"name.foreach": supported,
88
"name.resource": supported,
99
"name.resource.iteration": supported,
10+
"name.argument.actual": supported,
11+
"name.argument.actual.iteration": supported,
12+
1013
"value.foreach": supported,
1114
"value.yield": supported,
1215
"value.resource": supported,
1316
"value.resource.iteration": supported,
17+
"value.argument.actual": supported,
18+
"value.argument.actual.iteration": supported,
19+
1420
namedFunction: supported,
1521
anonymousFunction: supported,
1622
disqualifyDelimiter: supported,

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,16 @@ export const scopeSupportFacetInfos: Record<
442442
scopeType: "name",
443443
isIteration: true,
444444
},
445+
"name.argument.actual": {
446+
description: "The name of a (keyword) argument in a function call",
447+
scopeType: "name",
448+
},
449+
"name.argument.actual.iteration": {
450+
description:
451+
"Iteration scope of the names of the actual parameters of a function call; should be the whole arguments list",
452+
scopeType: "name",
453+
isIteration: true,
454+
},
445455
"name.argument.formal": {
446456
description: "The name of a parameter in a function declaration",
447457
scopeType: "name",
@@ -556,7 +566,7 @@ export const scopeSupportFacetInfos: Record<
556566
isIteration: true,
557567
},
558568
"value.argument.formal": {
559-
description: "The value of a parameter in a function declaration",
569+
description: "The value of a (keyword) argument in a function declaration",
560570
scopeType: "value",
561571
},
562572
"value.argument.formal.iteration": {
@@ -565,6 +575,16 @@ export const scopeSupportFacetInfos: Record<
565575
scopeType: "value",
566576
isIteration: true,
567577
},
578+
"value.argument.actual": {
579+
description: "The value of a argument in a function call",
580+
scopeType: "value",
581+
},
582+
"value.argument.actual.iteration": {
583+
description:
584+
"Iteration scope of the values of the actual parameters of a function call; should be the whole arguments list",
585+
scopeType: "value",
586+
isIteration: true,
587+
},
568588
"value.argument.formal.method": {
569589
description: "The value of a parameter in a class method declaration",
570590
scopeType: "value",

packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export const scopeSupportFacets = [
115115
"name.field",
116116
"name.resource",
117117
"name.resource.iteration",
118+
"name.argument.actual",
119+
"name.argument.actual.iteration",
118120
"name.argument.formal",
119121
"name.argument.formal.iteration",
120122
"name.argument.formal.method",
@@ -141,6 +143,8 @@ export const scopeSupportFacets = [
141143
"value.yield",
142144
"value.resource",
143145
"value.resource.iteration",
146+
"value.argument.actual",
147+
"value.argument.actual.iteration",
144148
"value.argument.formal",
145149
"value.argument.formal.iteration",
146150
"value.argument.formal.method",

queries/python.scm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,9 @@
626626
) @argumentOrParameter.iteration.domain
627627

628628
(argument_list
629-
"(" @argumentOrParameter.iteration.start.endOf
630-
")" @argumentOrParameter.iteration.end.startOf
631-
) @argumentOrParameter.iteration.domain
629+
"(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf
630+
")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf
631+
) @argumentOrParameter.iteration.domain @name.iteration.domain @value.iteration.domain
632632

633633
(call
634634
(generator_expression

0 commit comments

Comments
 (0)