jrsonnet icon indicating copy to clipboard operation
jrsonnet copied to clipboard

Generate imports graphs

Open cloneable opened this issue 2 years ago • 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.)

cloneable avatar Aug 13 '23 13:08 cloneable

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

CertainLach avatar Aug 13 '23 13:08 CertainLach

Upstream issue: https://github.com/google/jsonnet/issues/770

CertainLach avatar Aug 13 '23 13:08 CertainLach