6

I can't seem to find a basic piece of tooling which is a static analyzer that shows me which pieces of code use methods from which other pieces. I could even do with a very primitive one that only shows me which source files contain references to names found in other files in a NodeJS project (still using CJS require here). So far all I have found is a couple of abandoned projects, but one should think there simply must be something out there.

Edit: Graphical output is not required (but certainly a plus); what I primarily need is a tabulation (text) of which functions in which module call functions from which other modules so I can order dependencies.

Sublime text has this feature where when you hover over a name you get the location where that name was defined; this even works across modules and with CoffeeScript. Does anybody know how that is implemented?

2
  • Take a look at ESLint, I'm pretty sure it can do what you need. Commented May 25, 2021 at 7:00
  • Thanks for the tip but how? I cannot find an obvious way to get a call graph out of ESLint. Commented May 25, 2021 at 8:41

2 Answers 2

1

This is an actively maintained proprietary call graph generator that supports multiple languages.

Usage : callGraph <files> <options>

https://github.com/koknat/callGraph

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the suggestion, callGraph works in principle, even though I'm still grappling with adapting its RegExen to suit my use case. The biggest downside though is that it only outputs a huge map generated with GraphViz with methods from different files all over the place which is in fact much harder to grasp than looking through the sources.
Thanks, but I'm afraid this paper about comparative dynamic call graph generation is only tangentially related.
1

I’ve been looking for a similar tool to help my team track the indirect usage of a deprecated function, so I ended up writing a script based on the ts-morph module: https://gist.github.com/adrienjoly/fc117b187f87cca3417abc4a8433e3a2

It’s a node.js CLI that generates the call tree (a.k.a. call hierarchy, or dependency graph) of a function. You can probably modify it to support JavaScript projects. Or create a tsconfig.Json file that includes your JavaScript files.

Hope this helps!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.