aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-17 19:14:32 +0000
committerGitHub <[email protected]>2020-02-17 19:14:32 +0000
commit1b73abd1c3c9185f4a1f62c5e657e07daf3d4774 (patch)
tree33542cd2b44bd5290f18baebee460b487008035a
parent64755b5e1f68290a2518b0bbc2f0007f95cd2632 (diff)
parent2c9b91ad326c387190bedab9dae9d08d3eb0705a (diff)
Merge #3200
3200: Merge ra_vfs_glob and ra_lsp_server r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--Cargo.lock42
-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)158
-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_vfs_glob/Cargo.toml12
-rw-r--r--xtask/tests/tidy-tests/docs.rs1
16 files changed, 201 insertions, 230 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 82f910c1b..c22cbca3a 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,22 +1098,30 @@ 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 "globset",
1106 "itertools",
1128 "jod-thread", 1107 "jod-thread",
1129 "log", 1108 "log",
1130 "lsp-server", 1109 "lsp-server",
1131 "lsp-types", 1110 "lsp-types",
1132 "parking_lot", 1111 "parking_lot",
1112 "pico-args",
1133 "ra_cargo_watch", 1113 "ra_cargo_watch",
1114 "ra_db",
1115 "ra_hir",
1116 "ra_hir_def",
1117 "ra_hir_ty",
1134 "ra_ide", 1118 "ra_ide",
1135 "ra_prof", 1119 "ra_prof",
1136 "ra_project_model", 1120 "ra_project_model",
1137 "ra_syntax", 1121 "ra_syntax",
1138 "ra_text_edit", 1122 "ra_text_edit",
1139 "ra_vfs", 1123 "ra_vfs",
1140 "ra_vfs_glob", 1124 "rand",
1141 "relative-path", 1125 "relative-path",
1142 "rustc-hash", 1126 "rustc-hash",
1143 "serde", 1127 "serde",
@@ -1244,14 +1228,6 @@ dependencies = [
1244] 1228]
1245 1229
1246[[package]] 1230[[package]]
1247name = "ra_vfs_glob"
1248version = "0.1.0"
1249dependencies = [
1250 "globset",
1251 "ra_vfs",
1252]
1253
1254[[package]]
1255name = "rand" 1231name = "rand"
1256version = "0.7.3" 1232version = "0.7.3"
1257source = "registry+https://github.com/rust-lang/crates.io-index" 1233source = "registry+https://github.com/rust-lang/crates.io-index"
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..89e2139ce 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"]) {
@@ -247,7 +162,7 @@ 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"]) {
@@ -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!(
@@ -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_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"
diff --git a/xtask/tests/tidy-tests/docs.rs b/xtask/tests/tidy-tests/docs.rs
index a8ed9793f..b2571df25 100644
--- a/xtask/tests/tidy-tests/docs.rs
+++ b/xtask/tests/tidy-tests/docs.rs
@@ -73,7 +73,6 @@ fn no_docs_comments() {
73 } 73 }
74 74
75 let whitelist = [ 75 let whitelist = [
76 "ra_cli",
77 "ra_db", 76 "ra_db",
78 "ra_hir", 77 "ra_hir",
79 "ra_hir_expand", 78 "ra_hir_expand",