atom / symbols-view

Jump to symbols in Atom
MIT License
164 stars 114 forks source link

Add es7 async functions to ctags #157

Closed thedaniel closed 8 years ago

thedaniel commented 8 years ago

@atom/feedback ...any reason not to add these to the symbols-view? I've been writing a lot of babelized classes with async/await lately and this definitely makes my life better.

thedaniel commented 8 years ago

Actually, this regex might not be quite right since it needs to support default parameters as well. will update...

joshaber commented 8 years ago

:heart:

lee-dohm commented 8 years ago

Sounds like a good idea to me :+1:

maxbrunsfeld commented 8 years ago

:+1:

thedaniel commented 8 years ago

I changed the second character class in the function parameter capture group to .+ because writing a giant highly specific character class seems unnecessary given how specific the rest of the regex is. It now matches all of the following strings:

async connectedToDB () {

async request (requestPath, _fetchOptions = {}, _options = {}) {

async write (key, record, timestamp) {

I'd love to hear why I shouldn't be using the bludgeon that is .+ because while my regex is strong it is not kung fu master level, but so far this ctags-config is working for me on a babelized js project.

lee-dohm commented 8 years ago

I'd love to hear why I shouldn't be using the bludgeon that is .+

I don't think it would be a big problem. Is there a reason you chose something other than the \([^)]*\) pattern for the parameter list like in the function version a couple lines previous?

mnquintana commented 8 years ago

Side note – it's a bit of a bummer that we can't reuse tokenization from the language- packages for generating symbols. :disappointed:

thedaniel commented 8 years ago

@lee-dohm we shouldn't omit ) because we can supply a function call as a default param (i doubt this is common, but it does transpile successfully in babel so...)

cf:

class Foo {
   async functionWithFunctionCallAsDefaultParam (foo, bar = baz()) {
  }
}
mnquintana commented 8 years ago

@thedaniel Whoa, can you stick any expression in a default param?

lee-dohm commented 8 years ago

Ah interesting. Thanks for clarifying @thedaniel :grinning:

thedaniel commented 8 years ago

merging, i really think .+ is fine but we can write out a large specific character class if we hit any bugs.