aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main.rs19
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs3
2 files changed, 10 insertions, 12 deletions
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 82f52a6e8..b0b70df5c 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -6,21 +6,16 @@ use ra_lsp_server::{Result, InitializationOptions};
6use ra_prof; 6use ra_prof;
7 7
8fn main() -> Result<()> { 8fn main() -> Result<()> {
9 ::std::env::set_var("RUST_BACKTRACE", "short"); 9 std::env::set_var("RUST_BACKTRACE", "short");
10 let logger = Logger::with_env_or_str("error").duplicate_to_stderr(Duplicate::All); 10 let logger = Logger::with_env_or_str("error").duplicate_to_stderr(Duplicate::All);
11 match ::std::env::var("RA_INTERNAL_MODE") { 11 match std::env::var("RA_LOG_DIR") {
12 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()?,
13 _ => logger.start()?, 13 _ => logger.start()?,
14 }; 14 };
15 let prof_depth = match ::std::env::var("RA_PROFILE_DEPTH") { 15 ra_prof::set_filter(match std::env::var("RA_PROFILE") {
16 Ok(ref d) => d.parse()?, 16 Ok(spec) => ra_prof::Filter::from_spec(&spec),
17 _ => 0, 17 Err(_) => ra_prof::Filter::disabled(),
18 }; 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));
24 log::info!("lifecycle: server started"); 19 log::info!("lifecycle: server started");
25 match ::std::panic::catch_unwind(main_inner) { 20 match ::std::panic::catch_unwind(main_inner) {
26 Ok(res) => { 21 Ok(res) => {
@@ -36,7 +31,7 @@ fn main() -> Result<()> {
36 31
37fn main_inner() -> Result<()> { 32fn main_inner() -> Result<()> {
38 let (receiver, sender, threads) = stdio_transport(); 33 let (receiver, sender, threads) = stdio_transport();
39 let cwd = ::std::env::current_dir()?; 34 let cwd = std::env::current_dir()?;
40 run_server(ra_lsp_server::server_capabilities(), receiver, sender, |params, r, s| { 35 run_server(ra_lsp_server::server_capabilities(), receiver, sender, |params, r, s| {
41 let root = params.root_uri.and_then(|it| it.to_file_path().ok()).unwrap_or(cwd); 36 let root = params.root_uri.and_then(|it| it.to_file_path().ok()).unwrap_or(cwd);
42 37
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 41d1f759f..eb8a53545 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -12,6 +12,7 @@ use ra_ide_api::{
12 AssistId, 12 AssistId,
13}; 13};
14use ra_syntax::{AstNode, SyntaxKind, TextUnit}; 14use ra_syntax::{AstNode, SyntaxKind, TextUnit};
15use ra_prof::profile;
15use rustc_hash::FxHashMap; 16use rustc_hash::FxHashMap;
16use serde::{Serialize, Deserialize}; 17use serde::{Serialize, Deserialize};
17use serde_json::to_value; 18use serde_json::to_value;
@@ -328,6 +329,7 @@ pub fn handle_completion(
328 world: ServerWorld, 329 world: ServerWorld,
329 params: req::CompletionParams, 330 params: req::CompletionParams,
330) -> Result<Option<req::CompletionResponse>> { 331) -> Result<Option<req::CompletionResponse>> {
332 let _p = profile("handle_completion");
331 let position = { 333 let position = {
332 let file_id = params.text_document.try_conv_with(&world)?; 334 let file_id = params.text_document.try_conv_with(&world)?;
333 let line_index = world.analysis().file_line_index(file_id); 335 let line_index = world.analysis().file_line_index(file_id);
@@ -564,6 +566,7 @@ pub fn handle_code_action(
564 world: ServerWorld, 566 world: ServerWorld,
565 params: req::CodeActionParams, 567 params: req::CodeActionParams,
566) -> Result<Option<CodeActionResponse>> { 568) -> Result<Option<CodeActionResponse>> {
569 let _p = profile("handle_code_action");
567 let file_id = params.text_document.try_conv_with(&world)?; 570 let file_id = params.text_document.try_conv_with(&world)?;
568 let line_index = world.analysis().file_line_index(file_id); 571 let line_index = world.analysis().file_line_index(file_id);
569 let range = params.range.conv_with(&line_index); 572 let range = params.range.conv_with(&line_index);