Skip to content

Commit 09e7e34

Browse files
author
fidgetingbits
committed
Better support for c-style for loops
1 parent dc2ff17 commit 09e7e34

File tree

6 files changed

+195
-0
lines changed

6 files changed

+195
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
languageId: shellscript
2+
command:
3+
version: 6
4+
spokenForm: change condition five
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
mark: {type: decoratedSymbol, symbolColor: default, character: '5'}
10+
modifiers:
11+
- type: containingScope
12+
scopeType: {type: condition}
13+
usePrePhraseSnapshot: true
14+
initialState:
15+
documentContents: |2
16+
# C-style for loop
17+
for ((i = 1; i <= 5; i++)); do
18+
echo "C-style loop iteration: $i"
19+
done
20+
selections:
21+
- anchor: {line: 1, character: 19}
22+
active: {line: 1, character: 19}
23+
marks:
24+
default.5:
25+
start: {line: 1, character: 20}
26+
end: {line: 1, character: 21}
27+
finalState:
28+
documentContents: |2
29+
# C-style for loop
30+
for ((i = 1; ; i++)); do
31+
echo "C-style loop iteration: $i"
32+
done
33+
selections:
34+
- anchor: {line: 1, character: 15}
35+
active: {line: 1, character: 15}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: shellscript
2+
command:
3+
version: 6
4+
spokenForm: change name
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: name}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
for ((i = 1; i <= 5; i++)); do
16+
echo "C-style loop iteration: $i"
17+
done
18+
selections:
19+
- anchor: {line: 0, character: 8}
20+
active: {line: 0, character: 8}
21+
marks: {}
22+
finalState:
23+
documentContents: |-
24+
for (( = 1; i <= 5; i++)); do
25+
echo "C-style loop iteration: $i"
26+
done
27+
selections:
28+
- anchor: {line: 0, character: 6}
29+
active: {line: 0, character: 6}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
languageId: shellscript
2+
command:
3+
version: 6
4+
spokenForm: change value one
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
mark: {type: decoratedSymbol, symbolColor: default, character: '1'}
10+
modifiers:
11+
- type: containingScope
12+
scopeType: {type: value}
13+
usePrePhraseSnapshot: true
14+
initialState:
15+
documentContents: |2
16+
# C-style for loop
17+
for ((i = 1; i <= 5; i++)); do
18+
echo "C-style loop iteration: $i"
19+
done
20+
selections:
21+
- anchor: {line: 1, character: 12}
22+
active: {line: 1, character: 12}
23+
marks:
24+
default.1:
25+
start: {line: 1, character: 12}
26+
end: {line: 1, character: 13}
27+
finalState:
28+
documentContents: |2
29+
# C-style for loop
30+
for ((i = ; i <= 5; i++)); do
31+
echo "C-style loop iteration: $i"
32+
done
33+
selections:
34+
- anchor: {line: 1, character: 12}
35+
active: {line: 1, character: 12}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
languageId: shellscript
2+
command:
3+
version: 6
4+
spokenForm: chuck name green sit
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
mark: {type: decoratedSymbol, symbolColor: green, character: i}
10+
modifiers:
11+
- type: containingScope
12+
scopeType: {type: name}
13+
usePrePhraseSnapshot: true
14+
initialState:
15+
documentContents: |2-
16+
# C-style for loop
17+
for ((i = 1; i <= 5; i++)); do
18+
echo "C-style loop iteration: $i"
19+
done
20+
selections:
21+
- anchor: {line: 1, character: 12}
22+
active: {line: 1, character: 12}
23+
marks:
24+
green.i:
25+
start: {line: 1, character: 8}
26+
end: {line: 1, character: 9}
27+
finalState:
28+
documentContents: |2-
29+
# C-style for loop
30+
for ((1; i <= 5; i++)); do
31+
echo "C-style loop iteration: $i"
32+
done
33+
selections:
34+
- anchor: {line: 1, character: 8}
35+
active: {line: 1, character: 8}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
languageId: shellscript
2+
command:
3+
version: 6
4+
spokenForm: chuck value one
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
mark: {type: decoratedSymbol, symbolColor: default, character: '1'}
10+
modifiers:
11+
- type: containingScope
12+
scopeType: {type: value}
13+
usePrePhraseSnapshot: true
14+
initialState:
15+
documentContents: |2
16+
# C-style for loop
17+
for ((i = 1; i <= 5; i++)); do
18+
echo "C-style loop iteration: $i"
19+
done
20+
selections:
21+
- anchor: {line: 1, character: 12}
22+
active: {line: 1, character: 12}
23+
marks:
24+
default.1:
25+
start: {line: 1, character: 12}
26+
end: {line: 1, character: 13}
27+
finalState:
28+
documentContents: |2
29+
# C-style for loop
30+
for ((i; i <= 5; i++)); do
31+
echo "C-style loop iteration: $i"
32+
done
33+
selections:
34+
- anchor: {line: 1, character: 9}
35+
active: {line: 1, character: 9}

queries/shellscript.scm

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,17 @@
270270
(#not-parent-type? @dummy declaration_command)
271271
)
272272

273+
;;!! for ((i = 1; i <= 5; i++)); do
274+
;;! ^
275+
;;! xxxx
276+
;;! -----
277+
(variable_assignment
278+
!name
279+
(variable_name) @name @_.trailing.start.startOf
280+
"="
281+
(_) @_.trailing.end.startOf
282+
) @_.domain
283+
273284
;;!! local foo="bar"
274285
;;! ^^^
275286
;;! xxxxxxxxxx
@@ -296,6 +307,21 @@
296307
(#not-parent-type? @dummy declaration_command)
297308
)
298309

310+
;;!! for ((i = 1; i <= 5; i++)); do
311+
;;! ^
312+
;;! xxxx
313+
;;! -----
314+
(
315+
(variable_assignment
316+
!name
317+
!value
318+
(_) @_.leading.start.endOf
319+
"="
320+
.
321+
(_) @value @_.leading.end.endOf
322+
) @_.domain
323+
)
324+
299325
(declaration_command
300326
"local" @_.domain.start.startOf
301327
(variable_assignment

0 commit comments

Comments
 (0)