CertainLach / jrsonnet

Rust implementation of Jsonnet language
MIT License
290 stars 33 forks source link

Generate imports graphs #128

Open cloneable opened 11 months ago

cloneable commented 11 months ago

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.)

CertainLach commented 11 months ago

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 commented 11 months ago

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