gandm / language-babel

ES2017, flow, React JSX and GraphQL grammar and transpilation for ATOM
https://atom.io/packages/language-babel
MIT License
476 stars 83 forks source link

Arrow function definitions split over multiple lines not identified #366

Closed dane-johnson closed 7 years ago

dane-johnson commented 7 years ago

An arrow function definition that has newlines in the arguments list is not identified as a function in the syntax highlight.

screen shot 2017-05-15 at 10 01 04 am

gandm commented 7 years ago

Because grammars can't read ahead i have no idea this is an arrow function at the point of entry. For certain comma delimited arrow functions I make a 'probable guess' that it is an arrow function coming up but I've already parsed the name of the variable before I make this determination. So in your example above the arguments are scoped as function parameters but the variable holding the function is denoted as a storage var.

image

I will have a look to see if anything can be done to improve this but I'm not sure it is possible without undesirable side effects.

dane-johnson commented 7 years ago

I noticed a similar bug in the Coffeescript grammar as well

Just to be cheeky I made an issue there too. https://github.com/atom/language-coffee-script/issues/125

gandm commented 7 years ago

I can't fix this due to limitations beyond my control so i'll close this issue.

FlorianWendelborn commented 7 years ago

@gandm This issue comes up from time to time — perhaps we should add a "sticky" issue for this and flag it as "upstream bug"?