diff --git a/Cargo.lock b/Cargo.lock index 244c5bb..070db3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,7 +12,7 @@ dependencies = [ "rand", "rayon", "rnix", - "rowan 0.15.3", + "rowan", "termion", "tui", "walkdir", @@ -64,9 +64,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f1fea81f183005ced9e59cdb01737ef2423956dac5a6d731b06b2ecfaa3467" +checksum = "6d76c22c9b9b215eeb8d016ad3a90417bd13cb24cf8142756e6472445876cab7" dependencies = [ "atty", "bitflags", @@ -84,12 +84,6 @@ version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "328b822bdcba4d4e402be8d9adb6eebf269f969f8eadef977a553ff3c4fbcb58" -[[package]] -name = "countme" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03746e0c6dd9b5d2d9132ffe0bede35fb5f815604fd371bb42599fd37bc8e483" - [[package]] name = "crossbeam-channel" version = "0.5.2" @@ -163,12 +157,6 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -[[package]] -name = "hashbrown" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758" - [[package]] name = "hermit-abi" version = "0.1.19" @@ -344,7 +332,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "065c5eac8e8f7e7b0e7227bdc46e2d8dd7d69fff7a9a2734e21f686bbcb9b2c9" dependencies = [ "cbitset", - "rowan 0.12.6", + "rowan", "smol_str", ] @@ -354,26 +342,13 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1b36e449f3702f3b0c821411db1cbdf30fb451726a9456dce5dabcd44420043" dependencies = [ - "countme 2.0.4", + "countme", "hashbrown 0.9.1", "memoffset", "rustc-hash", "text-size", ] -[[package]] -name = "rowan" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c72a0c863fef62cfd9ca7b72a35b422d7672dbffac4ac8003dcc3be7837d871d" -dependencies = [ - "countme 3.0.0", - "hashbrown 0.12.0", - "memoffset", - "rustc-hash", - "text-size", -] - [[package]] name = "rustc-hash" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7440f5b..5a37bcb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ rayon = "*" rnix = "*" termion = "*" tui = { version = "*", default-features = false, features = ["termion"] } -rowan = "*" +rowan = "0.12.6" # follows rnix walkdir = "*" [package] diff --git a/src/cli.rs b/src/cli.rs index f3763c7..f8c9b08 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -2,13 +2,6 @@ pub fn parse(args: Vec) -> clap::ArgMatches { clap::Command::new("Alejandra") .about("The Uncompromising Nix Code Formatter.") .version(crate::version::VERSION) - .arg( - clap::Arg::new("debug") - .help("Enable debug mode.") - .long("debug") - .short('d') - .takes_value(false), - ) .arg( clap::Arg::new("paths") .help("Files or directories, or none to format stdin.") diff --git a/src/config.rs b/src/config.rs index 4bfd9ae..bbc823c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,28 +6,19 @@ pub enum Layout { #[derive(Clone)] pub struct Config { - debug: bool, layout: Layout, } impl Config { pub fn new() -> Config { - Config { debug: false, layout: Layout::Tall } - } - - pub fn debug(&self) -> bool { - self.debug + Config { layout: Layout::Tall } } pub fn layout(&self) -> &Layout { &self.layout } - pub fn with_debug(&self, debug: bool) -> Config { - Config { debug, layout: self.layout.clone() } - } - pub fn with_layout(&self, layout: Layout) -> Config { - Config { debug: self.debug, layout } + Config { layout } } } diff --git a/src/debug.rs b/src/debug.rs deleted file mode 100644 index 2e47842..0000000 --- a/src/debug.rs +++ /dev/null @@ -1,27 +0,0 @@ -pub fn display( - element: &rowan::NodeOrToken<&rowan::GreenNodeData, &rowan::GreenTokenData>, -) { - eprintln!("AST:"); - display_recursive(element, 2); -} - -fn display_recursive( - element: &rowan::NodeOrToken<&rowan::GreenNodeData, &rowan::GreenTokenData>, - depth: usize, -) { - let kind = unsafe { - std::mem::transmute::(element.kind().0) - }; - - match element { - rowan::NodeOrToken::Node(node) => { - eprintln!("{0:<1$}{2:?}", "", 2 * depth, kind); - for child in node.children() { - display_recursive(&child, depth + 1); - } - } - rowan::NodeOrToken::Token(token) => { - eprintln!("{0:<1$}{2:?} {3:?}", "", 2 * depth, kind, token.text()); - } - } -} diff --git a/src/format.rs b/src/format.rs index a03f059..0b725b9 100644 --- a/src/format.rs +++ b/src/format.rs @@ -14,10 +14,6 @@ pub fn string( let green_node = crate::builder::build(config, ast.node().into(), false, path).unwrap(); - if config.debug() { - crate::debug::display(&(&green_node).into()); - } - green_node.to_string() } diff --git a/src/lib.rs b/src/lib.rs index 61531a0..deae7f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,6 @@ pub mod builder; pub mod children; pub mod cli; pub mod config; -pub mod debug; pub mod find; pub mod format; pub mod position; diff --git a/src/main.rs b/src/main.rs index f4282cd..7fb15fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,7 @@ fn main() -> std::io::Result<()> { let matches = alejandra::cli::parse(std::env::args().collect()); - let debug: bool = matches.is_present("debug"); - let config = alejandra::config::Config::new().with_debug(debug); + let config = alejandra::config::Config::new(); match matches.values_of("paths") { Some(paths) => {