@@ -219,13 +219,18 @@ function local_bindings(expr, text, bindings = [], pos = 1, line = 1)
219
219
if scope != = nothing
220
220
expr. typ == CSTParser. Kw && return bindings
221
221
222
+ # destructure multiple returns
222
223
if ismultiplereturn (expr)
223
- # destructure multiple returns
224
- if expr. args != = nothing
225
- for arg in expr. args
226
- # don't update `pos` & `line`, i.e.: treat all the multiple returns at a same place
227
- local_bindings (arg, text, bindings, pos, line)
228
- end
224
+ for arg in expr. args
225
+ # don't update `pos` & `line`, i.e.: treat all the multiple returns as same
226
+ local_bindings (arg, text, bindings, pos, line)
227
+ end
228
+ # properly detect the parameters of a method with where clause: https://github.com/JunoLab/Juno.jl/issues/404
229
+ elseif iswhereclause (expr)
230
+ for arg in expr. args
231
+ local_bindings (arg, text, bindings, pos, line)
232
+ line += countlines (arg, text, pos)
233
+ pos += arg. fullspan
229
234
end
230
235
else
231
236
# find local binds in a scope
@@ -320,22 +325,26 @@ end
320
325
321
326
function scopeof (expr:: CSTParser.EXPR )
322
327
scope = CSTParser. scopeof (expr)
323
- if scope ≠ nothing
328
+ if scope != = nothing
324
329
return scope
325
330
else
326
331
# can remove this with CSTParser 0.6.3
327
332
if expr. typ == CSTParser. BinaryOpCall && expr. args[2 ]. kind == CSTParser. Tokens. ANON_FUNC
328
333
return :anon
329
334
end
330
335
331
- if expr. typ == CSTParser. Call && expr. parent ≠ nothing && scopeof (expr. parent) == nothing
336
+ if expr. typ == CSTParser. Call && expr. parent != = nothing && scopeof (expr. parent) == nothing
332
337
return :call
333
338
end
334
339
335
- if expr. typ == CSTParser. TupleH && expr. parent ≠ nothing && scopeof (expr. parent) == nothing
340
+ if expr. typ == CSTParser. TupleH && expr. parent != = nothing && scopeof (expr. parent) == nothing
336
341
return :tupleh
337
342
end
338
343
344
+ if iswhereclause (expr)
345
+ return :where
346
+ end
347
+
339
348
if expr. typ == CSTParser. MacroCall
340
349
return :macro
341
350
end
357
366
358
367
function ismultiplereturn (expr:: CSTParser.EXPR )
359
368
expr. typ === CSTParser. TupleH &&
360
- ! isempty (filter (a -> CSTParser. bindingof (a) != = nothing , expr. args))
369
+ expr. args != = nothing &&
370
+ ! isempty (filter (a -> CSTParser. bindingof (a) != = nothing , expr. args))
361
371
end
362
372
373
+ function iswhereclause (expr:: CSTParser.EXPR )
374
+ expr. typ === CSTParser. WhereOpCall &&
375
+ expr. parent != = nothing &&
376
+ expr. args != = nothing
377
+ end
363
378
364
379
"""
365
380
str_value(x::CSTParser.EXPR)
0 commit comments