|
2 | 2 | ;; Statements
|
3 | 3 | ;;
|
4 | 4 |
|
5 |
| -(program |
| 5 | +( |
| 6 | + (program |
6 | 7 | (_) @statement
|
| 8 | + ) |
| 9 | + (#not-type? @statement comment) |
7 | 10 | )
|
8 | 11 | [
|
9 |
| - (if_statement) |
10 |
| - (command) |
11 |
| - (function_definition) |
12 |
| - (variable_assignment) |
| 12 | + (if_statement) |
| 13 | + (command) |
| 14 | + (function_definition) |
| 15 | + (declaration_command) |
13 | 16 | ] @statement
|
14 | 17 |
|
| 18 | +( |
| 19 | + (_ |
| 20 | + (variable_assignment) @statement |
| 21 | + (#not-parent-type? @statement declaration_command) |
| 22 | + ) |
| 23 | +) |
| 24 | + |
15 | 25 | ;;
|
16 | 26 | ;; Conditionals
|
17 | 27 | ;;
|
18 | 28 |
|
19 | 29 | ;;!!
|
20 | 30 | (if_statement
|
21 |
| - (_)* |
22 |
| - "then" |
23 |
| - (_)* |
24 |
| - "fi" |
| 31 | + (_)* |
| 32 | + "then" |
| 33 | + (_)* |
| 34 | + "fi" |
25 | 35 | ) @ifStatement @branch
|
26 | 36 |
|
27 | 37 | (if_statement
|
28 |
| - "if" @branch.start.startOf |
29 |
| - (_) |
30 |
| - "then" |
31 |
| - (_)* @branch.interior |
32 |
| - . |
33 |
| - [ |
34 |
| - (elif_clause) |
35 |
| - (else_clause) |
36 |
| - ] @branch.end.startOf |
| 38 | + "if" @branch.start.startOf |
| 39 | + (_) |
| 40 | + "then" |
| 41 | + (_)* @branch.interior |
| 42 | + . |
| 43 | + [ |
| 44 | + (elif_clause) |
| 45 | + (else_clause) |
| 46 | + ] @branch.end.startOf |
37 | 47 | ) @ifStatement @branch.iteration @_.domain
|
38 | 48 |
|
39 | 49 | (elif_clause
|
40 |
| - (_)* @condition |
41 |
| - "then" |
42 |
| - (_)* @branch.interior |
| 50 | + (_)* @condition |
| 51 | + "then" |
| 52 | + (_)* @branch.interior |
43 | 53 | ) @branch
|
44 | 54 |
|
45 | 55 | (else_clause
|
46 |
| - "else" @branch.interior.start.endOf |
47 |
| - (_) @branch.interior.end.endOf |
| 56 | + "else" @branch.interior.start.endOf |
| 57 | + (_) @branch.interior.end.endOf |
48 | 58 | ) @branch
|
49 | 59 |
|
50 | 60 | (_
|
51 |
| - condition: (_) @condition |
| 61 | + condition: (_) @condition |
52 | 62 | ) @_.domain
|
53 | 63 |
|
54 | 64 | ;;
|
|
59 | 69 | ;;! ^^^^^^^^^^^^^
|
60 | 70 | ;;! -------------
|
61 | 71 | (array
|
62 |
| - "(" @_.interior.start.endOf |
63 |
| - (_)? @collectionItem |
64 |
| - ")" @_.interior.end.startOf |
65 |
| -) @list |
| 72 | + "(" @_.interior.start.endOf |
| 73 | + (_)? @collectionItem |
| 74 | + ")" @_.interior.end.startOf |
| 75 | +) @list @collectionItem.iteration |
66 | 76 |
|
67 | 77 | ;;
|
68 | 78 | ;; Strings
|
|
74 | 84 |
|
75 | 85 | ;;!! var="foo"
|
76 | 86 | ;;! ^^^^^
|
77 |
| -(string) @string @textFragment @argumentOrParameter.iteration |
| 87 | +(string) @string @textFragment |
78 | 88 |
|
79 | 89 | ;;!! var="foo ${bar}"
|
80 | 90 | ;;! ^^^^^^
|
81 | 91 | (string
|
82 |
| - [ |
83 |
| - (expansion) |
84 |
| - (simple_expansion) |
85 |
| - ] @argumentOrParameter |
| 92 | + [ |
| 93 | + (expansion) |
| 94 | + (simple_expansion) |
| 95 | + ] @argumentOrParameter |
86 | 96 | )
|
87 | 97 |
|
88 | 98 | ;;
|
|
92 | 102 | ;;!! echo "foo"
|
93 | 103 | ;;! ^^^^^
|
94 | 104 | (_
|
95 |
| - argument: (_) @argumentOrParameter |
96 |
| -) @_.iterator |
| 105 | + argument: (_) @argumentOrParameter |
| 106 | +) @_.iteration |
97 | 107 |
|
98 | 108 | ;; call:
|
99 | 109 | ;;!! echo "foo"
|
|
103 | 113 | ;;! ^^^^
|
104 | 114 | ;;! ----------
|
105 | 115 | (command
|
106 |
| - name: (_) @functionCallee |
107 |
| -) @_.domain @functionCall |
| 116 | + name: (_) @functionCallee |
| 117 | +) @_.domain @functionCall @command |
108 | 118 |
|
109 | 119 | ;;!! function foo() {
|
110 | 120 | ;;! ^^^
|
|
114 | 124 | ;;!! }
|
115 | 125 | ;;! -
|
116 | 126 | (function_definition
|
117 |
| - name: (_) @functionName |
| 127 | + name: (_) @functionName |
118 | 128 | ) @_.domain
|
119 | 129 |
|
120 | 130 | ;; FIXME: Need to support redirections
|
|
127 | 137 | ;;!! }
|
128 | 138 | ;;! -
|
129 | 139 | (function_definition
|
130 |
| - body: (_ |
131 |
| - "{" |
132 |
| - . |
133 |
| - (_)? @_.interior |
134 |
| - . |
135 |
| - "}" |
136 |
| - ) |
| 140 | + body: (_ |
| 141 | + "{" |
| 142 | + . |
| 143 | + (_)? @_.interior |
| 144 | + . |
| 145 | + "}" |
| 146 | + ) |
137 | 147 | ) @namedFunction @_.domain
|
138 | 148 |
|
139 | 149 | ;;
|
|
144 | 154 | ;;! ^^^
|
145 | 155 | ;;! xxxx
|
146 | 156 | ;;! ---------
|
147 |
| -(variable_assignment |
| 157 | +( |
| 158 | + (variable_assignment |
148 | 159 | name: (_) @name @_.trailing.start.startOf
|
149 | 160 | .
|
150 | 161 | "=" @_.trailing.end.endOf
|
151 |
| -) @_.domain |
| 162 | + ) @dummy @_.domain |
| 163 | + (#not-parent-type? @dummy declaration_command) |
| 164 | +) |
| 165 | + |
| 166 | +;;!! local foo="bar" |
| 167 | +;;! ^^^ |
| 168 | +;;! xxxxxxxxxx |
| 169 | +;;! --------------- |
| 170 | +(declaration_command |
| 171 | + "local" @_.domain.start.startOf @_.trailing.start.startOf |
| 172 | + (variable_assignment |
| 173 | + name: (_) @name |
| 174 | + . |
| 175 | + "=" @_.trailing.end.endOf |
| 176 | + ) @_.domain.end.endOf |
| 177 | +) |
152 | 178 |
|
153 | 179 | ;;!! foo="bar"
|
154 | 180 | ;;! ^^^^^
|
155 | 181 | ;;! xxxxxx
|
156 | 182 | ;;! ---------
|
157 | 183 | (variable_assignment
|
158 |
| - "=" @value.leading.start.startOf |
159 |
| - . |
160 |
| - value: (_) @value @value.leading.end.endOf |
| 184 | + "=" @value.leading.start.startOf |
| 185 | + . |
| 186 | + value: (_) @value @value.leading.end.endOf |
161 | 187 | ) @_.domain
|
0 commit comments