Skip to content

Commit df12b92

Browse files
author
fidgetingbits
committed
Support interpolated string args, add assert condition/branch, fix if branch
1 parent c9a7f97 commit df12b92

File tree

8 files changed

+86
-168
lines changed

8 files changed

+86
-168
lines changed

packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/nix/changeArgBat.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/nix/changeArgBlueDot.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/nix/changeBranch.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,18 @@ command:
1111
scopeType: {type: branch}
1212
usePrePhraseSnapshot: true
1313
initialState:
14-
documentContents: |
14+
documentContents: |-
1515
{
16-
key = if a then b else c;
17-
16+
foo = if a then b else c;
1817
}
1918
selections:
2019
- anchor: {line: 1, character: 9}
2120
active: {line: 1, character: 9}
2221
marks: {}
2322
finalState:
24-
documentContents: |
23+
documentContents: |-
2524
{
26-
key = then b else c;
27-
25+
foo = else c;
2826
}
2927
selections:
3028
- anchor: {line: 1, character: 8}

packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/nix/changeBranch2.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/nix/changeEveryArg.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: chuck arg
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: argumentOrParameter}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
d = "Interpolated ${value1} string ${value2}";
17+
}
18+
selections:
19+
- anchor: {line: 1, character: 26}
20+
active: {line: 1, character: 26}
21+
marks: {}
22+
finalState:
23+
documentContents: |
24+
{
25+
d = "Interpolated string ${value2}";
26+
}
27+
selections:
28+
- anchor: {line: 1, character: 20}
29+
active: {line: 1, character: 20}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: chuck key
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: collectionKey}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
d = "Interpolated ${value1} string ${value2}";
17+
}
18+
selections:
19+
- anchor: {line: 1, character: 6}
20+
active: {line: 1, character: 6}
21+
marks: {}
22+
finalState:
23+
documentContents: |
24+
{
25+
"Interpolated ${value1} string ${value2}";
26+
}
27+
selections:
28+
- anchor: {line: 1, character: 2}
29+
active: {line: 1, character: 2}

queries/nix.scm

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@
2323
(
2424
(assert_expression
2525
"assert" @statement.start
26-
condition: (_) @condition
26+
condition: (_)
2727
";" @statement.end
2828
body: (_)
2929
) @_.domain
3030
(#not-parent-type? @_.domain binding)
3131
)
32+
(assert_expression
33+
"assert" @functionCallee @functionCall.start
34+
condition: (_) @condition
35+
body: (_) @branch @functionCall.end.startOf
36+
) @_.domain
3237

3338
(
3439
(with_expression) @statement
@@ -52,19 +57,17 @@
5257
;;! ^^^^^^^^^^^^^^^^^^
5358
(if_expression) @ifStatement @branch.iteration @condition.iteration
5459
;;!! key = if a then b else c;
55-
;;! ^^^^
60+
;;! ^^^^^^^^^^^
61+
;;! xxxxxxxxxxxx
5662
(if_expression
5763
"if" @branch.start
58-
condition: (_) @branch.end
59-
)
60-
;;!! key = if a then b else c;
61-
;;! ^^^^^^
62-
(if_expression
63-
"then" @branch.start
64+
condition: (_)
65+
"then"
6466
consequence: (_) @branch.end
6567
)
6668
;;!! key = if a then b else c;
6769
;;! ^^^^^^
70+
;;! xxxxxxx
6871
(if_expression
6972
"else" @branch.start
7073
alternative: (_) @branch.end
@@ -93,9 +96,11 @@
9396

9497
;;!! foo = { x = 1; y = 2; };
9598
;;! ^
99+
;;! xxxx
96100
;;! -----
97101
(binding
98-
attrpath: (_) @collectionKey
102+
attrpath: (_) @collectionKey @_.trailing.start.endOf
103+
expression: (_) @_.trailing.end.startOf
99104
) @_.domain
100105

101106
;; Strings
@@ -110,6 +115,13 @@
110115
] @string
111116
(string_fragment) @textFragment
112117

118+
;;!! d = "foo ${bar} baz"
119+
;;! ^^^^^^
120+
;;! <**************>
121+
(string_expression
122+
(interpolation) @argumentOrParameter
123+
) @_.iteration
124+
113125
;; Functions
114126

115127
;; Note for this part of the function, we identify is as lambda only
@@ -166,10 +178,10 @@
166178

167179
;;!! a = 25;
168180
;;! ^
169-
;;! xx
181+
;;! xxxx
170182
;;! -------
171183
(binding
172-
(_) @name @_.leading.end.startOf
184+
(_) @name @_.leading.end.startOf @_.trailing.start.endOf
173185
.
174-
expression: (_)
186+
expression: (_) @_.trailing.end.startOf
175187
) @_.domain

0 commit comments

Comments
 (0)