diff options
author | Aleksey Kladov <[email protected]> | 2020-02-18 12:30:40 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-18 12:30:40 +0000 |
commit | d05480a178b132e62b8aff8986a8cb3dd3a89c0b (patch) | |
tree | 0fc36373073a66c2bbd6c7cfae6cb734527d847f /crates/ra_lsp_server/src/cli.rs | |
parent | 2768476e491d985317b08230824f96e6718f338a (diff) | |
parent | 865759925be6b72f7ef39124ed0e4c86c0412a69 (diff) |
Merge pull request #3216 from matklad/rename-to-rust-analyzer
rename binary to rust-analyzer
Diffstat (limited to 'crates/ra_lsp_server/src/cli.rs')
-rw-r--r-- | crates/ra_lsp_server/src/cli.rs | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/crates/ra_lsp_server/src/cli.rs b/crates/ra_lsp_server/src/cli.rs deleted file mode 100644 index c9738d101..000000000 --- a/crates/ra_lsp_server/src/cli.rs +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | //! Various batch processing tasks, intended primarily for debugging. | ||
2 | |||
3 | mod load_cargo; | ||
4 | mod analysis_stats; | ||
5 | mod analysis_bench; | ||
6 | mod progress_report; | ||
7 | |||
8 | use std::io::Read; | ||
9 | |||
10 | use anyhow::Result; | ||
11 | use ra_ide::{file_structure, Analysis}; | ||
12 | use ra_prof::profile; | ||
13 | use ra_syntax::{AstNode, SourceFile}; | ||
14 | |||
15 | #[derive(Clone, Copy)] | ||
16 | pub enum Verbosity { | ||
17 | Spammy, | ||
18 | Verbose, | ||
19 | Normal, | ||
20 | Quiet, | ||
21 | } | ||
22 | |||
23 | impl Verbosity { | ||
24 | pub fn is_verbose(self) -> bool { | ||
25 | match self { | ||
26 | Verbosity::Verbose | Verbosity::Spammy => true, | ||
27 | _ => false, | ||
28 | } | ||
29 | } | ||
30 | pub fn is_spammy(self) -> bool { | ||
31 | match self { | ||
32 | Verbosity::Spammy => true, | ||
33 | _ => false, | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | |||
38 | pub fn parse(no_dump: bool) -> Result<()> { | ||
39 | let _p = profile("parsing"); | ||
40 | let file = file()?; | ||
41 | if !no_dump { | ||
42 | println!("{:#?}", file.syntax()); | ||
43 | } | ||
44 | std::mem::forget(file); | ||
45 | Ok(()) | ||
46 | } | ||
47 | |||
48 | pub fn symbols() -> Result<()> { | ||
49 | let file = file()?; | ||
50 | for s in file_structure(&file) { | ||
51 | println!("{:?}", s); | ||
52 | } | ||
53 | Ok(()) | ||
54 | } | ||
55 | |||
56 | pub fn highlight(rainbow: bool) -> Result<()> { | ||
57 | let (analysis, file_id) = Analysis::from_single_file(read_stdin()?); | ||
58 | let html = analysis.highlight_as_html(file_id, rainbow).unwrap(); | ||
59 | println!("{}", html); | ||
60 | Ok(()) | ||
61 | } | ||
62 | |||
63 | pub use analysis_bench::{analysis_bench, BenchWhat, Position}; | ||
64 | pub use analysis_stats::analysis_stats; | ||
65 | |||
66 | fn file() -> Result<SourceFile> { | ||
67 | let text = read_stdin()?; | ||
68 | Ok(SourceFile::parse(&text).tree()) | ||
69 | } | ||
70 | |||
71 | fn read_stdin() -> Result<String> { | ||
72 | let mut buff = String::new(); | ||
73 | std::io::stdin().read_to_string(&mut buff)?; | ||
74 | Ok(buff) | ||
75 | } | ||