-
Notifications
You must be signed in to change notification settings - Fork 29
Grammar generator mishandles function arguments that span multiple lines #21
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Reproduced the problem in Safe Mode: http://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
- Followed all applicable steps in the debugging guide: http://flight-manual.atom.io/hacking-atom/sections/debugging/
- Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
- Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
- Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages
Description
If you create a typescript function with arguments on separate lines, they don't get the proper scopes associated with them and end up not getting highlighted correctly by the syntax theme.
Here's an example function that is highlighted correctly (because all of the args on the same line):

Here's an example of that same function but highlighted incorrectly (because of the args on different lines):

In looking at scopes, I see that the html created for the one-liner function declaration's first argument looks like:
<span class="syntax--variable syntax--parameter syntax--ts">arg1</span>
<span class="syntax--meta syntax--type syntax--annotation syntax--ts">
<span class="syntax--keyword syntax--operator syntax--type syntax--annotation syntax--ts">:</span>
<span class="syntax--support syntax--type syntax--primitive syntax--ts">number</span>
</span>and the first argument for the multi-line arguments looks like:
<span class="syntax--meta syntax--var syntax--expr syntax--ts">
<span class="leading-whitespace"> </span>
<span class="syntax--variable syntax--other syntax--readwrite syntax--ts">arg1</span>:
<span class="syntax--variable syntax--other syntax--readwrite syntax--ts">number</span>
<span class="syntax--punctuation syntax--separator syntax--comma syntax--ts">,</span>
</span>Which is clearly wrong.
Steps to Reproduce
- Create new typescript file with a function declaration, where the arguments are on separate lines (as seen above).
- Check if types are highlighted (or if you want to be thorough, compare scopes with a single line function).
Expected behavior: Arguments for a function that spans multiple lines should get the right scopes
Actual behavior: Arguments for a function that spans multiple lines are getting variable scopes instead of parameter scopes.
Reproduces how often: 💯
Versions
Atom: 1.27.1
Apm: 1.19.0
OS: Windows 10