Skip to content

Commit a917aae

Browse files
authored
Add iteration scope for typescript functions (#1545)
## Checklist - [ ] 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 de29bdd commit a917aae

File tree

10 files changed

+290
-0
lines changed

10 files changed

+290
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: namedFunction}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |-
14+
class Foo {
15+
bar() {
16+
17+
}
18+
19+
baz() {
20+
21+
}
22+
}
23+
selections:
24+
- anchor: {line: 8, character: 1}
25+
active: {line: 8, character: 1}
26+
marks: {}
27+
finalState:
28+
documentContents: |-
29+
class Foo {
30+
31+
32+
33+
}
34+
selections:
35+
- anchor: {line: 1, character: 4}
36+
active: {line: 1, character: 4}
37+
- anchor: {line: 3, character: 4}
38+
active: {line: 3, character: 4}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: namedFunction}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |
14+
function aaa() {}
15+
function bbb() {}
16+
selections:
17+
- anchor: {line: 2, character: 0}
18+
active: {line: 2, character: 0}
19+
marks: {}
20+
finalState:
21+
documentContents: |+
22+
23+
24+
selections:
25+
- anchor: {line: 0, character: 0}
26+
active: {line: 0, character: 0}
27+
- anchor: {line: 1, character: 0}
28+
active: {line: 1, character: 0}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: namedFunction}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |-
14+
type Aaa = {
15+
bbb(): void;
16+
ccc(): void;
17+
}
18+
19+
function ddd() {}
20+
selections:
21+
- anchor: {line: 3, character: 1}
22+
active: {line: 3, character: 1}
23+
marks: {}
24+
finalState:
25+
documentContents: |-
26+
type Aaa = {
27+
28+
29+
}
30+
31+
function ddd() {}
32+
selections:
33+
- anchor: {line: 1, character: 4}
34+
active: {line: 1, character: 4}
35+
- anchor: {line: 2, character: 4}
36+
active: {line: 2, character: 4}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: namedFunction}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |-
14+
interface Aaa {
15+
bbb(): void;
16+
ccc(): void;
17+
}
18+
19+
function ddd() {}
20+
selections:
21+
- anchor: {line: 3, character: 1}
22+
active: {line: 3, character: 1}
23+
marks: {}
24+
finalState:
25+
documentContents: |-
26+
interface Aaa {
27+
28+
29+
}
30+
31+
function ddd() {}
32+
selections:
33+
- anchor: {line: 1, character: 4}
34+
active: {line: 1, character: 4}
35+
- anchor: {line: 2, character: 4}
36+
active: {line: 2, character: 4}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: namedFunction}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |-
14+
const aaa = {
15+
bbb() {},
16+
ccc() {},
17+
}
18+
19+
function ddd() {}
20+
selections:
21+
- anchor: {line: 3, character: 1}
22+
active: {line: 3, character: 1}
23+
marks: {}
24+
finalState:
25+
documentContents: |-
26+
const aaa = {
27+
,
28+
,
29+
}
30+
31+
function ddd() {}
32+
selections:
33+
- anchor: {line: 1, character: 4}
34+
active: {line: 1, character: 4}
35+
- anchor: {line: 2, character: 4}
36+
active: {line: 2, character: 4}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: namedFunction}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |-
14+
const aaa = {
15+
bbb: "ccc",
16+
ddd: "eee",
17+
}
18+
19+
function fff() {}
20+
selections:
21+
- anchor: {line: 3, character: 1}
22+
active: {line: 3, character: 1}
23+
marks: {}
24+
finalState:
25+
documentContents: |+
26+
const aaa = {
27+
bbb: "ccc",
28+
ddd: "eee",
29+
}
30+
31+
selections:
32+
- anchor: {line: 5, character: 0}
33+
active: {line: 5, character: 0}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk name
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: functionName}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |-
14+
class Foo {
15+
bar() {
16+
17+
}
18+
19+
baz() {
20+
21+
}
22+
}
23+
selections:
24+
- anchor: {line: 8, character: 1}
25+
active: {line: 8, character: 1}
26+
marks: {}
27+
finalState:
28+
documentContents: |-
29+
class Foo {
30+
() {
31+
32+
}
33+
34+
() {
35+
36+
}
37+
}
38+
selections:
39+
- anchor: {line: 1, character: 4}
40+
active: {line: 1, character: 4}
41+
- anchor: {line: 5, character: 4}
42+
active: {line: 5, character: 4}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
languageId: typescript
2+
command:
3+
version: 5
4+
spokenForm: clear every funk name
5+
action: {name: clearAndSetSelection}
6+
targets:
7+
- type: primitive
8+
modifiers:
9+
- type: everyScope
10+
scopeType: {type: functionName}
11+
usePrePhraseSnapshot: true
12+
initialState:
13+
documentContents: |
14+
function aaa() {}
15+
function bbb() {}
16+
selections:
17+
- anchor: {line: 2, character: 0}
18+
active: {line: 2, character: 0}
19+
marks: {}
20+
finalState:
21+
documentContents: |
22+
function () {}
23+
function () {}
24+
selections:
25+
- anchor: {line: 0, character: 9}
26+
active: {line: 0, character: 9}
27+
- anchor: {line: 1, character: 9}
28+
active: {line: 1, character: 9}

queries/javascript.function.scm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,11 @@
157157
]
158158
)
159159
] @namedFunction @functionName.domain
160+
161+
[
162+
(program)
163+
(class_declaration)
164+
(object
165+
(method_definition)
166+
)
167+
] @namedFunction.iteration @functionName.iteration

queries/typescript.scm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@
6767
.
6868
";"? @name.domain.end
6969
)
70+
71+
[
72+
(interface_declaration)
73+
(object_type)
74+
] @namedFunction.iteration @functionName.iteration

0 commit comments

Comments
 (0)