aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-12 19:01:28 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-12 19:01:28 +0100
commit02ba107bbf24b1d09e61f76bb64b7355076744c4 (patch)
tree4046c8840eb1e15704a9c195fe5ee54327799091
parent1944fc2c2b9ed5d9414afbc1b167e628d6e4e7f9 (diff)
parent8ee2926aa2be9ac0e658386b91617e6563cc5d71 (diff)
Merge #1265
1265: drop obsolete render test subcommand r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_cli/src/analysis_stats.rs4
-rw-r--r--crates/ra_cli/src/main.rs37
2 files changed, 7 insertions, 34 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs
index 86ee0cb63..e6b2b30c6 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_cli/src/analysis_stats.rs
@@ -7,9 +7,9 @@ use ra_syntax::AstNode;
7 7
8use crate::Result; 8use crate::Result;
9 9
10pub fn run(verbose: bool, only: Option<&str>) -> Result<()> { 10pub fn run(verbose: bool, path: &str, only: Option<&str>) -> Result<()> {
11 let db_load_time = Instant::now(); 11 let db_load_time = Instant::now();
12 let (db, roots) = BatchDatabase::load_cargo(".")?; 12 let (db, roots) = BatchDatabase::load_cargo(path)?;
13 println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed()); 13 println!("Database loaded, {} roots, {:?}", roots.len(), db_load_time.elapsed());
14 let analysis_time = Instant::now(); 14 let analysis_time = Instant::now();
15 let mut num_crates = 0; 15 let mut num_crates = 0;
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index 11790d2e7..038f5f3fe 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_cli/src/main.rs
@@ -1,11 +1,10 @@
1mod analysis_stats; 1mod analysis_stats;
2 2
3use std::{fs, io::Read, path::Path}; 3use std::io::Read;
4 4
5use clap::{App, Arg, SubCommand}; 5use clap::{App, Arg, SubCommand};
6use ra_ide_api::file_structure; 6use ra_ide_api::file_structure;
7use ra_syntax::{SourceFile, TreeArc, AstNode}; 7use ra_syntax::{SourceFile, TreeArc, AstNode};
8use tools::collect_tests;
9use flexi_logger::Logger; 8use flexi_logger::Logger;
10use ra_prof::profile; 9use ra_prof::profile;
11 10
@@ -15,17 +14,13 @@ fn main() -> Result<()> {
15 Logger::with_env().start()?; 14 Logger::with_env().start()?;
16 let matches = App::new("ra-cli") 15 let matches = App::new("ra-cli")
17 .setting(clap::AppSettings::SubcommandRequiredElseHelp) 16 .setting(clap::AppSettings::SubcommandRequiredElseHelp)
18 .subcommand(
19 SubCommand::with_name("render-test")
20 .arg(Arg::with_name("line").long("--line").required(true).takes_value(true))
21 .arg(Arg::with_name("file").long("--file").required(true).takes_value(true)),
22 )
23 .subcommand(SubCommand::with_name("parse").arg(Arg::with_name("no-dump").long("--no-dump"))) 17 .subcommand(SubCommand::with_name("parse").arg(Arg::with_name("no-dump").long("--no-dump")))
24 .subcommand(SubCommand::with_name("symbols")) 18 .subcommand(SubCommand::with_name("symbols"))
25 .subcommand( 19 .subcommand(
26 SubCommand::with_name("analysis-stats") 20 SubCommand::with_name("analysis-stats")
27 .arg(Arg::with_name("verbose").short("v")) 21 .arg(Arg::with_name("verbose").short("v"))
28 .arg(Arg::with_name("only").short("o").takes_value(true)), 22 .arg(Arg::with_name("only").short("o").takes_value(true))
23 .arg(Arg::with_name("path")),
29 ) 24 )
30 .get_matches(); 25 .get_matches();
31 match matches.subcommand() { 26 match matches.subcommand() {
@@ -43,18 +38,11 @@ fn main() -> Result<()> {
43 println!("{:?}", s); 38 println!("{:?}", s);
44 } 39 }
45 } 40 }
46 ("render-test", Some(matches)) => {
47 let file = matches.value_of("file").unwrap();
48 let file = Path::new(file);
49 let line: usize = matches.value_of("line").unwrap().parse()?;
50 let line = line - 1;
51 let (test, tree) = render_test(file, line)?;
52 println!("{}\n{}", test, tree);
53 }
54 ("analysis-stats", Some(matches)) => { 41 ("analysis-stats", Some(matches)) => {
55 let verbose = matches.is_present("verbose"); 42 let verbose = matches.is_present("verbose");
43 let path = matches.value_of("path").unwrap_or("");
56 let only = matches.value_of("only"); 44 let only = matches.value_of("only");
57 analysis_stats::run(verbose, only)?; 45 analysis_stats::run(verbose, path, only)?;
58 } 46 }
59 _ => unreachable!(), 47 _ => unreachable!(),
60 } 48 }
@@ -71,18 +59,3 @@ fn read_stdin() -> Result<String> {
71 ::std::io::stdin().read_to_string(&mut buff)?; 59 ::std::io::stdin().read_to_string(&mut buff)?;
72 Ok(buff) 60 Ok(buff)
73} 61}
74
75fn render_test(file: &Path, line: usize) -> Result<(String, String)> {
76 let text = fs::read_to_string(file)?;
77 let tests = collect_tests(&text);
78 let test = tests.into_iter().find(|(start_line, t)| {
79 *start_line <= line && line <= *start_line + t.text.lines().count()
80 });
81 let test = match test {
82 None => failure::bail!("No test found at line {} at {}", line, file.display()),
83 Some((_start_line, test)) => test,
84 };
85 let file = SourceFile::parse(&test.text);
86 let tree = file.syntax().debug_dump();
87 Ok((test.text, tree))
88}