-
-
Notifications
You must be signed in to change notification settings - Fork 91
Description
For a formal arguments we use the entire function as the iteration scope to main:
cursorless/data/fixtures/scopes/javascript.core/argument.formal.iteration.scope
Lines 8 to 10 in 8231890
[Domain] = 0:0-0:29 | |
>-----------------------------< | |
0| function myFunk(aaa, bbb) { } |
But for actual arguments we only use the argument list (including parentheses):
cursorless/data/fixtures/scopes/javascript.core/argument.actual.iteration.scope
Lines 8 to 10 in 8231890
[Domain] = 0:3-0:13 | |
>----------< | |
0| aaa(bbb, ccc); |
I can't remember the discussion around this decision, but I think the reason why the actual argument domain doesn't include the function name is the case when you have a function call as an argument:
foo(|bar(1), baz(2))
"every arg"
refers to bar(1)
and baz(2)
today, but if bar
was part of the iteration domain the result would just have been just 1
instead.
That is of course useful. On the other hand it creates an inconsistency and you can always use item
instead of arg
. Maybe the fact that item and argument does the same thing in this case is an indication that argument is not correct according to the syntax tree?
Also in this scenario I think people would be surprised what "every arg"
refers to.
function foo(value: number) {
b|ar(1, 2, 3);
}