scottrogowski / code2flow

Pretty good call graphs for dynamic languages
MIT License
3.92k stars 286 forks source link

How to handle functions inside a global object? #80

Open joedf opened 1 year ago

joedf commented 1 year ago

How can I get functions defined in a object like to be mapped out? Currently, they are being ignored... Here's some example code where MappedFunction() and anotherFunc() are succefully being included in the callgraph but nothing from Utils ... ? This was mostly done to keep the global namespace "clean"...

function MappedFunction(a, b, c) {
    anotherFunc();
    Utils.MyMethod1(1,2,3);
    Utils.MyMethod2(4,5,6);
}

const Utils = {
    MyMethod1: function(a, b, c) {
        // ...
        return value;
    },
    MyMethod2: function(a, b, c) {
        // ...
        return value;
    }
}
scott-c-h commented 1 year ago

This doesn't work for certain types of imports either.

from .my_module import utils
from .my_module import utils as mm_utils
from .my_module.utils import call3

def root():
  utils.call1()
  mm_utils.call2()
  call3()

only shows call3() in output.