aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_cli/src/main.rs31
1 files changed, 1 insertions, 30 deletions
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index 5a8136823..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,11 +14,6 @@ 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(
@@ -44,14 +38,6 @@ fn main() -> Result<()> {
44 println!("{:?}", s); 38 println!("{:?}", s);
45 } 39 }
46 } 40 }
47 ("render-test", Some(matches)) => {
48 let file = matches.value_of("file").unwrap();
49 let file = Path::new(file);
50 let line: usize = matches.value_of("line").unwrap().parse()?;
51 let line = line - 1;
52 let (test, tree) = render_test(file, line)?;
53 println!("{}\n{}", test, tree);
54 }
55 ("analysis-stats", Some(matches)) => { 41 ("analysis-stats", Some(matches)) => {
56 let verbose = matches.is_present("verbose"); 42 let verbose = matches.is_present("verbose");
57 let path = matches.value_of("path").unwrap_or(""); 43 let path = matches.value_of("path").unwrap_or("");
@@ -73,18 +59,3 @@ fn read_stdin() -> Result<String> {
73 ::std::io::stdin().read_to_string(&mut buff)?; 59 ::std::io::stdin().read_to_string(&mut buff)?;
74 Ok(buff) 60 Ok(buff)
75} 61}
76
77fn render_test(file: &Path, line: usize) -> Result<(String, String)> {
78 let text = fs::read_to_string(file)?;
79 let tests = collect_tests(&text);
80 let test = tests.into_iter().find(|(start_line, t)| {
81 *start_line <= line && line <= *start_line + t.text.lines().count()
82 });
83 let test = match test {
84 None => failure::bail!("No test found at line {} at {}", line, file.display()),
85 Some((_start_line, test)) => test,
86 };
87 let file = SourceFile::parse(&test.text);
88 let tree = file.syntax().debug_dump();
89 Ok((test.text, tree))
90}