|
| 1 | +;; |
1 | 2 | ;; Statements
|
| 3 | +;; |
2 | 4 |
|
3 | 5 | ;; Any top-level expression that isn't a comment is a statement
|
4 | 6 | (
|
|
51 | 53 | (_) @statement.iteration @value.iteration @name.iteration
|
52 | 54 | )
|
53 | 55 |
|
| 56 | +;; |
54 | 57 | ;; Conditionals
|
| 58 | +;; |
55 | 59 |
|
56 | 60 | ;;!! key = if a then b else c;
|
57 | 61 | ;;! ^^^^^^^^^^^^^^^^^^
|
|
79 | 83 | condition: (_) @condition
|
80 | 84 | ) @_.domain
|
81 | 85 |
|
| 86 | +;; |
82 | 87 | ;; Lists and maps
|
| 88 | +;; |
83 | 89 |
|
84 | 90 | ;;!! foo = [ a b c ];
|
85 | 91 | ;;! ^^^^^^^^^
|
|
103 | 109 | expression: (_) @_.trailing.end.startOf
|
104 | 110 | ) @_.domain
|
105 | 111 |
|
| 112 | +;; |
106 | 113 | ;; Strings
|
| 114 | +;; |
107 | 115 |
|
108 | 116 | ;;!! # foo
|
109 | 117 | ;;! ^^^^^
|
|
122 | 130 | (interpolation) @argumentOrParameter
|
123 | 131 | ) @_.iteration
|
124 | 132 |
|
| 133 | +;; |
125 | 134 | ;; Functions
|
| 135 | +;; |
126 | 136 |
|
127 | 137 | ;; Note for this part of the function, we identify is as lambda only
|
128 | 138 | ;;!! x = a: b: a + b;
|
|
154 | 164 | expression: (function_expression) @namedFunction.interior
|
155 | 165 | ) @namedFunction @functionName.domain
|
156 | 166 |
|
| 167 | +;; Calls to functions are a bit finicky, because of everything being curried lambdas |
| 168 | +( |
| 169 | + (apply_expression) @dummy @functionCall @argumentOrParameter.iteration |
| 170 | + (#not-parent-type? @functionCall apply_expression) |
| 171 | +) |
| 172 | + |
| 173 | +;; This is gross, but not sure how to do fuzzy matching against an unknown number of |
| 174 | +;; nested child nodes. Arbitrarily stopping at 5 args for now, as that ought to be enough |
| 175 | +;; arguments for anyone |
| 176 | +;; Args: |
| 177 | +;;!! mkHost a b c d e |
| 178 | +;;! ^ |
| 179 | +;;! xx |
| 180 | +;;! <*********> |
| 181 | +;;! Callee: |
| 182 | +;;!! mkHost a b c d e |
| 183 | +;;! ^^^^^^ |
| 184 | +;;! xxxxxxx |
| 185 | +;;! ---------------- |
| 186 | +;; The mkHost node looks like this: |
| 187 | +;; # (binding_set |
| 188 | +;; # binding: (binding |
| 189 | +;; # expression: (attrset_expression |
| 190 | +;; # (binding_set |
| 191 | +;; # binding: (binding |
| 192 | +;; # expression: (apply_expression |
| 193 | +;; # function: (apply_expression |
| 194 | +;; # function: (apply_expression |
| 195 | +;; # function: (variable_expression |
| 196 | +;; # name: (identifier) |
| 197 | +;; # ) |
| 198 | +(apply_expression |
| 199 | + [ |
| 200 | + (apply_expression |
| 201 | + function: (variable_expression |
| 202 | + name: (identifier) @functionCallee |
| 203 | + ) |
| 204 | + ) |
| 205 | + (apply_expression |
| 206 | + [ |
| 207 | + (apply_expression |
| 208 | + function: (variable_expression |
| 209 | + name: (identifier) @functionCallee |
| 210 | + ) |
| 211 | + ) |
| 212 | + (apply_expression |
| 213 | + [ |
| 214 | + (apply_expression |
| 215 | + function: (variable_expression |
| 216 | + name: (identifier) @functionCallee |
| 217 | + ) |
| 218 | + ) |
| 219 | + (apply_expression |
| 220 | + (apply_expression |
| 221 | + function: (variable_expression |
| 222 | + name: (identifier) @functionCallee |
| 223 | + ) |
| 224 | + ) |
| 225 | + ) |
| 226 | + ] |
| 227 | + ) |
| 228 | + ] |
| 229 | + ) |
| 230 | + ] |
| 231 | +) @_.domain |
| 232 | + |
| 233 | +;; Args: |
| 234 | +;;!! mkHost a |
| 235 | +;;! ^ |
| 236 | +;;! x |
| 237 | +;;! -------- |
| 238 | +;;! Callee: |
| 239 | +;;!! mkHost a |
| 240 | +;;! ^^^^^^ |
| 241 | +;;! xxxxxx |
| 242 | +;;! -------- |
157 | 243 | (apply_expression
|
158 |
| - function: (_) @functionCallee |
| 244 | + function: (variable_expression |
| 245 | + name: (identifier) @functionCallee |
| 246 | + ) |
159 | 247 | argument: (_) @argumentOrParameter
|
160 | 248 | ) @_.domain
|
161 | 249 |
|
162 |
| -(apply_expression) @functionCall |
| 250 | +(apply_expression |
| 251 | + argument: (_) @argumentOrParameter |
| 252 | +) |
| 253 | + |
163 | 254 | (function_expression
|
164 | 255 | (formals) @argumentOrParameter
|
165 | 256 | ) @_.domain
|
166 | 257 |
|
| 258 | +;; inherit is a built-in keyword, but is close enough to a function... |
| 259 | +;; Callee: |
| 260 | +;;!! inherit pkgs input output; |
| 261 | +;;! ^^^^^^^ |
| 262 | +;;! xxxxxxxx |
| 263 | +;;! ------------------------- |
| 264 | +;; Args: |
| 265 | +;;!! inherit pkgs input output; |
| 266 | +;;! ^^^^ |
| 267 | +;;! xxxxx |
| 268 | +;;! <*****************> |
| 269 | +(inherit |
| 270 | + "inherit" @functionCallee |
| 271 | + ( |
| 272 | + (inherited_attrs) @argumentOrParameter.iteration |
| 273 | + ) |
| 274 | +) @functionCall @_.domain |
| 275 | +(inherited_attrs |
| 276 | + attr: (_) @argumentOrParameter |
| 277 | +) |
| 278 | + |
| 279 | +;; |
167 | 280 | ;; Names and Values
|
| 281 | +;; |
168 | 282 |
|
169 | 283 | ;;!! a = 25;
|
170 | 284 | ;;! ^^
|
|
0 commit comments