scottrogowski / code2flow

Pretty good call graphs for dynamic languages
MIT License
4.01k stars 296 forks source link

[javascript] Cannot resolve `Destructuring Assignment` for `new` object #77

Open ZLY201 opened 1 year ago

ZLY201 commented 1 year ago

It can resolve:

const { host, protocol } = URL(origin);

and

const url = new URL(origin);

but when I use:

const { host, protocol } = new URL(origin);

It caught an error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/code2flow", line 8, in <module>
    sys.exit(main())
  File "/opt/homebrew/lib/python3.10/site-packages/code2flow/engine.py", line 860, in main
    code2flow(
  File "/opt/homebrew/lib/python3.10/site-packages/code2flow/engine.py", line 734, in code2flow
    file_groups, all_nodes, edges = map_it(sources, language, no_trimming,
  File "/opt/homebrew/lib/python3.10/site-packages/code2flow/engine.py", line 478, in map_it
    file_group = make_file_group(file_ast_tree, source, extension)
  File "/opt/homebrew/lib/python3.10/site-packages/code2flow/engine.py", line 356, in make_file_group
    for new_node in language.make_nodes(node_tree, parent=file_group):
  File "/opt/homebrew/lib/python3.10/site-packages/code2flow/javascript.py", line 354, in make_nodes
    variables = make_local_variables(this_scope_body, parent)
  File "/opt/homebrew/lib/python3.10/site-packages/code2flow/javascript.py", line 193, in make_local_variables
    variables += process_assign(element)
  File "/opt/homebrew/lib/python3.10/site-packages/code2flow/javascript.py", line 134, in process_assign
    token = target['id']['name']
KeyError: 'name'
ZLY201 commented 1 year ago

@scottrogowski Do you have time to have a look? https://github.com/scottrogowski/code2flow/pull/78