CertainLach/jrsonnet

Generate imports graphs

Opened this issue · 2 comments

Hi!
Besides #116 I'd like to offer another feature: showing the imports graphs of defined imports and effective imports. For my demo tool I already managed to simply wrap the ImportResolver to track what's imported during evaluation. Good enough for the tool.

I also would like to show the entire imports graph of all potential imports. For that I think I have to walk the AST. My first idea was to re-use my ImportResolver implementation to parse the contents from load_file_contents and check for defined imports, but I can't distinguish between import, importstr and importbin at this point properly and things would get too hacky even for demo code.

Do you know of a good way to get the exhaustive imports graph? (Btw, I believe this too would be a useful feature to have in jrsonnet-cli.)

I have implemented such AST walker for running jrsonnet with imports in browser, but it is not good, and needs to be updated.
https://github.com/CertainLach/jrsonnet/blob/master/crates/jrsonnet-evaluator/src/async_import.rs

Upstream issue: google/jsonnet#770