3 ms·
Regarding visualization of codebases, something I've wanted for a long time is a graph of function calls across an entire project. I want to know all the calle
by bern4444 4y ago
Regarding visualization of codebases, something I've wanted for a long time is a graph of function calls across an entire project.
I want to know all the callers and callees of every function. This shouldn't be too hard, we already have find references via LSP.
Turning this into a graph would make it significantly easier to manage the entry and exit points of a code base and inform architecture decisions, refactors, type checking, hot paths etc.
- avg_dev 4y agoThat’s a cool idea. I don’t know much about ASTs or anything but I know you are right about LSP being able to find most everything I am searching for in the mostly statically typed languages I’ve worked with. Would be fun to try that out over a weekend or three.
- kelsolaar 4y agoI have been looking for something like that for a while and your reply made me look again. I just came across Codemap (haven’t tried): https://codemap.app/ https://codemap.app/
- bern4444 4y agoThanks for sharing! This looks pretty close to what I had in mind.
- madelyn 4y agoI ended up doing this for our python codebases at work. The AST module was super handy as you'd expect. The script would optionally take some filters to reduce the size of the generated graph, and then it sent all the info to Graphiz (it emitted DOT, too, so it could be version controlled!!) It was extremely fun, highly recommended.
- 0x09 4y agoDoxygen has the ability to generate these with its CALL_GRAPH/CALLER_GRAPH config, at least from each function individually. It can look quite funny when the depth isn't limited: https://i.imgur.com/3LMV71N.png https://i.imgur.com/3LMV71N.png
- cheald 4y agoIt's coming at it from the wrong end, but I do a lot of this with kcachegrind, particularly for tracking down hot paths in Ruby, which is so dynamic that static analysis of nigh impossible. At least for the purposes of checking hot paths, it's quite useful.
- jcparkyn 4y agoThis isn't really what you're asking for, but since no-one else has mentioned it, the call hierarchy feature built into most IDEs gets about 50% of the way there. The obvious limitations are that this usually only works for one function at a time, and shows a tree not a graph.