Handle tagged templates more fluently
Here's an example with the parse:
taggedTemplate`hello ${firstName}`;
> program
>> expression_statement
>>> call_expression
>>>> arguments: template_string
>>>>> template_substitution
>>>>>> identifier
>>>>>> "firstName"
I wonder if the template_string could be referred to as a string, the function identifier as name and then each template_substitution as an argument.
Edit @pokey
We will do the following to handle this issue:
- [ ] #90
- [ ] #645
- [x] #646
Interesting. A couple thoughts / questions:
Can we not already refer to the template string as string? If not, that strikes me as a bug worth fixing
Using name for the function identifier feels like an abuse of name. name is generally used for the name of something being declared, so I'm not sure this use case is intuitive. I would lean towards using a new scope type called eg "callee", which we'd also use for the function being called in a regular call expression
Interesting idea to have template substitutions be "arguments", though it doesn't feel super intuitive to me. I'd be tempted to just use a new scope type as proposed in https://github.com/cursorless-dev/cursorless/issues/90, tho I do generally advocate for trying to fold scope types together where possible to reduce cognitive load
Can we not already refer to the template string as string? If not, that strikes me as a bug worth fixing
This is indeed a bug.
Using name for the function identifier feels like an abuse of name.
Agree.
Interesting idea to have template substitutions be "arguments", though it doesn't feel super intuitive to me. I'd be tempted to just use a new scope type as proposed in https://github.com/cursorless-dev/cursorless/issues/90, tho I do generally advocate for trying to fold scope types together where possible to reduce cognitive load
Under the hood, these are arguments for a tagged template. See MDN. There is definitely ambiguity though with regular template literals. Happy to follow your lead on this one.
It's an interesting idea to just use "arg" for any template literal as a solution to this problem as well as #90. wdyt @AndreasArvidsson
Argument sounds good to me
Ok I think we've come to a decision. I've updated the issue description; lmk if that doesn't seem right
This sounds great to me, thanks!