aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorSergey Parilin <[email protected]>2019-04-02 15:52:04 +0100
committerSergey Parilin <[email protected]>2019-04-02 15:52:04 +0100
commit9b73f809596e955216dde24fcf921d6985a1a767 (patch)
tree016b82dc06800a174c49a0ba88957df9c91d1906 /crates/ra_lsp_server
parentef02c3c038812897cd96789fa35770e4215d27e8 (diff)
PR issuse resolved
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r--crates/ra_lsp_server/Cargo.toml1
-rw-r--r--crates/ra_lsp_server/src/main.rs10
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs7
3 files changed, 14 insertions, 4 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index d82410700..bc181e4eb 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -27,6 +27,7 @@ ra_ide_api = { path = "../ra_ide_api" }
27ra_arena = { path = "../ra_arena" } 27ra_arena = { path = "../ra_arena" }
28gen_lsp_server = { path = "../gen_lsp_server" } 28gen_lsp_server = { path = "../gen_lsp_server" }
29ra_project_model = { path = "../ra_project_model" } 29ra_project_model = { path = "../ra_project_model" }
30ra_prof = { path = "../ra_prof" }
30 31
31[dev-dependencies] 32[dev-dependencies]
32tempfile = "3" 33tempfile = "3"
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 5a2905207..eb4091a3d 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -3,6 +3,7 @@ use flexi_logger::{Duplicate, Logger};
3use gen_lsp_server::{run_server, stdio_transport}; 3use gen_lsp_server::{run_server, stdio_transport};
4 4
5use ra_lsp_server::{Result, InitializationOptions}; 5use ra_lsp_server::{Result, InitializationOptions};
6use ra_prof;
6 7
7fn main() -> Result<()> { 8fn main() -> Result<()> {
8 ::std::env::set_var("RUST_BACKTRACE", "short"); 9 ::std::env::set_var("RUST_BACKTRACE", "short");
@@ -11,6 +12,15 @@ fn main() -> Result<()> {
11 Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, 12 Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?,
12 _ => logger.start()?, 13 _ => logger.start()?,
13 }; 14 };
15 let prof_depth = match ::std::env::var("RA_PROFILE_DEPTH") {
16 Ok(ref d) => d.parse()?,
17 _ => 0,
18 };
19 let profile_allowed = match ::std::env::var("RA_PROFILE") {
20 Ok(ref p) => p.split(";").map(String::from).collect(),
21 _ => Vec::new(),
22 };
23 ra_prof::set_filter(ra_prof::Filter::new(prof_depth, profile_allowed));
14 log::info!("lifecycle: server started"); 24 log::info!("lifecycle: server started");
15 match ::std::panic::catch_unwind(main_inner) { 25 match ::std::panic::catch_unwind(main_inner) {
16 Ok(res) => { 26 Ok(res) => {
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index eecf278a8..82410bee3 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -24,6 +24,7 @@ use crate::{
24 Result, 24 Result,
25 InitializationOptions, 25 InitializationOptions,
26}; 26};
27use ra_prof::profile;
27 28
28#[derive(Debug, Fail)] 29#[derive(Debug, Fail)]
29#[fail(display = "Language Server request failed with {}. ({})", code, message)] 30#[fail(display = "Language Server request failed with {}. ({})", code, message)]
@@ -181,7 +182,7 @@ fn main_loop_inner(
181 recv(libdata_receiver) -> data => Event::Lib(data.unwrap()) 182 recv(libdata_receiver) -> data => Event::Lib(data.unwrap())
182 }; 183 };
183 log::info!("loop_turn = {:?}", event); 184 log::info!("loop_turn = {:?}", event);
184 let start = std::time::Instant::now(); 185 let _p = profile("loop_turn");
185 let mut state_changed = false; 186 let mut state_changed = false;
186 match event { 187 match event {
187 Event::Task(task) => on_task(task, msg_sender, pending_requests), 188 Event::Task(task) => on_task(task, msg_sender, pending_requests),
@@ -235,10 +236,9 @@ fn main_loop_inner(
235 in_flight_libraries += 1; 236 in_flight_libraries += 1;
236 let sender = libdata_sender.clone(); 237 let sender = libdata_sender.clone();
237 pool.execute(move || { 238 pool.execute(move || {
238 let start = ::std::time::Instant::now();
239 log::info!("indexing {:?} ... ", root); 239 log::info!("indexing {:?} ... ", root);
240 let _p = profile(&format!("indexed {:?}", root));
240 let data = LibraryData::prepare(root, files); 241 let data = LibraryData::prepare(root, files);
241 log::info!("indexed {:?} {:?}", start.elapsed(), root);
242 sender.send(data).unwrap(); 242 sender.send(data).unwrap();
243 }); 243 });
244 } 244 }
@@ -266,7 +266,6 @@ fn main_loop_inner(
266 subs.subscriptions(), 266 subs.subscriptions(),
267 ) 267 )
268 } 268 }
269 log::info!("loop_turn = {:?}", start.elapsed());
270 } 269 }
271} 270}
272 271