diff options
Diffstat (limited to 'src/bin/annotaterust.rs')
-rw-r--r-- | src/bin/annotaterust.rs | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/src/bin/annotaterust.rs b/src/bin/annotaterust.rs index 8a85563..3ecc023 100644 --- a/src/bin/annotaterust.rs +++ b/src/bin/annotaterust.rs @@ -1,10 +1,13 @@ -use std::{env, io}; +use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::process; -use std::collections::HashMap; +use std::{env, io}; + +use syn::visit::Visit; -use annotate_rust::{git, annotate::Annotation}; +use annotate_rust::annotate::{Annotation, FnVisitor}; +use annotate_rust::git; fn main() { let mut args = env::args(); @@ -26,24 +29,34 @@ fn main() { let syntax = syn::parse_file(&src).expect("Unable to parse file"); println!("{:#?}", syntax); + // Visit function invocations + let mut visitor = FnVisitor; + visitor.visit_file(&syntax); + let output = git::crawl_git_tree(".").expect("git"); let blobs = git::parse_ls_tree_output(&output).expect("parse"); let mut annotations = HashMap::new(); - annotations.entry(blobs[0].object).or_insert(Vec::new()).push(Annotation::Markdown { - lineno: 1, - title: "Title".to_string(), - content: "content".to_string() - }); - annotations.entry(blobs[0].object).or_insert(Vec::new()).push(Annotation::Link { - lineno: 1, - colno: 0, - len: 5, - to: "asdf".to_string(), - title: None, - color: None - }); + annotations + .entry(blobs[0].object) + .or_insert(Vec::new()) + .push(Annotation::Markdown { + lineno: 1, + title: "Title".to_string(), + content: "content".to_string(), + }); + annotations + .entry(blobs[0].object) + .or_insert(Vec::new()) + .push(Annotation::Link { + lineno: 1, + colno: 0, + len: 5, + to: "asdf".to_string(), + title: None, + color: None, + }); let stdout = io::stdout(); - serde_json::to_writer_pretty(stdout, &annotations).expect("json"); + serde_json::to_writer(stdout, &annotations).expect("json"); } |