Question

My JS code is getting bigger and bigger and also older. This means that, while working on other projects, I tend to forget all the sequences in which I call my functions. I would like to know if there's a tool which can parse my .js file and produce a (simple) document in which each function has listed all the other function it call. This is just a static source code analysis; I don't need it to do anything at run time.

Overly simplified example:

function firstFunction(){
    ...
    secondFunction();
    thirdFunction(); 
}

function secondFunction(){
    ...
    thirdFunction(); 
}

function thirdFunction(){
    ...
    secondFunction();
    firstFunction(); 
}

The resulted (text) document would simply list the function calls (I don't care about format):

firstFunction: secondFunction, thirdFunction 
secondFunction: thirdFunction
thirdFunction: secondFunction, firstFunction

EDIT: please note that I would like not to change my code; I have tens of functions with some of them calling more than 10-15 other functions; printing messages before or after each function call would require to much time, both for writing and running each scenario.

EDIT no.2: I could do this with any basic text editor by selecting each function name and searching for instances of that name in the file; this method would require much more time and brain cells than I can afford right now; an automated tool would have been perfect.

No correct solution

OTHER TIPS

console.trace() works very well on Google Chrome. In addition console.log() could be handy, when console.log() is called, the stacktrace is also displayed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top