lejsue / symbols-navigator

Symbols navigator for Atom.io
MIT License
13 stars 3 forks source link

Some function symbols do not appear #5

Open wshito opened 7 years ago

wshito commented 7 years ago

Thanks for the great tool! I like the tree view of your package. However, I found some functions not being recognized by the package.

The symbols in the screen shot are sorted as it appears in the source. At the bottom in the navigator, there shows changeAnchorPart(arg_map). However, the source has five more functions after that. You can see in the screenshot that setJqueryMap() and toggleChat() are not displayed in the navigator.

The Atom version I use is 1.22.0 x64 on Mac. The Symbols navigator's version is 1.0.1. The UTF-8 JavaScript source: spa.shell.txt

screenshot

lejsue commented 7 years ago

Hi wshito,

Sorry for my late reply, I'm working on company's project and not to have much time for here. But I think I'll be available next month, and can pay more attention on this package.

Currently, this package is using universal-ctags (https://github.com/universal-ctags/ctags) to analyze all tags for functions, variables, classes, etc. And it seems that the native setting of universal-ctags is not enough, some tags will be missing. Maybe add a customized setting for universal-ctgas will solve it, but I haven't tested this. I'll try it next month!

Thanks for your report! And sorry for the inconvenience of missing tags!

lejsue commented 6 years ago

Hi wshito,

I added this into .ctags file which is in lib folder, then I can see other functions. --regex-JavaScript=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]*\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/,function/ But unfortunately, their scope are not correct. they should belong to spa.shell(). I'm still figuring out the solution.

Martinsos commented 6 years ago

Related to this, I was wondering if you support arrow functions, for example const foo = () => {}? I was also looking at official https://github.com/atom/symbols-view/issues/215 and they have not handled it yet it seems -> if you have it working that would be great.

lejsue commented 6 years ago

Hi Martinsos,

Yes, the official symbols-view is using ctags to do tag/symbol analysis, and not support modern Javascript.

In my package, I'm using universal-ctags, but it seems not well support arrow functions. Let me check if there is any update for this.

nickcombs32 commented 5 years ago

Hi lejsue, The regex above needs an asterisk for the given capture group in order to match function declarations (as opposed to function expressions):

(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]*\.)*))
>
(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]*\.)*))*

However, I feel like I'm missing something because only one of my function declarations needed this fix while the others matched either way.