1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
use std::fmt::Write; use log::trace; use petgraph::graph::NodeIndex; use ra_ap_hir as hir; use ra_ap_ide::RootDatabase; pub use crate::options::generate::tree::Options; use crate::{ graph::Graph, printer::tree::{Options as PrinterOptions, Printer}, }; pub struct Command { #[allow(dead_code)] options: Options, } impl Command { pub fn new(options: Options) -> Self { Self { options } } #[doc(hidden)] pub fn run( &self, graph: &Graph, start_node_idx: NodeIndex, _member_krate: hir::Crate, _db: &RootDatabase, ) -> anyhow::Result<()> { trace!("Printing ..."); let printer = { let printer_options = PrinterOptions {}; Printer::new(printer_options) }; let mut string = String::new(); writeln!(&mut string)?; printer.fmt(&mut string, graph, start_node_idx)?; print!("{}", string); Ok(()) } }