aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-17 18:03:03 +0000
committerAleksey Kladov <[email protected]>2020-02-17 18:03:03 +0000
commit659b0e73cfd9ef7755d032f90622a08576f1d86d (patch)
tree238a2cb3e021502608d357785ebbe3b21f94573f
parent2d1b3da5fb69d932c65884a361ec10d81e8a51d8 (diff)
Merge cli and ra_lsp_server
-rw-r--r--Cargo.lock32
-rw-r--r--crates/ra_cli/Cargo.toml31
-rw-r--r--crates/ra_lsp_server/Cargo.toml11
-rw-r--r--crates/ra_lsp_server/src/args.rs (renamed from crates/ra_cli/src/main.rs)155
-rw-r--r--crates/ra_lsp_server/src/cli.rs75
-rw-r--r--crates/ra_lsp_server/src/cli/analysis_bench.rs (renamed from crates/ra_cli/src/analysis_bench.rs)39
-rw-r--r--crates/ra_lsp_server/src/cli/analysis_stats.rs (renamed from crates/ra_cli/src/analysis_stats.rs)4
-rw-r--r--crates/ra_lsp_server/src/cli/load_cargo.rs (renamed from crates/ra_cli/src/load_cargo.rs)0
-rw-r--r--crates/ra_lsp_server/src/cli/progress_report.rs (renamed from crates/ra_cli/src/progress_report.rs)0
-rw-r--r--crates/ra_lsp_server/src/lib.rs2
-rw-r--r--crates/ra_lsp_server/src/main.rs46
11 files changed, 190 insertions, 205 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 82f910c1b..ccdcfbee3 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -942,30 +942,6 @@ dependencies = [
942] 942]
943 943
944[[package]] 944[[package]]
945name = "ra_cli"
946version = "0.1.0"
947dependencies = [
948 "anyhow",
949 "crossbeam-channel",
950 "env_logger",
951 "itertools",
952 "log",
953 "pico-args",
954 "ra_db",
955 "ra_hir",
956 "ra_hir_def",
957 "ra_hir_ty",
958 "ra_ide",
959 "ra_prof",
960 "ra_project_model",
961 "ra_syntax",
962 "ra_vfs",
963 "ra_vfs_glob",
964 "rand",
965 "rustc-hash",
966]
967
968[[package]]
969name = "ra_db" 945name = "ra_db"
970version = "0.1.0" 946version = "0.1.0"
971dependencies = [ 947dependencies = [
@@ -1122,15 +1098,22 @@ dependencies = [
1122name = "ra_lsp_server" 1098name = "ra_lsp_server"
1123version = "0.1.0" 1099version = "0.1.0"
1124dependencies = [ 1100dependencies = [
1101 "anyhow",
1125 "crossbeam-channel", 1102 "crossbeam-channel",
1126 "either", 1103 "either",
1127 "env_logger", 1104 "env_logger",
1105 "itertools",
1128 "jod-thread", 1106 "jod-thread",
1129 "log", 1107 "log",
1130 "lsp-server", 1108 "lsp-server",
1131 "lsp-types", 1109 "lsp-types",
1132 "parking_lot", 1110 "parking_lot",
1111 "pico-args",
1133 "ra_cargo_watch", 1112 "ra_cargo_watch",
1113 "ra_db",
1114 "ra_hir",
1115 "ra_hir_def",
1116 "ra_hir_ty",
1134 "ra_ide", 1117 "ra_ide",
1135 "ra_prof", 1118 "ra_prof",
1136 "ra_project_model", 1119 "ra_project_model",
@@ -1138,6 +1121,7 @@ dependencies = [
1138 "ra_text_edit", 1121 "ra_text_edit",
1139 "ra_vfs", 1122 "ra_vfs",
1140 "ra_vfs_glob", 1123 "ra_vfs_glob",
1124 "rand",
1141 "relative-path", 1125 "relative-path",
1142 "rustc-hash", 1126 "rustc-hash",
1143 "serde", 1127 "serde",
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml
deleted file mode 100644
index ce88a76b1..000000000
--- a/crates/ra_cli/Cargo.toml
+++ /dev/null
@@ -1,31 +0,0 @@
1[package]
2edition = "2018"
3name = "ra_cli"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6publish = false
7
8[dependencies]
9crossbeam-channel = "0.4.0"
10env_logger = { version = "0.7.1", default-features = false }
11itertools = "0.8.0"
12log = "0.4.5"
13pico-args = "0.3.0"
14rand = { version = "0.7.0", features = ["small_rng"] }
15rustc-hash = "1.0"
16anyhow = "1.0"
17
18hir = { path = "../ra_hir", package = "ra_hir" }
19hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
20hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" }
21ra_db = { path = "../ra_db" }
22ra_ide = { path = "../ra_ide" }
23ra_project_model = { path = "../ra_project_model" }
24ra_syntax = { path = "../ra_syntax" }
25ra_vfs = "0.5.0"
26ra_vfs_glob = { path = "../ra_vfs_glob" }
27
28[dependencies.ra_prof]
29path = "../ra_prof"
30# features = [ "cpu_profiler" ]
31# features = [ "jemalloc" ]
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index 0066929c0..be7982b2a 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -8,13 +8,17 @@ authors = ["rust-analyzer developers"]
8doctest = false 8doctest = false
9 9
10[dependencies] 10[dependencies]
11anyhow = "1.0"
11crossbeam-channel = "0.4" 12crossbeam-channel = "0.4"
12either = "1.5" 13either = "1.5"
13env_logger = { version = "0.7.1", default-features = false } 14env_logger = { version = "0.7.1", default-features = false }
15itertools = "0.8.0"
14jod-thread = "0.1.0" 16jod-thread = "0.1.0"
15log = "0.4.3" 17log = "0.4.3"
16lsp-types = { version = "0.70.0", features = ["proposed"] } 18lsp-types = { version = "0.70.0", features = ["proposed"] }
17parking_lot = "0.10.0" 19parking_lot = "0.10.0"
20pico-args = "0.3.0"
21rand = { version = "0.7.0", features = ["small_rng"] }
18relative-path = "1.0.0" 22relative-path = "1.0.0"
19rustc-hash = "1.0" 23rustc-hash = "1.0"
20serde = { version = "1.0.83", features = ["derive"] } 24serde = { version = "1.0.83", features = ["derive"] }
@@ -31,6 +35,13 @@ ra_text_edit = { path = "../ra_text_edit" }
31ra_vfs = "0.5.0" 35ra_vfs = "0.5.0"
32ra_vfs_glob = { path = "../ra_vfs_glob" } 36ra_vfs_glob = { path = "../ra_vfs_glob" }
33 37
38# This should only be used in CLI
39ra_db = { path = "../ra_db" }
40hir = { path = "../ra_hir", package = "ra_hir" }
41hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
42hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" }
43
44
34[target.'cfg(windows)'.dependencies] 45[target.'cfg(windows)'.dependencies]
35winapi = "0.3" 46winapi = "0.3"
36 47
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_lsp_server/src/args.rs
index 4cf062f47..41959797c 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_lsp_server/src/args.rs
@@ -1,65 +1,15 @@
1//! FIXME: write short doc here 1use anyhow::{bail, Result};
2
3mod load_cargo;
4mod analysis_stats;
5mod analysis_bench;
6mod progress_report;
7
8use std::{fmt::Write, io::Read, path::PathBuf, str::FromStr};
9
10use pico_args::Arguments; 2use pico_args::Arguments;
11use ra_ide::{file_structure, Analysis}; 3use ra_lsp_server::cli::{BenchWhat, Position, Verbosity};
12use ra_prof::profile; 4
13use ra_syntax::{AstNode, SourceFile}; 5use std::{fmt::Write, path::PathBuf};
14
15use anyhow::{bail, format_err, Result};
16
17fn main() -> Result<()> {
18 env_logger::try_init()?;
19
20 let command = match Command::from_env_args()? {
21 Ok(it) => it,
22 Err(HelpPrinted) => return Ok(()),
23 };
24 match command {
25 Command::Parse { no_dump } => {
26 let _p = profile("parsing");
27 let file = file()?;
28 if !no_dump {
29 println!("{:#?}", file.syntax());
30 }
31 std::mem::forget(file);
32 }
33 Command::Symbols => {
34 let file = file()?;
35 for s in file_structure(&file) {
36 println!("{:?}", s);
37 }
38 }
39 Command::Highlight { rainbow } => {
40 let (analysis, file_id) = Analysis::from_single_file(read_stdin()?);
41 let html = analysis.highlight_as_html(file_id, rainbow).unwrap();
42 println!("{}", html);
43 }
44 Command::Stats { verbosity, randomize, memory_usage, only, with_deps, path } => {
45 analysis_stats::run(
46 verbosity,
47 memory_usage,
48 path.as_ref(),
49 only.as_ref().map(String::as_ref),
50 with_deps,
51 randomize,
52 )?;
53 }
54 Command::Bench { verbosity, path, what } => {
55 analysis_bench::run(verbosity, path.as_ref(), what)?;
56 }
57 }
58 6
59 Ok(()) 7pub(crate) struct Args {
8 pub(crate) verbosity: Verbosity,
9 pub(crate) command: Command,
60} 10}
61 11
62enum Command { 12pub(crate) enum Command {
63 Parse { 13 Parse {
64 no_dump: bool, 14 no_dump: bool,
65 }, 15 },
@@ -68,7 +18,6 @@ enum Command {
68 rainbow: bool, 18 rainbow: bool,
69 }, 19 },
70 Stats { 20 Stats {
71 verbosity: Verbosity,
72 randomize: bool, 21 randomize: bool,
73 memory_usage: bool, 22 memory_usage: bool,
74 only: Option<String>, 23 only: Option<String>,
@@ -76,67 +25,21 @@ enum Command {
76 path: PathBuf, 25 path: PathBuf,
77 }, 26 },
78 Bench { 27 Bench {
79 verbosity: Verbosity,
80 path: PathBuf, 28 path: PathBuf,
81 what: BenchWhat, 29 what: BenchWhat,
82 }, 30 },
31 RunServer,
32 Version,
83} 33}
84 34
85#[derive(Clone, Copy)] 35impl Args {
86pub enum Verbosity { 36 pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> {
87 Spammy, 37 let mut matches = Arguments::from_env();
88 Verbose,
89 Normal,
90 Quiet,
91}
92 38
93impl Verbosity { 39 if matches.contains("--version") {
94 fn is_verbose(self) -> bool { 40 matches.finish().or_else(handle_extra_flags)?;
95 match self { 41 return Ok(Ok(Args { verbosity: Verbosity::Normal, command: Command::Version }));
96 Verbosity::Verbose | Verbosity::Spammy => true,
97 _ => false,
98 } 42 }
99 }
100 fn is_spammy(self) -> bool {
101 match self {
102 Verbosity::Spammy => true,
103 _ => false,
104 }
105 }
106}
107
108enum BenchWhat {
109 Highlight { path: PathBuf },
110 Complete(Position),
111 GotoDef(Position),
112}
113
114pub(crate) struct Position {
115 path: PathBuf,
116 line: u32,
117 column: u32,
118}
119
120impl FromStr for Position {
121 type Err = anyhow::Error;
122 fn from_str(s: &str) -> Result<Self> {
123 let (path_line, column) = rsplit_at_char(s, ':')?;
124 let (path, line) = rsplit_at_char(path_line, ':')?;
125 Ok(Position { path: path.into(), line: line.parse()?, column: column.parse()? })
126 }
127}
128
129fn rsplit_at_char(s: &str, c: char) -> Result<(&str, &str)> {
130 let idx = s.rfind(c).ok_or_else(|| format_err!("no `{}` in {}", c, s))?;
131 Ok((&s[..idx], &s[idx + 1..]))
132}
133
134struct HelpPrinted;
135
136impl Command {
137 fn from_env_args() -> Result<Result<Command, HelpPrinted>> {
138 let mut matches = Arguments::from_env();
139 let subcommand = matches.subcommand()?.unwrap_or_default();
140 43
141 let verbosity = match ( 44 let verbosity = match (
142 matches.contains(["-vv", "--spammy"]), 45 matches.contains(["-vv", "--spammy"]),
@@ -151,6 +54,13 @@ impl Command {
151 (false, true, true) => bail!("Invalid flags: -q conflicts with -v"), 54 (false, true, true) => bail!("Invalid flags: -q conflicts with -v"),
152 }; 55 };
153 56
57 let subcommand = match matches.subcommand()? {
58 Some(it) => it,
59 None => {
60 matches.finish().or_else(handle_extra_flags)?;
61 return Ok(Ok(Args { verbosity, command: Command::RunServer }));
62 }
63 };
154 let command = match subcommand.as_str() { 64 let command = match subcommand.as_str() {
155 "parse" => { 65 "parse" => {
156 if matches.contains(["-h", "--help"]) { 66 if matches.contains(["-h", "--help"]) {
@@ -247,7 +157,7 @@ ARGS:
247 trailing.pop().unwrap().into() 157 trailing.pop().unwrap().into()
248 }; 158 };
249 159
250 Command::Stats { verbosity, randomize, memory_usage, only, with_deps, path } 160 Command::Stats { randomize, memory_usage, only, with_deps, path }
251 } 161 }
252 "analysis-bench" => { 162 "analysis-bench" => {
253 if matches.contains(["-h", "--help"]) { 163 if matches.contains(["-h", "--help"]) {
@@ -284,7 +194,7 @@ ARGS:
284 "exactly one of `--highlight`, `--complete` or `--goto-def` must be set" 194 "exactly one of `--highlight`, `--complete` or `--goto-def` must be set"
285 ), 195 ),
286 }; 196 };
287 Command::Bench { verbosity, path, what } 197 Command::Bench { path, what }
288 } 198 }
289 _ => { 199 _ => {
290 eprintln!( 200 eprintln!(
@@ -307,10 +217,12 @@ SUBCOMMANDS:
307 return Ok(Err(HelpPrinted)); 217 return Ok(Err(HelpPrinted));
308 } 218 }
309 }; 219 };
310 Ok(Ok(command)) 220 Ok(Ok(Args { verbosity, command }))
311 } 221 }
312} 222}
313 223
224pub(crate) struct HelpPrinted;
225
314fn handle_extra_flags(e: pico_args::Error) -> Result<()> { 226fn handle_extra_flags(e: pico_args::Error) -> Result<()> {
315 if let pico_args::Error::UnusedArgsLeft(flags) = e { 227 if let pico_args::Error::UnusedArgsLeft(flags) = e {
316 let mut invalid_flags = String::new(); 228 let mut invalid_flags = String::new();
@@ -323,14 +235,3 @@ fn handle_extra_flags(e: pico_args::Error) -> Result<()> {
323 bail!(e); 235 bail!(e);
324 } 236 }
325} 237}
326
327fn file() -> Result<SourceFile> {
328 let text = read_stdin()?;
329 Ok(SourceFile::parse(&text).tree())
330}
331
332fn read_stdin() -> Result<String> {
333 let mut buff = String::new();
334 std::io::stdin().read_to_string(&mut buff)?;
335 Ok(buff)
336}
diff --git a/crates/ra_lsp_server/src/cli.rs b/crates/ra_lsp_server/src/cli.rs
new file mode 100644
index 000000000..3c7b8e250
--- /dev/null
+++ b/crates/ra_lsp_server/src/cli.rs
@@ -0,0 +1,75 @@
1//! FIXME: write short doc here
2
3mod load_cargo;
4mod analysis_stats;
5mod analysis_bench;
6mod progress_report;
7
8use std::io::Read;
9
10use anyhow::Result;
11use ra_ide::{file_structure, Analysis};
12use ra_prof::profile;
13use ra_syntax::{AstNode, SourceFile};
14
15#[derive(Clone, Copy)]
16pub enum Verbosity {
17 Spammy,
18 Verbose,
19 Normal,
20 Quiet,
21}
22
23impl 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
38pub 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
48pub fn symbols() -> Result<()> {
49 let file = file()?;
50 for s in file_structure(&file) {
51 println!("{:?}", s);
52 }
53 Ok(())
54}
55
56pub 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
63pub use analysis_bench::{analysis_bench, BenchWhat, Position};
64pub use analysis_stats::analysis_stats;
65
66fn file() -> Result<SourceFile> {
67 let text = read_stdin()?;
68 Ok(SourceFile::parse(&text).tree())
69}
70
71fn read_stdin() -> Result<String> {
72 let mut buff = String::new();
73 std::io::stdin().read_to_string(&mut buff)?;
74 Ok(buff)
75}
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_lsp_server/src/cli/analysis_bench.rs
index 91fc55fe2..e00f81073 100644
--- a/crates/ra_cli/src/analysis_bench.rs
+++ b/crates/ra_lsp_server/src/cli/analysis_bench.rs
@@ -1,17 +1,48 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use std::{path::Path, sync::Arc, time::Instant}; 3use std::{
4 path::{Path, PathBuf},
5 str::FromStr,
6 sync::Arc,
7 time::Instant,
8};
4 9
5use anyhow::format_err; 10use anyhow::{format_err, Result};
6use ra_db::{ 11use ra_db::{
7 salsa::{Database, Durability}, 12 salsa::{Database, Durability},
8 FileId, SourceDatabaseExt, 13 FileId, SourceDatabaseExt,
9}; 14};
10use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; 15use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol};
11 16
12use crate::{load_cargo::load_cargo, BenchWhat, Result, Verbosity}; 17use crate::cli::{load_cargo::load_cargo, Verbosity};
18
19pub enum BenchWhat {
20 Highlight { path: PathBuf },
21 Complete(Position),
22 GotoDef(Position),
23}
24
25pub struct Position {
26 pub path: PathBuf,
27 pub line: u32,
28 pub column: u32,
29}
30
31impl FromStr for Position {
32 type Err = anyhow::Error;
33 fn from_str(s: &str) -> Result<Self> {
34 let (path_line, column) = rsplit_at_char(s, ':')?;
35 let (path, line) = rsplit_at_char(path_line, ':')?;
36 Ok(Position { path: path.into(), line: line.parse()?, column: column.parse()? })
37 }
38}
39
40fn rsplit_at_char(s: &str, c: char) -> Result<(&str, &str)> {
41 let idx = s.rfind(c).ok_or_else(|| format_err!("no `{}` in {}", c, s))?;
42 Ok((&s[..idx], &s[idx + 1..]))
43}
13 44
14pub(crate) fn run(verbosity: Verbosity, path: &Path, what: BenchWhat) -> Result<()> { 45pub fn analysis_bench(verbosity: Verbosity, path: &Path, what: BenchWhat) -> Result<()> {
15 ra_prof::init(); 46 ra_prof::init();
16 47
17 let start = Instant::now(); 48 let start = Instant::now();
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_lsp_server/src/cli/analysis_stats.rs
index d40f04391..c27fabe3c 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_lsp_server/src/cli/analysis_stats.rs
@@ -13,9 +13,9 @@ use ra_db::SourceDatabaseExt;
13use ra_syntax::AstNode; 13use ra_syntax::AstNode;
14use rand::{seq::SliceRandom, thread_rng}; 14use rand::{seq::SliceRandom, thread_rng};
15 15
16use crate::{load_cargo::load_cargo, progress_report::ProgressReport, Result, Verbosity}; 16use crate::cli::{load_cargo::load_cargo, progress_report::ProgressReport, Result, Verbosity};
17 17
18pub fn run( 18pub fn analysis_stats(
19 verbosity: Verbosity, 19 verbosity: Verbosity,
20 memory_usage: bool, 20 memory_usage: bool,
21 path: &Path, 21 path: &Path,
diff --git a/crates/ra_cli/src/load_cargo.rs b/crates/ra_lsp_server/src/cli/load_cargo.rs
index b9a4e6aba..b9a4e6aba 100644
--- a/crates/ra_cli/src/load_cargo.rs
+++ b/crates/ra_lsp_server/src/cli/load_cargo.rs
diff --git a/crates/ra_cli/src/progress_report.rs b/crates/ra_lsp_server/src/cli/progress_report.rs
index 31867a1e9..31867a1e9 100644
--- a/crates/ra_cli/src/progress_report.rs
+++ b/crates/ra_lsp_server/src/cli/progress_report.rs
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs
index a3464a5a3..2832b2605 100644
--- a/crates/ra_lsp_server/src/lib.rs
+++ b/crates/ra_lsp_server/src/lib.rs
@@ -7,6 +7,8 @@
7//! state, and `main_loop` module defines the rules for modifying it. 7//! state, and `main_loop` module defines the rules for modifying it.
8#![recursion_limit = "512"] 8#![recursion_limit = "512"]
9 9
10pub mod cli;
11
10#[allow(unused)] 12#[allow(unused)]
11macro_rules! println { 13macro_rules! println {
12 ($($tt:tt)*) => { 14 ($($tt:tt)*) => {
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index ed2eaabd4..a549e5ff1 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -1,14 +1,39 @@
1//! `ra_lsp_server` binary 1//! `ra_lsp_server` binary
2mod args;
2 3
3use lsp_server::Connection; 4use lsp_server::Connection;
4use ra_lsp_server::{from_json, show_message, Result, ServerConfig}; 5use ra_lsp_server::{cli, from_json, show_message, Result, ServerConfig};
5use ra_prof; 6use ra_prof;
6 7
8use crate::args::HelpPrinted;
9
7fn main() -> Result<()> { 10fn main() -> Result<()> {
8 setup_logging()?; 11 setup_logging()?;
9 match Args::parse()? { 12 let args = match args::Args::parse()? {
10 Args::Version => println!("rust-analyzer {}", env!("REV")), 13 Ok(it) => it,
11 Args::Run => run_server()?, 14 Err(HelpPrinted) => return Ok(()),
15 };
16 match args.command {
17 args::Command::Parse { no_dump } => cli::parse(no_dump)?,
18 args::Command::Symbols => cli::symbols()?,
19 args::Command::Highlight { rainbow } => cli::highlight(rainbow)?,
20 args::Command::Stats { randomize, memory_usage, only, with_deps, path } => {
21 cli::analysis_stats(
22 args.verbosity,
23 memory_usage,
24 path.as_ref(),
25 only.as_ref().map(String::as_ref),
26 with_deps,
27 randomize,
28 )?
29 }
30
31 args::Command::Bench { path, what } => {
32 cli::analysis_bench(args.verbosity, path.as_ref(), what)?
33 }
34
35 args::Command::RunServer => run_server()?,
36 args::Command::Version => println!("rust-analyzer {}", env!("REV")),
12 } 37 }
13 Ok(()) 38 Ok(())
14} 39}
@@ -20,19 +45,6 @@ fn setup_logging() -> Result<()> {
20 Ok(()) 45 Ok(())
21} 46}
22 47
23enum Args {
24 Version,
25 Run,
26}
27
28impl Args {
29 fn parse() -> Result<Args> {
30 let res =
31 if std::env::args().any(|it| it == "--version") { Args::Version } else { Args::Run };
32 Ok(res)
33 }
34}
35
36fn run_server() -> Result<()> { 48fn run_server() -> Result<()> {
37 log::info!("lifecycle: server started"); 49 log::info!("lifecycle: server started");
38 50