ctags icon indicating copy to clipboard operation
ctags copied to clipboard

JavaScript: destructural binding

Open techee opened this issue 8 years ago • 3 comments

When playing with various languages I ran into this warning for this file:

https://github.com/facebook/react/blob/master/src/renderers/shared/fiber/ReactFiberBeginWork.js

It looks the code doesn't like lines like

var { findNextUnitOfWorkAtPriority } = require('ReactFiberPendingWork');

and the warning comes from

https://github.com/universal-ctags/ctags/blob/master/parsers/jscript.c#L1778

because the name tag isn't checked whether it's an identifier or something else - it's probably { in this case.

Not a js developer myself so leaving this to someone who knows the correct syntax.

techee avatar Sep 06 '16 16:09 techee

I also get this warning with array destructuring, i.e. this pattern : const [lang, setLang] = useState("en")

Strangehill avatar Apr 14 '20 07:04 Strangehill

https://github.com/universal-ctags/ctags/pull/2115 I found I tried to fix this issue once. https://github.com/universal-ctags/ctags/pull/2115/commits/e977d56e5cc0531651c80c1481928b791a3c3ade

Though I opened the pull request, the way to fix the issue in the pull request looks a bit tricky for me. In addition, as @Strangehill wrote, the fix doesn't handle the array destructuring.

I will fix this but I cannot say when. I have to finish rewriting R parser.

See also #2494.

masatake avatar Apr 14 '20 07:04 masatake

I'm working on this item. The code in my PC partially works.

$ cat /tmp/foo.js
cat /tmp/foo.js
var [a, b, ...rest] = [1, 2, 3];
$ ./ctags -o - /tmp/foo.js 
./ctags -o - /tmp/foo.js 
a	/tmp/foo.js	/^var [a, b, ...rest] = [1, 2, 3];$/;"	v
b	/tmp/foo.js	/^var [a, b, ...rest] = [1, 2, 3];$/;"	v
rest	/tmp/foo.js	/^var [a, b, ...rest] = [1, 2, 3];$/;"	v
$ 

masatake avatar Jul 09 '22 10:07 masatake