diff options
author | Aleksey Kladov <[email protected]> | 2019-05-12 18:55:17 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-05-12 19:00:04 +0100 |
commit | 8ee2926aa2be9ac0e658386b91617e6563cc5d71 (patch) | |
tree | c7fa74cbecd55426686b50679c9a7eef09887b7f /crates/ra_cli | |
parent | 915489714baefac71f9dcc6c42c20a02645d7e23 (diff) |
drop obsolete render test subcommand
Diffstat (limited to 'crates/ra_cli')
-rw-r--r-- | crates/ra_cli/src/main.rs | 31 |
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 @@ | |||
1 | mod analysis_stats; | 1 | mod analysis_stats; |
2 | 2 | ||
3 | use std::{fs, io::Read, path::Path}; | 3 | use std::io::Read; |
4 | 4 | ||
5 | use clap::{App, Arg, SubCommand}; | 5 | use clap::{App, Arg, SubCommand}; |
6 | use ra_ide_api::file_structure; | 6 | use ra_ide_api::file_structure; |
7 | use ra_syntax::{SourceFile, TreeArc, AstNode}; | 7 | use ra_syntax::{SourceFile, TreeArc, AstNode}; |
8 | use tools::collect_tests; | ||
9 | use flexi_logger::Logger; | 8 | use flexi_logger::Logger; |
10 | use ra_prof::profile; | 9 | use 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 | |||
77 | fn 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 | } | ||