aboutsummaryrefslogtreecommitdiff
path: root/crates/tools/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-31 20:41:43 +0000
committerAleksey Kladov <[email protected]>2018-10-31 20:41:43 +0000
commit6be50f7d5de3737464853a589673375fc0cafa97 (patch)
tree2c6da7f3a1234c3f2fd3f330d2c9445953979598 /crates/tools/src
parent857c1650efdb51650458f9ec1119adaa49b34371 (diff)
Reformat all
Diffstat (limited to 'crates/tools/src')
-rw-r--r--crates/tools/src/lib.rs31
-rw-r--r--crates/tools/src/main.rs8
2 files changed, 19 insertions, 20 deletions
diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs
index 29c46c7c4..3387d0620 100644
--- a/crates/tools/src/lib.rs
+++ b/crates/tools/src/lib.rs
@@ -1,5 +1,5 @@
1extern crate itertools;
2extern crate failure; 1extern crate failure;
2extern crate itertools;
3extern crate teraron; 3extern crate teraron;
4 4
5use std::{ 5use std::{
@@ -7,10 +7,10 @@ use std::{
7 process::Command, 7 process::Command,
8}; 8};
9 9
10use itertools::Itertools;
11use failure::bail; 10use failure::bail;
11use itertools::Itertools;
12 12
13pub use teraron::{Mode, Verify, Overwrite}; 13pub use teraron::{Mode, Overwrite, Verify};
14 14
15pub type Result<T> = ::std::result::Result<T, failure::Error>; 15pub type Result<T> = ::std::result::Result<T, failure::Error>;
16 16
@@ -63,16 +63,8 @@ pub fn generate(mode: Mode) -> Result<()> {
63 let grammar = project_root().join(GRAMMAR); 63 let grammar = project_root().join(GRAMMAR);
64 let syntax_kinds = project_root().join(SYNTAX_KINDS); 64 let syntax_kinds = project_root().join(SYNTAX_KINDS);
65 let ast = project_root().join(AST); 65 let ast = project_root().join(AST);
66 teraron::generate( 66 teraron::generate(&syntax_kinds, &grammar, mode)?;
67 &syntax_kinds, 67 teraron::generate(&ast, &grammar, mode)?;
68 &grammar,
69 mode,
70 )?;
71 teraron::generate(
72 &ast,
73 &grammar,
74 mode,
75 )?;
76 Ok(()) 68 Ok(())
77} 69}
78 70
@@ -101,9 +93,18 @@ pub fn run(cmdline: &str, dir: &str) -> Result<()> {
101 93
102pub fn run_rustfmt(mode: Mode) -> Result<()> { 94pub fn run_rustfmt(mode: Mode) -> Result<()> {
103 run(&format!("rustup install {}", TOOLCHAIN), ".")?; 95 run(&format!("rustup install {}", TOOLCHAIN), ".")?;
104 run(&format!("rustup component add rustfmt-preview --toolchain {}", TOOLCHAIN), ".")?; 96 run(
97 &format!(
98 "rustup component add rustfmt-preview --toolchain {}",
99 TOOLCHAIN
100 ),
101 ".",
102 )?;
105 if mode == Verify { 103 if mode == Verify {
106 run(&format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN), ".")?; 104 run(
105 &format!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN),
106 ".",
107 )?;
107 } else { 108 } else {
108 run(&format!("rustup run {} -- cargo fmt", TOOLCHAIN), ".")?; 109 run(&format!("rustup run {} -- cargo fmt", TOOLCHAIN), ".")?;
109 } 110 }
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs
index 91675bbf0..dc623a464 100644
--- a/crates/tools/src/main.rs
+++ b/crates/tools/src/main.rs
@@ -1,19 +1,17 @@
1extern crate clap; 1extern crate clap;
2extern crate failure; 2extern crate failure;
3extern crate teraron;
3extern crate tools; 4extern crate tools;
4extern crate walkdir; 5extern crate walkdir;
5extern crate teraron;
6 6
7use clap::{App, Arg, SubCommand}; 7use clap::{App, Arg, SubCommand};
8use failure::bail;
8use std::{ 9use std::{
9 collections::HashMap, 10 collections::HashMap,
10 fs, 11 fs,
11 path::{Path, PathBuf}, 12 path::{Path, PathBuf},
12}; 13};
13use tools::{ 14use tools::{collect_tests, generate, run, run_rustfmt, Mode, Overwrite, Result, Test, Verify};
14 collect_tests, Result, Test, generate, Mode, Overwrite, Verify, run, run_rustfmt,
15};
16use failure::bail;
17 15
18const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar"; 16const GRAMMAR_DIR: &str = "./crates/ra_syntax/src/grammar";
19const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline"; 17const INLINE_TESTS_DIR: &str = "./crates/ra_syntax/tests/data/parser/inline";