aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_cli/Cargo.toml31
-rw-r--r--crates/ra_lsp_server/Cargo.toml13
-rw-r--r--crates/ra_lsp_server/src/args.rs (renamed from crates/ra_cli/src/main.rs)172
-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)3
-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.rs3
-rw-r--r--crates/ra_lsp_server/src/main.rs46
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs2
-rw-r--r--crates/ra_lsp_server/src/vfs_glob.rs (renamed from crates/ra_vfs_glob/src/lib.rs)0
-rw-r--r--crates/ra_lsp_server/src/world.rs2
-rw-r--r--crates/ra_prof/src/lib.rs4
-rw-r--r--crates/ra_vfs_glob/Cargo.toml12
15 files changed, 201 insertions, 205 deletions
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..da523ba8a 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -8,13 +8,18 @@ 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 }
15globset = "0.4.4"
16itertools = "0.8.0"
14jod-thread = "0.1.0" 17jod-thread = "0.1.0"
15log = "0.4.3" 18log = "0.4.3"
16lsp-types = { version = "0.70.0", features = ["proposed"] } 19lsp-types = { version = "0.70.0", features = ["proposed"] }
17parking_lot = "0.10.0" 20parking_lot = "0.10.0"
21pico-args = "0.3.0"
22rand = { version = "0.7.0", features = ["small_rng"] }
18relative-path = "1.0.0" 23relative-path = "1.0.0"
19rustc-hash = "1.0" 24rustc-hash = "1.0"
20serde = { version = "1.0.83", features = ["derive"] } 25serde = { version = "1.0.83", features = ["derive"] }
@@ -29,7 +34,13 @@ ra_project_model = { path = "../ra_project_model" }
29ra_syntax = { path = "../ra_syntax" } 34ra_syntax = { path = "../ra_syntax" }
30ra_text_edit = { path = "../ra_text_edit" } 35ra_text_edit = { path = "../ra_text_edit" }
31ra_vfs = "0.5.0" 36ra_vfs = "0.5.0"
32ra_vfs_glob = { path = "../ra_vfs_glob" } 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
33 44
34[target.'cfg(windows)'.dependencies] 45[target.'cfg(windows)'.dependencies]
35winapi = "0.3" 46winapi = "0.3"
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_lsp_server/src/args.rs
index 4cf062f47..3890fe13a 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_lsp_server/src/args.rs
@@ -1,65 +1,20 @@
1//! FIXME: write short doc here 1//! Command like parsing for rust-analyzer.
2 2//!
3mod load_cargo; 3//! If run started args, we run the LSP server loop. With a subcommand, we do a
4mod analysis_stats; 4//! one-time batch processing.
5mod analysis_bench;
6mod progress_report;
7
8use std::{fmt::Write, io::Read, path::PathBuf, str::FromStr};
9 5
6use anyhow::{bail, Result};
10use pico_args::Arguments; 7use pico_args::Arguments;
11use ra_ide::{file_structure, Analysis}; 8use ra_lsp_server::cli::{BenchWhat, Position, Verbosity};
12use ra_prof::profile;
13use ra_syntax::{AstNode, SourceFile};
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 9
59 Ok(()) 10use std::{fmt::Write, path::PathBuf};
11
12pub(crate) struct Args {
13 pub(crate) verbosity: Verbosity,
14 pub(crate) command: Command,
60} 15}
61 16
62enum Command { 17pub(crate) enum Command {
63 Parse { 18 Parse {
64 no_dump: bool, 19 no_dump: bool,
65 }, 20 },
@@ -68,7 +23,6 @@ enum Command {
68 rainbow: bool, 23 rainbow: bool,
69 }, 24 },
70 Stats { 25 Stats {
71 verbosity: Verbosity,
72 randomize: bool, 26 randomize: bool,
73 memory_usage: bool, 27 memory_usage: bool,
74 only: Option<String>, 28 only: Option<String>,
@@ -76,67 +30,21 @@ enum Command {
76 path: PathBuf, 30 path: PathBuf,
77 }, 31 },
78 Bench { 32 Bench {
79 verbosity: Verbosity,
80 path: PathBuf, 33 path: PathBuf,
81 what: BenchWhat, 34 what: BenchWhat,
82 }, 35 },
36 RunServer,
37 Version,
83} 38}
84 39
85#[derive(Clone, Copy)] 40impl Args {
86pub enum Verbosity { 41 pub(crate) fn parse() -> Result<Result<Args, HelpPrinted>> {
87 Spammy, 42 let mut matches = Arguments::from_env();
88 Verbose,
89 Normal,
90 Quiet,
91}
92 43
93impl Verbosity { 44 if matches.contains("--version") {
94 fn is_verbose(self) -> bool { 45 matches.finish().or_else(handle_extra_flags)?;
95 match self { 46 return Ok(Ok(Args { verbosity: Verbosity::Normal, command: Command::Version }));
96 Verbosity::Verbose | Verbosity::Spammy => true,
97 _ => false,
98 }
99 }
100 fn is_spammy(self) -> bool {
101 match self {
102 Verbosity::Spammy => true,
103 _ => false,
104 } 47 }
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 48
141 let verbosity = match ( 49 let verbosity = match (
142 matches.contains(["-vv", "--spammy"]), 50 matches.contains(["-vv", "--spammy"]),
@@ -151,6 +59,13 @@ impl Command {
151 (false, true, true) => bail!("Invalid flags: -q conflicts with -v"), 59 (false, true, true) => bail!("Invalid flags: -q conflicts with -v"),
152 }; 60 };
153 61
62 let subcommand = match matches.subcommand()? {
63 Some(it) => it,
64 None => {
65 matches.finish().or_else(handle_extra_flags)?;
66 return Ok(Ok(Args { verbosity, command: Command::RunServer }));
67 }
68 };
154 let command = match subcommand.as_str() { 69 let command = match subcommand.as_str() {
155 "parse" => { 70 "parse" => {
156 if matches.contains(["-h", "--help"]) { 71 if matches.contains(["-h", "--help"]) {
@@ -159,7 +74,7 @@ impl Command {
159ra-cli-parse 74ra-cli-parse
160 75
161USAGE: 76USAGE:
162 ra_cli parse [FLAGS] 77 ra_lsp_server parse [FLAGS]
163 78
164FLAGS: 79FLAGS:
165 -h, --help Prints help inforamtion 80 -h, --help Prints help inforamtion
@@ -179,7 +94,7 @@ FLAGS:
179ra-cli-symbols 94ra-cli-symbols
180 95
181USAGE: 96USAGE:
182 ra_cli highlight [FLAGS] 97 ra_lsp_server highlight [FLAGS]
183 98
184FLAGS: 99FLAGS:
185 -h, --help Prints help inforamtion" 100 -h, --help Prints help inforamtion"
@@ -198,7 +113,7 @@ FLAGS:
198ra-cli-highlight 113ra-cli-highlight
199 114
200USAGE: 115USAGE:
201 ra_cli highlight [FLAGS] 116 ra_lsp_server highlight [FLAGS]
202 117
203FLAGS: 118FLAGS:
204 -h, --help Prints help information 119 -h, --help Prints help information
@@ -218,7 +133,7 @@ FLAGS:
218ra-cli-analysis-stats 133ra-cli-analysis-stats
219 134
220USAGE: 135USAGE:
221 ra_cli analysis-stats [FLAGS] [OPTIONS] [PATH] 136 ra_lsp_server analysis-stats [FLAGS] [OPTIONS] [PATH]
222 137
223FLAGS: 138FLAGS:
224 -h, --help Prints help information 139 -h, --help Prints help information
@@ -247,16 +162,16 @@ ARGS:
247 trailing.pop().unwrap().into() 162 trailing.pop().unwrap().into()
248 }; 163 };
249 164
250 Command::Stats { verbosity, randomize, memory_usage, only, with_deps, path } 165 Command::Stats { randomize, memory_usage, only, with_deps, path }
251 } 166 }
252 "analysis-bench" => { 167 "analysis-bench" => {
253 if matches.contains(["-h", "--help"]) { 168 if matches.contains(["-h", "--help"]) {
254 eprintln!( 169 eprintln!(
255 "\ 170 "\
256ra_cli-analysis-bench 171ra_lsp_server-analysis-bench
257 172
258USAGE: 173USAGE:
259 ra_cli analysis-bench [FLAGS] [OPTIONS] [PATH] 174 ra_lsp_server analysis-bench [FLAGS] [OPTIONS] [PATH]
260 175
261FLAGS: 176FLAGS:
262 -h, --help Prints help information 177 -h, --help Prints help information
@@ -284,7 +199,7 @@ ARGS:
284 "exactly one of `--highlight`, `--complete` or `--goto-def` must be set" 199 "exactly one of `--highlight`, `--complete` or `--goto-def` must be set"
285 ), 200 ),
286 }; 201 };
287 Command::Bench { verbosity, path, what } 202 Command::Bench { path, what }
288 } 203 }
289 _ => { 204 _ => {
290 eprintln!( 205 eprintln!(
@@ -292,7 +207,7 @@ ARGS:
292ra-cli 207ra-cli
293 208
294USAGE: 209USAGE:
295 ra_cli <SUBCOMMAND> 210 ra_lsp_server <SUBCOMMAND>
296 211
297FLAGS: 212FLAGS:
298 -h, --help Prints help information 213 -h, --help Prints help information
@@ -307,10 +222,12 @@ SUBCOMMANDS:
307 return Ok(Err(HelpPrinted)); 222 return Ok(Err(HelpPrinted));
308 } 223 }
309 }; 224 };
310 Ok(Ok(command)) 225 Ok(Ok(Args { verbosity, command }))
311 } 226 }
312} 227}
313 228
229pub(crate) struct HelpPrinted;
230
314fn handle_extra_flags(e: pico_args::Error) -> Result<()> { 231fn handle_extra_flags(e: pico_args::Error) -> Result<()> {
315 if let pico_args::Error::UnusedArgsLeft(flags) = e { 232 if let pico_args::Error::UnusedArgsLeft(flags) = e {
316 let mut invalid_flags = String::new(); 233 let mut invalid_flags = String::new();
@@ -323,14 +240,3 @@ fn handle_extra_flags(e: pico_args::Error) -> Result<()> {
323 bail!(e); 240 bail!(e);
324 } 241 }
325} 242}
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..bb3e1513b 100644
--- a/crates/ra_cli/src/load_cargo.rs
+++ b/crates/ra_lsp_server/src/cli/load_cargo.rs
@@ -7,9 +7,10 @@ use ra_db::{CrateGraph, FileId, SourceRootId};
7use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags}; 7use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags};
8use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace}; 8use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace};
9use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; 9use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch};
10use ra_vfs_glob::RustPackageFilterBuilder;
11use rustc_hash::FxHashMap; 10use rustc_hash::FxHashMap;
12 11
12use crate::vfs_glob::RustPackageFilterBuilder;
13
13use anyhow::Result; 14use anyhow::Result;
14 15
15fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId { 16fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId {
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..958c70fe5 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)*) => {
@@ -21,6 +23,7 @@ macro_rules! print {
21 }; 23 };
22} 24}
23 25
26mod vfs_glob;
24mod caps; 27mod caps;
25mod cargo_target_spec; 28mod cargo_target_spec;
26mod conv; 29mod conv;
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
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 7ae2e1e6f..944074118 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -135,7 +135,7 @@ pub fn main_loop(
135 let globs = config 135 let globs = config
136 .exclude_globs 136 .exclude_globs
137 .iter() 137 .iter()
138 .map(|glob| ra_vfs_glob::Glob::new(glob)) 138 .map(|glob| crate::vfs_glob::Glob::new(glob))
139 .collect::<std::result::Result<Vec<_>, _>>()?; 139 .collect::<std::result::Result<Vec<_>, _>>()?;
140 140
141 if config.use_client_watching { 141 if config.use_client_watching {
diff --git a/crates/ra_vfs_glob/src/lib.rs b/crates/ra_lsp_server/src/vfs_glob.rs
index 12401d75a..12401d75a 100644
--- a/crates/ra_vfs_glob/src/lib.rs
+++ b/crates/ra_lsp_server/src/vfs_glob.rs
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs
index d993c5fc4..71c95d4af 100644
--- a/crates/ra_lsp_server/src/world.rs
+++ b/crates/ra_lsp_server/src/world.rs
@@ -19,12 +19,12 @@ use ra_ide::{
19}; 19};
20use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace}; 20use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace};
21use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch}; 21use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch};
22use ra_vfs_glob::{Glob, RustPackageFilterBuilder};
23use relative_path::RelativePathBuf; 22use relative_path::RelativePathBuf;
24 23
25use crate::{ 24use crate::{
26 diagnostics::{CheckFixes, DiagnosticCollection}, 25 diagnostics::{CheckFixes, DiagnosticCollection},
27 main_loop::pending_requests::{CompletedRequest, LatestRequests}, 26 main_loop::pending_requests::{CompletedRequest, LatestRequests},
27 vfs_glob::{Glob, RustPackageFilterBuilder},
28 LspError, Result, 28 LspError, Result,
29}; 29};
30 30
diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs
index c0bfbc2ee..7ff8db58a 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/ra_prof/src/lib.rs
@@ -351,13 +351,13 @@ impl Drop for Scope {
351/// 2. Build with `cpu_profiler` feature. 351/// 2. Build with `cpu_profiler` feature.
352/// 3. Tun the code, the *raw* output would be in the `./out.profile` file. 352/// 3. Tun the code, the *raw* output would be in the `./out.profile` file.
353/// 4. Install pprof for visualization (https://github.com/google/pprof). 353/// 4. Install pprof for visualization (https://github.com/google/pprof).
354/// 5. Use something like `pprof -svg target/release/ra_cli ./out.profile` to see the results. 354/// 5. Use something like `pprof -svg target/release/ra_lsp_server ./out.profile` to see the results.
355/// 355///
356/// For example, here's how I run profiling on NixOS: 356/// For example, here's how I run profiling on NixOS:
357/// 357///
358/// ```bash 358/// ```bash
359/// $ nix-shell -p gperftools --run \ 359/// $ nix-shell -p gperftools --run \
360/// 'cargo run --release -p ra_cli -- parse < ~/projects/rustbench/parser.rs > /dev/null' 360/// 'cargo run --release -p ra_lsp_server -- parse < ~/projects/rustbench/parser.rs > /dev/null'
361/// ``` 361/// ```
362#[derive(Debug)] 362#[derive(Debug)]
363pub struct CpuProfiler { 363pub struct CpuProfiler {
diff --git a/crates/ra_vfs_glob/Cargo.toml b/crates/ra_vfs_glob/Cargo.toml
deleted file mode 100644
index 094d6d6f4..000000000
--- a/crates/ra_vfs_glob/Cargo.toml
+++ /dev/null
@@ -1,12 +0,0 @@
1[package]
2edition = "2018"
3name = "ra_vfs_glob"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6
7[lib]
8doctest = false
9
10[dependencies]
11ra_vfs = "0.5.0"
12globset = "0.4.4"