This commit does a few different things, and largely finishes up the work started in #88, and #140.
First, analyze/analyses/paths.rs
has been divided into separate files for the paths
function itself, the emitting logic, and for the struct that represents an entry in the Paths
struct. Further, the logic for traversing the ir::Items
tree that was previously mixed into the emitting logic has been divided out into a separate function, create_entry
.
To be sure that this is all working correctly, I added some various tests as well, especially focusing on the max_paths
option. The expected output files were generated using the current master branch, to be sure that everything was behaving the same way before and after this change.
While doing this, I did notice an issue with the emit_csv
function, being that the meta root is printed in the path
field of a CSV record. Additionally, some items only display themselves in that field. In each of these cases, the field will instead be empty. Given that the meta root (iirc) is an internal abstraction, I think it is best left out of this command's output, especially if it is not shown in other formats.
Currently, summaries are not shown, but the code to do so is included in comments under a 'FIXME' note. Once this lands, following up by enabling these sections and updating the test cases should be very straightforward.
Minor sidenote: The output generated by emit_csv
would probably be most helpful if we made a change so that duplicate rows are not displayed. For now, I've considered that out of scope for this PR, and can open up a separate issue for that.