1
1
mod analysis_stats;
2
2
3
- use std:: { fs , io:: Read , path :: Path } ;
3
+ use std:: io:: Read ;
4
4
5
5
use clap:: { App , Arg , SubCommand } ;
6
6
use ra_ide_api:: file_structure;
7
7
use ra_syntax:: { SourceFile , TreeArc , AstNode } ;
8
- use tools:: collect_tests;
9
8
use flexi_logger:: Logger ;
10
9
use ra_prof:: profile;
11
10
@@ -15,17 +14,13 @@ fn main() -> Result<()> {
15
14
Logger :: with_env ( ) . start ( ) ?;
16
15
let matches = App :: new ( "ra-cli" )
17
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
17
. subcommand ( SubCommand :: with_name ( "parse" ) . arg ( Arg :: with_name ( "no-dump" ) . long ( "--no-dump" ) ) )
24
18
. subcommand ( SubCommand :: with_name ( "symbols" ) )
25
19
. subcommand (
26
20
SubCommand :: with_name ( "analysis-stats" )
27
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
25
. get_matches ( ) ;
31
26
match matches. subcommand ( ) {
@@ -43,18 +38,11 @@ fn main() -> Result<()> {
43
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
41
( "analysis-stats" , Some ( matches) ) => {
55
42
let verbose = matches. is_present ( "verbose" ) ;
43
+ let path = matches. value_of ( "path" ) . unwrap_or ( "" ) ;
56
44
let only = matches. value_of ( "only" ) ;
57
- analysis_stats:: run ( verbose, only) ?;
45
+ analysis_stats:: run ( verbose, path , only) ?;
58
46
}
59
47
_ => unreachable ! ( ) ,
60
48
}
@@ -71,18 +59,3 @@ fn read_stdin() -> Result<String> {
71
59
:: std:: io:: stdin ( ) . read_to_string ( & mut buff) ?;
72
60
Ok ( buff)
73
61
}
74
-
75
- fn 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
- }
0 commit comments