Skip to content

Commit aef52e4

Browse files
author
fidgetingbits
committed
Fix overlapping if conditional domains
1 parent ca04ea4 commit aef52e4

File tree

1 file changed

+89
-19
lines changed

1 file changed

+89
-19
lines changed

queries/shellscript.scm

Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,102 @@
2525
;; Conditionals
2626
;;
2727

28-
;;!!
28+
(if_statement) @ifStatement @branch.iteration
29+
30+
;; Branch
31+
(
32+
(if_statement
33+
"if" @branch.start.startOf @branch.domain.start.startOf
34+
(_)
35+
"then"
36+
(_) @branch.interior @dummy
37+
"fi" @branch.end.startOf @branch.domain.end.startOf
38+
)
39+
(#not-type? @dummy elif_clause else_clause)
40+
)
41+
42+
;; Conditional
43+
44+
;;!! if [ $value -le 0 ]; then
45+
;;!! fi
2946
(if_statement
30-
(_)*
31-
"then"
32-
(_)*
47+
"if" @condition.domain.start.startOf
48+
(_) @condition
49+
"then" @condition.domain.end.endOf
50+
.
3351
"fi"
34-
) @ifStatement @branch
52+
)
3553

54+
;;!! if [ $value -le 0 ]; then
55+
;;!! else
3656
(if_statement
37-
"if" @branch.start.startOf
38-
(_)
39-
"then"
40-
(_)* @branch.interior
57+
"if" @condition.domain.start.startOf
58+
(_) @condition
59+
"then" @condition.domain.end.endOf
4160
.
42-
[
43-
(elif_clause)
44-
(else_clause)
45-
] @branch.end.startOf
46-
) @ifStatement @branch.iteration @_.domain
61+
(else_clause)
62+
)
63+
64+
;;!! if [ $value -le 0 ]; then
65+
;;!! elif
66+
(if_statement
67+
"if" @condition.domain.start.startOf
68+
(_) @condition
69+
"then" @condition.domain.end.endOf
70+
.
71+
(elif_clause)
72+
)
73+
74+
;;!! if [ $value -le 0 ]; then
75+
;;!! echo foo
76+
;;!! fi
77+
(
78+
(if_statement
79+
"if" @condition.domain.start.startOf
80+
(_) @condition
81+
"then"
82+
(_) @dummy
83+
.
84+
"fi" @condition.domain.end.startOf
85+
)
86+
(#not-type? @dummy else_clause elif_clause)
87+
)
88+
89+
;;!! if [ $value -le 0 ]; then
90+
;;!! echo foo
91+
;;!! elif [ $value -le 0 ]; then
92+
;;!! fi
93+
(
94+
(if_statement
95+
"if" @condition.domain.start.startOf
96+
(_) @condition
97+
"then"
98+
(_)
99+
(elif_clause) @condition.domain.end.startOf
100+
)
101+
)
102+
103+
;;!! if [ $value -le 0 ]; then
104+
;;!! echo foo
105+
;;!! else [ $value -le 0 ]; then
106+
;;!! fi
107+
(
108+
(if_statement
109+
"if" @condition.domain.start.startOf
110+
(_) @condition
111+
"then"
112+
(_) @dummy
113+
.
114+
(else_clause) @condition.domain.end.startOf
115+
)
116+
(#not-type? @dummy elif_clause)
117+
)
47118

48119
(elif_clause
49-
(_)* @condition
120+
(_) @condition
50121
"then"
51-
(_)* @branch.interior
52-
) @branch
122+
(_) @branch.interior
123+
) @branch @_.domain
53124

54125
(else_clause
55126
"else" @branch.interior.start.endOf
@@ -58,9 +129,8 @@
58129

59130
(_
60131
condition: (_) @condition
61-
) @_.domain
132+
)
62133

63-
;;
64134
;; Lists and maps
65135
;;
66136

0 commit comments

Comments
 (0)