From 9c764cb966cd62d8eaa83fbb7d91646a850dc256 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Fri, 29 Nov 2019 15:14:42 +0100 Subject: Only allow renames to valid identifiers --- crates/ra_lsp_server/src/main_loop/handlers.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index c81fa7f67..137f26302 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -13,7 +13,7 @@ use ra_ide::{ AssistId, FileId, FilePosition, FileRange, Query, Runnable, RunnableKind, SearchScope, }; use ra_prof::profile; -use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; +use ra_syntax::{tokenize, AstNode, SyntaxKind, TextRange, TextUnit}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use serde_json::to_value; @@ -506,6 +506,12 @@ pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result return Ok(None), -- cgit v1.2.3 From f081c9d94dcc7a06e9c224e6b113a563d474ad18 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Fri, 29 Nov 2019 15:27:22 +0100 Subject: Also allow renaming to underscore --- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 137f26302..0380788ac 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -508,7 +508,9 @@ pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result Date: Fri, 29 Nov 2019 15:52:12 +0100 Subject: Move identifier check to analysis --- crates/ra_lsp_server/src/main_loop/handlers.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 0380788ac..ca47ff5e1 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -13,7 +13,7 @@ use ra_ide::{ AssistId, FileId, FilePosition, FileRange, Query, Runnable, RunnableKind, SearchScope, }; use ra_prof::profile; -use ra_syntax::{tokenize, AstNode, SyntaxKind, TextRange, TextUnit}; +use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use serde_json::to_value; @@ -480,8 +480,6 @@ pub fn handle_prepare_rename( let _p = profile("handle_prepare_rename"); let position = params.try_conv_with(&world)?; - // We support renaming references like handle_rename does. - // In the future we may want to reject the renaming of things like keywords here too. let optional_change = world.analysis().rename(position, "dummy")?; let range = match optional_change { None => return Ok(None), @@ -506,14 +504,6 @@ pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result return Ok(None), -- cgit v1.2.3 From eb4e70fc676a97a7b411f372be1727df51a8906a Mon Sep 17 00:00:00 2001 From: Alexander Ekdahl Date: Fri, 29 Nov 2019 19:35:03 -0500 Subject: Remove flexi_logger from ra_lsp_server --- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/main.rs | 7 +------ crates/ra_lsp_server/tests/heavy_tests/main.rs | 1 - crates/ra_lsp_server/tests/heavy_tests/support.rs | 3 +-- 4 files changed, 3 insertions(+), 10 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 21aef842c..41672eaff 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -13,7 +13,6 @@ relative-path = "1.0.0" serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" -flexi_logger = "0.14.0" log = "0.4.3" lsp-types = { version = "0.61.0", features = ["proposed"] } rustc-hash = "1.0" @@ -27,6 +26,7 @@ lsp-server = "0.3.0" ra_project_model = { path = "../ra_project_model" } ra_prof = { path = "../ra_prof" } ra_vfs_glob = { path = "../ra_vfs_glob" } +env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } [dev-dependencies] tempfile = "3" diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index e13c8ca14..8076a7fa5 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -1,6 +1,5 @@ //! `ra_lsp_server` binary -use flexi_logger::{Duplicate, Logger}; use lsp_server::Connection; use ra_lsp_server::{show_message, Result, ServerConfig}; use ra_prof; @@ -14,11 +13,7 @@ fn main() -> Result<()> { fn setup_logging() -> Result<()> { std::env::set_var("RUST_BACKTRACE", "short"); - let logger = Logger::with_env_or_str("error").duplicate_to_stderr(Duplicate::All); - match std::env::var("RA_LOG_DIR") { - Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, - _ => logger.start()?, - }; + env_logger::try_init()?; ra_prof::set_filter(match std::env::var("RA_PROFILE") { Ok(spec) => ra_prof::Filter::from_spec(&spec), diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 2ba82ab05..29224cbe8 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -15,7 +15,6 @@ use tempfile::TempDir; use crate::support::{project, Project}; -const LOG: &'static str = ""; const PROFILE: &'static str = ""; // const PROFILE: &'static str = "*@3>100"; diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 86073b57d..d5ea52fa9 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -7,7 +7,6 @@ use std::{ }; use crossbeam_channel::{after, select, Receiver}; -use flexi_logger::Logger; use lsp_server::{Connection, Message, Notification, Request}; use lsp_types::{ notification::{DidOpenTextDocument, Exit}, @@ -53,7 +52,7 @@ impl<'a> Project<'a> { let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); static INIT: Once = Once::new(); INIT.call_once(|| { - let _ = Logger::with_env_or_str(crate::LOG).start().unwrap(); + let _ = env_logger::builder().is_test(true).try_init().unwrap(); ra_prof::set_filter(if crate::PROFILE.is_empty() { ra_prof::Filter::disabled() } else { -- cgit v1.2.3 From b437dca4bd100c0a7a498d5960d566a0ccd92432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Rouill=C3=A9?= Date: Wed, 4 Dec 2019 23:05:01 +0100 Subject: Run rustfmt with respect to Cargo.toml edition --- crates/ra_lsp_server/src/main_loop/handlers.rs | 6 +++ crates/ra_lsp_server/tests/heavy_tests/main.rs | 58 ++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index ca47ff5e1..409583634 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -555,12 +555,18 @@ pub fn handle_formatting( let _p = profile("handle_formatting"); let file_id = params.text_document.try_conv_with(&world)?; let file = world.analysis().file_text(file_id)?; + let crate_ids = world.analysis().crate_for(file_id)?; let file_line_index = world.analysis().file_line_index(file_id)?; let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); use std::process; let mut rustfmt = process::Command::new("rustfmt"); + if let Some(&crate_id) = crate_ids.first() { + // Assume all crates are in the same edition + let edition = world.analysis().crate_edition(crate_id)?; + rustfmt.args(&["--edition", &edition.to_string()]); + } rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped()); if let Ok(path) = params.text_document.uri.to_file_path() { diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 29224cbe8..fec50bd25 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -172,6 +172,7 @@ fn main() {} fn test_format_document() { let server = project( r#" +//- Cargo.toml [package] name = "foo" version = "0.0.0" @@ -219,6 +220,63 @@ pub use std::collections::HashMap; ); } +#[test] +fn test_format_document_2018() { + let server = project( + r#" +//- Cargo.toml +[package] +name = "foo" +version = "0.0.0" +edition = "2018" + +//- src/lib.rs +mod bar; + +async fn test() { +} + +fn main() { +} + +pub use std::collections::HashMap; +"#, + ); + server.wait_until_workspace_is_loaded(); + + server.request::( + DocumentFormattingParams { + text_document: server.doc_id("src/lib.rs"), + options: FormattingOptions { + tab_size: 4, + insert_spaces: false, + properties: HashMap::new(), + }, + }, + json!([ + { + "newText": r#"mod bar; + +async fn test() {} + +fn main() {} + +pub use std::collections::HashMap; +"#, + "range": { + "end": { + "character": 0, + "line": 10 + }, + "start": { + "character": 0, + "line": 0 + } + } + } + ]), + ); +} #[test] fn test_missing_module_code_action() { let server = project( -- cgit v1.2.3 From 8ec5f2fcdcdd2e2a9297093189ad8c05e1dd7a8f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 7 Dec 2019 12:46:36 +0100 Subject: Skip slow tests by default --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index fec50bd25..cfbf16ea5 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -12,6 +12,7 @@ use ra_lsp_server::req::{ }; use serde_json::json; use tempfile::TempDir; +use test_utils::skip_slow_tests; use crate::support::{project, Project}; @@ -20,6 +21,10 @@ const PROFILE: &'static str = ""; #[test] fn completes_items_from_standard_library() { + if skip_slow_tests() { + return; + } + let project_start = Instant::now(); let server = Project::with_fixture( r#" @@ -50,6 +55,10 @@ use std::collections::Spam; #[test] fn test_runnables_no_project() { + if skip_slow_tests() { + return; + } + let server = project( r" //- lib.rs @@ -99,6 +108,10 @@ fn foo() { #[test] fn test_runnables_project() { + if skip_slow_tests() { + return; + } + let code = r#" //- foo/Cargo.toml [package] @@ -170,6 +183,10 @@ fn main() {} #[test] fn test_format_document() { + if skip_slow_tests() { + return; + } + let server = project( r#" //- Cargo.toml @@ -222,6 +239,10 @@ pub use std::collections::HashMap; #[test] fn test_format_document_2018() { + if skip_slow_tests() { + return; + } + let server = project( r#" //- Cargo.toml @@ -277,8 +298,13 @@ pub use std::collections::HashMap; ]), ); } + #[test] fn test_missing_module_code_action() { + if skip_slow_tests() { + return; + } + let server = project( r#" //- Cargo.toml @@ -337,6 +363,10 @@ fn main() {} #[test] fn test_missing_module_code_action_in_json_project() { + if skip_slow_tests() { + return; + } + let tmp_dir = TempDir::new().unwrap(); let path = tmp_dir.path(); @@ -412,6 +442,10 @@ fn main() {{}} #[test] fn diagnostics_dont_block_typing() { + if skip_slow_tests() { + return; + } + let librs: String = (0..10).map(|i| format!("mod m{};", i)).collect(); let libs: String = (0..10).map(|i| format!("//- src/m{}.rs\nfn foo() {{}}\n\n", i)).collect(); let server = Project::with_fixture(&format!( @@ -480,6 +514,10 @@ fn main() {{}} #[test] fn preserves_dos_line_endings() { + if skip_slow_tests() { + return; + } + let server = Project::with_fixture( &" //- Cargo.toml -- cgit v1.2.3 From 5a012fb9fd87404515033b2a5e025f2b7ec44b29 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 9 Dec 2019 15:59:04 +0100 Subject: Implement `ra_lsp_server --version` --- crates/ra_lsp_server/build.rs | 15 +++++++++++++++ crates/ra_lsp_server/src/main.rs | 18 +++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 crates/ra_lsp_server/build.rs (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/build.rs b/crates/ra_lsp_server/build.rs new file mode 100644 index 000000000..05f9772c0 --- /dev/null +++ b/crates/ra_lsp_server/build.rs @@ -0,0 +1,15 @@ +//! Just embed git-hash to `--version` + +use std::process::Command; + +fn main() { + let rev = rev().unwrap_or_else(|| "???????".to_string()); + println!("cargo:rustc-env=REV={}", rev) +} + +fn rev() -> Option { + let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().ok()?; + let stdout = String::from_utf8(output.stdout).ok()?; + let short_hash = stdout.get(0..7)?; + Some(short_hash.to_owned()) +} diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 8076a7fa5..cdd925c9f 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -6,7 +6,10 @@ use ra_prof; fn main() -> Result<()> { setup_logging()?; - run_server()?; + match Args::parse()? { + Args::Version => println!("rust-analyzer {}", env!("REV")), + Args::Run => run_server()?, + } Ok(()) } @@ -22,6 +25,19 @@ fn setup_logging() -> Result<()> { Ok(()) } +enum Args { + Version, + Run, +} + +impl Args { + fn parse() -> Result { + let res = + if std::env::args().any(|it| it == "--version") { Args::Version } else { Args::Run }; + Ok(res) + } +} + fn run_server() -> Result<()> { log::info!("lifecycle: server started"); -- cgit v1.2.3 From fcccf8ec59420d20edc53f7d787f2412e297f5fe Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Wed, 11 Dec 2019 09:11:55 -0500 Subject: Support LSP 3.15 This merely upgrades our protocol support. It does not add any of the new features. --- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/caps.rs | 7 ++++++- crates/ra_lsp_server/src/main_loop.rs | 3 ++- crates/ra_lsp_server/src/main_loop/handlers.rs | 5 ++++- crates/ra_lsp_server/tests/heavy_tests/main.rs | 21 ++++++++++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 41672eaff..c50cb8031 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" log = "0.4.3" -lsp-types = { version = "0.61.0", features = ["proposed"] } +lsp-types = { version = "0.63.0", features = ["proposed"] } rustc-hash = "1.0" parking_lot = "0.10.0" jod-thread = "0.1.0" diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index eea0965ed..4cb259360 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -5,7 +5,7 @@ use lsp_types::{ DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability, ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, - TextDocumentSyncOptions, TypeDefinitionProviderCapability, + TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, }; pub fn server_capabilities() -> ServerCapabilities { @@ -21,10 +21,14 @@ pub fn server_capabilities() -> ServerCapabilities { completion_provider: Some(CompletionOptions { resolve_provider: None, trigger_characters: Some(vec![":".to_string(), ".".to_string()]), + work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), signature_help_provider: Some(SignatureHelpOptions { trigger_characters: Some(vec!["(".to_string(), ",".to_string(), ")".to_string()]), + retrigger_characters: None, + work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), + declaration_provider: None, definition_provider: Some(true), type_definition_provider: Some(TypeDefinitionProviderCapability::Simple(true)), implementation_provider: Some(ImplementationProviderCapability::Simple(true)), @@ -44,6 +48,7 @@ pub fn server_capabilities() -> ServerCapabilities { folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), rename_provider: Some(RenameProviderCapability::Options(RenameOptions { prepare_provider: Some(true), + work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, })), document_link_provider: None, color_provider: None, diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 83845f1e0..158cac0be 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -520,7 +520,8 @@ fn on_notification( if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) { subs.remove_sub(FileId(file_id.0)); } - let params = req::PublishDiagnosticsParams { uri, diagnostics: Vec::new() }; + let params = + req::PublishDiagnosticsParams { uri, diagnostics: Vec::new(), version: None }; let not = notification_new::(params); msg_sender.send(not.into()).unwrap(); return Ok(()); diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 409583634..5b64b27cd 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -648,6 +648,7 @@ pub fn handle_code_action( diagnostics: None, edit: None, command: Some(command), + is_preferred: None, }; res.push(action.into()); } @@ -670,6 +671,7 @@ pub fn handle_code_action( diagnostics: None, edit: None, command: Some(command), + is_preferred: None, }; res.push(action.into()); } @@ -828,9 +830,10 @@ pub fn publish_diagnostics( source: Some("rust-analyzer".to_string()), message: d.message, related_information: None, + tags: None, }) .collect(); - Ok(req::PublishDiagnosticsParams { uri, diagnostics }) + Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None }) } pub fn publish_decorations( diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index cfbf16ea5..dff63a12d 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -4,7 +4,8 @@ use std::{collections::HashMap, time::Instant}; use lsp_types::{ CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions, - Position, Range, TextDocumentItem, TextDocumentPositionParams, + PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams, + WorkDoneProgressParams, }; use ra_lsp_server::req::{ CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, @@ -48,6 +49,8 @@ use std::collections::Spam; Position::new(0, 23), ), context: None, + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }); assert!(format!("{}", res).contains("HashMap")); eprintln!("completion took {:?}", completion_start.elapsed()); @@ -211,8 +214,12 @@ pub use std::collections::HashMap; options: FormattingOptions { tab_size: 4, insert_spaces: false, + insert_final_newline: None, + trim_final_newlines: None, + trim_trailing_whitespace: None, properties: HashMap::new(), }, + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -272,7 +279,11 @@ pub use std::collections::HashMap; tab_size: 4, insert_spaces: false, properties: HashMap::new(), + insert_final_newline: None, + trim_final_newlines: None, + trim_trailing_whitespace: None, }, + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -325,6 +336,8 @@ fn main() {} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(0, 4), Position::new(0, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -356,6 +369,8 @@ fn main() {} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(2, 4), Position::new(2, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([]), ); @@ -404,6 +419,8 @@ fn main() {{}} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(0, 4), Position::new(0, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -435,6 +452,8 @@ fn main() {{}} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(2, 4), Position::new(2, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([]), ); -- cgit v1.2.3 From 1e0bf205eff81f04c0e1e6c208c3489327520c3f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 11 Dec 2019 18:27:34 +0100 Subject: Revert "Support LSP 3.15" This reverts commit 712700d8e027b108f9c4f8fa9acc2f25e453b6d1. --- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/caps.rs | 7 +------ crates/ra_lsp_server/src/main_loop.rs | 3 +-- crates/ra_lsp_server/src/main_loop/handlers.rs | 5 +---- crates/ra_lsp_server/tests/heavy_tests/main.rs | 21 +-------------------- 5 files changed, 5 insertions(+), 33 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index c50cb8031..41672eaff 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" log = "0.4.3" -lsp-types = { version = "0.63.0", features = ["proposed"] } +lsp-types = { version = "0.61.0", features = ["proposed"] } rustc-hash = "1.0" parking_lot = "0.10.0" jod-thread = "0.1.0" diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index 4cb259360..eea0965ed 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -5,7 +5,7 @@ use lsp_types::{ DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability, ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, - TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, + TextDocumentSyncOptions, TypeDefinitionProviderCapability, }; pub fn server_capabilities() -> ServerCapabilities { @@ -21,14 +21,10 @@ pub fn server_capabilities() -> ServerCapabilities { completion_provider: Some(CompletionOptions { resolve_provider: None, trigger_characters: Some(vec![":".to_string(), ".".to_string()]), - work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), signature_help_provider: Some(SignatureHelpOptions { trigger_characters: Some(vec!["(".to_string(), ",".to_string(), ")".to_string()]), - retrigger_characters: None, - work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), - declaration_provider: None, definition_provider: Some(true), type_definition_provider: Some(TypeDefinitionProviderCapability::Simple(true)), implementation_provider: Some(ImplementationProviderCapability::Simple(true)), @@ -48,7 +44,6 @@ pub fn server_capabilities() -> ServerCapabilities { folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), rename_provider: Some(RenameProviderCapability::Options(RenameOptions { prepare_provider: Some(true), - work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, })), document_link_provider: None, color_provider: None, diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 158cac0be..83845f1e0 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -520,8 +520,7 @@ fn on_notification( if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) { subs.remove_sub(FileId(file_id.0)); } - let params = - req::PublishDiagnosticsParams { uri, diagnostics: Vec::new(), version: None }; + let params = req::PublishDiagnosticsParams { uri, diagnostics: Vec::new() }; let not = notification_new::(params); msg_sender.send(not.into()).unwrap(); return Ok(()); diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5b64b27cd..409583634 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -648,7 +648,6 @@ pub fn handle_code_action( diagnostics: None, edit: None, command: Some(command), - is_preferred: None, }; res.push(action.into()); } @@ -671,7 +670,6 @@ pub fn handle_code_action( diagnostics: None, edit: None, command: Some(command), - is_preferred: None, }; res.push(action.into()); } @@ -830,10 +828,9 @@ pub fn publish_diagnostics( source: Some("rust-analyzer".to_string()), message: d.message, related_information: None, - tags: None, }) .collect(); - Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None }) + Ok(req::PublishDiagnosticsParams { uri, diagnostics }) } pub fn publish_decorations( diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index dff63a12d..cfbf16ea5 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -4,8 +4,7 @@ use std::{collections::HashMap, time::Instant}; use lsp_types::{ CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions, - PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams, - WorkDoneProgressParams, + Position, Range, TextDocumentItem, TextDocumentPositionParams, }; use ra_lsp_server::req::{ CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, @@ -49,8 +48,6 @@ use std::collections::Spam; Position::new(0, 23), ), context: None, - partial_result_params: PartialResultParams::default(), - work_done_progress_params: WorkDoneProgressParams::default(), }); assert!(format!("{}", res).contains("HashMap")); eprintln!("completion took {:?}", completion_start.elapsed()); @@ -214,12 +211,8 @@ pub use std::collections::HashMap; options: FormattingOptions { tab_size: 4, insert_spaces: false, - insert_final_newline: None, - trim_final_newlines: None, - trim_trailing_whitespace: None, properties: HashMap::new(), }, - work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -279,11 +272,7 @@ pub use std::collections::HashMap; tab_size: 4, insert_spaces: false, properties: HashMap::new(), - insert_final_newline: None, - trim_final_newlines: None, - trim_trailing_whitespace: None, }, - work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -336,8 +325,6 @@ fn main() {} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(0, 4), Position::new(0, 7)), context: empty_context(), - partial_result_params: PartialResultParams::default(), - work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -369,8 +356,6 @@ fn main() {} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(2, 4), Position::new(2, 7)), context: empty_context(), - partial_result_params: PartialResultParams::default(), - work_done_progress_params: WorkDoneProgressParams::default(), }, json!([]), ); @@ -419,8 +404,6 @@ fn main() {{}} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(0, 4), Position::new(0, 7)), context: empty_context(), - partial_result_params: PartialResultParams::default(), - work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -452,8 +435,6 @@ fn main() {{}} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(2, 4), Position::new(2, 7)), context: empty_context(), - partial_result_params: PartialResultParams::default(), - work_done_progress_params: WorkDoneProgressParams::default(), }, json!([]), ); -- cgit v1.2.3 From b0a4765059c38e7b614d98015f7544ce0abc1bdf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 11 Dec 2019 18:34:01 +0100 Subject: Revert "Revert "Support LSP 3.15"" This reverts commit 1e0bf205eff81f04c0e1e6c208c3489327520c3f. --- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/caps.rs | 7 ++++++- crates/ra_lsp_server/src/main_loop.rs | 3 ++- crates/ra_lsp_server/src/main_loop/handlers.rs | 5 ++++- crates/ra_lsp_server/tests/heavy_tests/main.rs | 21 ++++++++++++++++++++- 5 files changed, 33 insertions(+), 5 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 41672eaff..c50cb8031 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" log = "0.4.3" -lsp-types = { version = "0.61.0", features = ["proposed"] } +lsp-types = { version = "0.63.0", features = ["proposed"] } rustc-hash = "1.0" parking_lot = "0.10.0" jod-thread = "0.1.0" diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index eea0965ed..4cb259360 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -5,7 +5,7 @@ use lsp_types::{ DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability, ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, - TextDocumentSyncOptions, TypeDefinitionProviderCapability, + TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, }; pub fn server_capabilities() -> ServerCapabilities { @@ -21,10 +21,14 @@ pub fn server_capabilities() -> ServerCapabilities { completion_provider: Some(CompletionOptions { resolve_provider: None, trigger_characters: Some(vec![":".to_string(), ".".to_string()]), + work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), signature_help_provider: Some(SignatureHelpOptions { trigger_characters: Some(vec!["(".to_string(), ",".to_string(), ")".to_string()]), + retrigger_characters: None, + work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), + declaration_provider: None, definition_provider: Some(true), type_definition_provider: Some(TypeDefinitionProviderCapability::Simple(true)), implementation_provider: Some(ImplementationProviderCapability::Simple(true)), @@ -44,6 +48,7 @@ pub fn server_capabilities() -> ServerCapabilities { folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), rename_provider: Some(RenameProviderCapability::Options(RenameOptions { prepare_provider: Some(true), + work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, })), document_link_provider: None, color_provider: None, diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 83845f1e0..158cac0be 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -520,7 +520,8 @@ fn on_notification( if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) { subs.remove_sub(FileId(file_id.0)); } - let params = req::PublishDiagnosticsParams { uri, diagnostics: Vec::new() }; + let params = + req::PublishDiagnosticsParams { uri, diagnostics: Vec::new(), version: None }; let not = notification_new::(params); msg_sender.send(not.into()).unwrap(); return Ok(()); diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 409583634..5b64b27cd 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -648,6 +648,7 @@ pub fn handle_code_action( diagnostics: None, edit: None, command: Some(command), + is_preferred: None, }; res.push(action.into()); } @@ -670,6 +671,7 @@ pub fn handle_code_action( diagnostics: None, edit: None, command: Some(command), + is_preferred: None, }; res.push(action.into()); } @@ -828,9 +830,10 @@ pub fn publish_diagnostics( source: Some("rust-analyzer".to_string()), message: d.message, related_information: None, + tags: None, }) .collect(); - Ok(req::PublishDiagnosticsParams { uri, diagnostics }) + Ok(req::PublishDiagnosticsParams { uri, diagnostics, version: None }) } pub fn publish_decorations( diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index cfbf16ea5..dff63a12d 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -4,7 +4,8 @@ use std::{collections::HashMap, time::Instant}; use lsp_types::{ CodeActionContext, DidOpenTextDocumentParams, DocumentFormattingParams, FormattingOptions, - Position, Range, TextDocumentItem, TextDocumentPositionParams, + PartialResultParams, Position, Range, TextDocumentItem, TextDocumentPositionParams, + WorkDoneProgressParams, }; use ra_lsp_server::req::{ CodeActionParams, CodeActionRequest, Completion, CompletionParams, DidOpenTextDocument, @@ -48,6 +49,8 @@ use std::collections::Spam; Position::new(0, 23), ), context: None, + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }); assert!(format!("{}", res).contains("HashMap")); eprintln!("completion took {:?}", completion_start.elapsed()); @@ -211,8 +214,12 @@ pub use std::collections::HashMap; options: FormattingOptions { tab_size: 4, insert_spaces: false, + insert_final_newline: None, + trim_final_newlines: None, + trim_trailing_whitespace: None, properties: HashMap::new(), }, + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -272,7 +279,11 @@ pub use std::collections::HashMap; tab_size: 4, insert_spaces: false, properties: HashMap::new(), + insert_final_newline: None, + trim_final_newlines: None, + trim_trailing_whitespace: None, }, + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -325,6 +336,8 @@ fn main() {} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(0, 4), Position::new(0, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -356,6 +369,8 @@ fn main() {} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(2, 4), Position::new(2, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([]), ); @@ -404,6 +419,8 @@ fn main() {{}} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(0, 4), Position::new(0, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([ { @@ -435,6 +452,8 @@ fn main() {{}} text_document: server.doc_id("src/lib.rs"), range: Range::new(Position::new(2, 4), Position::new(2, 7)), context: empty_context(), + partial_result_params: PartialResultParams::default(), + work_done_progress_params: WorkDoneProgressParams::default(), }, json!([]), ); -- cgit v1.2.3 From 6c6e6978eb5b1df611bde4677e078704fc3cc4ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 11 Dec 2019 18:34:22 +0100 Subject: Update lsp-types more --- crates/ra_lsp_server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index c50cb8031..e29b688fd 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" log = "0.4.3" -lsp-types = { version = "0.63.0", features = ["proposed"] } +lsp-types = { version = "0.63.1", features = ["proposed"] } rustc-hash = "1.0" parking_lot = "0.10.0" jod-thread = "0.1.0" -- cgit v1.2.3 From b4c8e5b9e95d28d3c18631e65caac4ff8c1f16d0 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Thu, 12 Dec 2019 07:55:05 -0500 Subject: Do not trigger signature help on close --- crates/ra_lsp_server/src/caps.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index 4cb259360..e0bb75666 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -24,7 +24,7 @@ pub fn server_capabilities() -> ServerCapabilities { work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), signature_help_provider: Some(SignatureHelpOptions { - trigger_characters: Some(vec!["(".to_string(), ",".to_string(), ")".to_string()]), + trigger_characters: Some(vec!["(".to_string(), ",".to_string()]), retrigger_characters: None, work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, }), -- cgit v1.2.3 From af4eb266457eb784010da28d80535f9fd38d4d1e Mon Sep 17 00:00:00 2001 From: oxalica Date: Fri, 13 Dec 2019 18:16:34 +0800 Subject: Support setting cargo features --- crates/ra_lsp_server/src/config.rs | 5 +++++ crates/ra_lsp_server/src/main_loop.rs | 1 + 2 files changed, 6 insertions(+) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/config.rs b/crates/ra_lsp_server/src/config.rs index 8045f3d60..67942aa41 100644 --- a/crates/ra_lsp_server/src/config.rs +++ b/crates/ra_lsp_server/src/config.rs @@ -9,6 +9,7 @@ use rustc_hash::FxHashMap; +use ra_project_model::CargoFeatures; use serde::{Deserialize, Deserializer}; /// Client provided initialization options @@ -37,6 +38,9 @@ pub struct ServerConfig { /// Fine grained feature flags to disable specific features. pub feature_flags: FxHashMap, + + /// Cargo feature configurations. + pub cargo_features: CargoFeatures, } impl Default for ServerConfig { @@ -49,6 +53,7 @@ impl Default for ServerConfig { max_inlay_hint_length: None, with_sysroot: true, feature_flags: FxHashMap::default(), + cargo_features: Default::default(), } } } diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 158cac0be..965e7c53c 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -67,6 +67,7 @@ pub fn main_loop( let workspace = ra_project_model::ProjectWorkspace::discover_with_sysroot( ws_root.as_path(), config.with_sysroot, + &config.cargo_features, ); match workspace { Ok(workspace) => loaded_workspaces.push(workspace), -- cgit v1.2.3 From a234b5a3cab6e134bfb644f91652532b68195f65 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 13 Dec 2019 16:08:47 -0500 Subject: LSP 3.15 supports the deprecated tag on completions --- crates/ra_lsp_server/src/conv.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index b13093cfe..5561f6270 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -130,6 +130,11 @@ impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem { deprecated: Some(self.deprecated()), ..Default::default() }; + + if self.deprecated() { + res.tags = Some(vec![lsp_types::CompletionItemTag::Deprecated]) + } + res.insert_text_format = Some(match self.insert_text_format() { InsertTextFormat::Snippet => lsp_types::InsertTextFormat::Snippet, InsertTextFormat::PlainText => lsp_types::InsertTextFormat::PlainText, -- cgit v1.2.3 From 324cbe839f3110bd4d51726d5a7afe29808ade02 Mon Sep 17 00:00:00 2001 From: Omer Ben-Amram Date: Sun, 15 Dec 2019 16:51:57 +0200 Subject: Lowercase drive letters on windows before sending to extension. --- crates/ra_lsp_server/src/world.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 927449b45..be3a5bfb8 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -22,6 +22,7 @@ use crate::{ main_loop::pending_requests::{CompletedRequest, LatestRequests}, LspError, Result, }; +use std::str::FromStr; #[derive(Debug, Clone)] pub struct Options { @@ -235,6 +236,9 @@ impl WorldSnapshot { let path = self.vfs.read().file2path(VfsFile(id.0)); let url = Url::from_file_path(&path) .map_err(|_| format!("can't convert path to url: {}", path.display()))?; + + #[cfg(target_os = "windows")] + let url = lowercase_drive_letter(&url); Ok(url) } @@ -279,3 +283,33 @@ impl WorldSnapshot { self.analysis.feature_flags() } } + +#[cfg(target_os = "windows")] +fn lowercase_drive_letter(url: &Url) -> Url { + let s = url.to_string(); + let drive_partition: Vec<&str> = s.rsplitn(2, ':').collect::>(); + + if drive_partition.len() == 1 { + return url.clone(); + } + + let joined = drive_partition[1].to_ascii_lowercase() + ":" + drive_partition[0]; + let url = Url::from_str(&joined).expect("This came from a valid `Url`"); + url +} + +#[test] +fn test_lowercase_drive_letter_with_drive() { + let url = Url::from_file_path("C:\\Test").unwrap(); + let url = lowercase_drive_letter(&url); + + assert_eq!(url.to_string(), "file:///c:/Test"); +} + +#[test] +fn test_drive_without_colon_passthrough() { + let url = Url::from_file_path(r#"\\localhost\C$\my_dir"#).expect("Should work"); + let url = lowercase_drive_letter(&url); + + assert_eq!(url.to_string(), "file:///C$/my_dir"); +} -- cgit v1.2.3 From ebf302d2610527c35b8fb794a03cc1c280c8a9d3 Mon Sep 17 00:00:00 2001 From: Omer Ben-Amram Date: Sun, 15 Dec 2019 17:03:39 +0200 Subject: move import inside cfg block --- crates/ra_lsp_server/src/world.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index be3a5bfb8..f139a5728 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -22,7 +22,6 @@ use crate::{ main_loop::pending_requests::{CompletedRequest, LatestRequests}, LspError, Result, }; -use std::str::FromStr; #[derive(Debug, Clone)] pub struct Options { @@ -286,6 +285,8 @@ impl WorldSnapshot { #[cfg(target_os = "windows")] fn lowercase_drive_letter(url: &Url) -> Url { + use std::str::FromStr; + let s = url.to_string(); let drive_partition: Vec<&str> = s.rsplitn(2, ':').collect::>(); -- cgit v1.2.3 From 2e2fae32dff6cab508768953bbd34b88b5bea166 Mon Sep 17 00:00:00 2001 From: Omer Ben-Amram Date: Sun, 15 Dec 2019 17:46:00 +0200 Subject: improved path checking to consider only paths that may contain a windows drive. --- crates/ra_lsp_server/src/world.rs | 64 +++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 20 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index f139a5728..63a820012 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -17,11 +17,13 @@ use ra_project_model::{get_rustc_cfg_options, ProjectWorkspace}; use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot, VfsTask, Watch}; use ra_vfs_glob::{Glob, RustPackageFilterBuilder}; use relative_path::RelativePathBuf; +use std::path::{Component, Prefix}; use crate::{ main_loop::pending_requests::{CompletedRequest, LatestRequests}, LspError, Result, }; +use std::str::FromStr; #[derive(Debug, Clone)] pub struct Options { @@ -233,11 +235,8 @@ impl WorldSnapshot { pub fn file_id_to_uri(&self, id: FileId) -> Result { let path = self.vfs.read().file2path(VfsFile(id.0)); - let url = Url::from_file_path(&path) - .map_err(|_| format!("can't convert path to url: {}", path.display()))?; + let url = url_from_path_with_drive_lowercasing(path)?; - #[cfg(target_os = "windows")] - let url = lowercase_drive_letter(&url); Ok(url) } @@ -283,34 +282,59 @@ impl WorldSnapshot { } } -#[cfg(target_os = "windows")] -fn lowercase_drive_letter(url: &Url) -> Url { - use std::str::FromStr; +/// Returns a `Url` object from a given path, will lowercase drive letters if present. +/// This will only happen when processing windows paths. +/// +/// When processing non-windows path, this is essentially the same as `Url::from_file_path`. +fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> Result { + let component_has_windows_drive = path + .as_ref() + .components() + .find(|comp| { + if let Component::Prefix(c) = comp { + match c.kind() { + Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, + _ => return false, + } + } + false + }) + .is_some(); + + // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. + if component_has_windows_drive { + let url_original = Url::from_file_path(&path) + .map_err(|_| format!("can't convert path to url: {}", path.as_ref().display()))?; + + let drive_partition: Vec<&str> = + url_original.as_str().rsplitn(2, ':').collect::>(); + + // There is a drive partition, but we never found a colon. + // This should not happen, but in this case we just pass it through. + if drive_partition.len() == 1 { + return Ok(url_original); + } - let s = url.to_string(); - let drive_partition: Vec<&str> = s.rsplitn(2, ':').collect::>(); + let joined = drive_partition[1].to_ascii_lowercase() + ":" + drive_partition[0]; + let url = Url::from_str(&joined).expect("This came from a valid `Url`"); - if drive_partition.len() == 1 { - return url.clone(); + Ok(url) + } else { + Ok(Url::from_file_path(&path) + .map_err(|_| format!("can't convert path to url: {}", path.as_ref().display()))?) } - - let joined = drive_partition[1].to_ascii_lowercase() + ":" + drive_partition[0]; - let url = Url::from_str(&joined).expect("This came from a valid `Url`"); - url } #[test] fn test_lowercase_drive_letter_with_drive() { - let url = Url::from_file_path("C:\\Test").unwrap(); - let url = lowercase_drive_letter(&url); + let url = url_from_path_with_drive_lowercasing("C:\\Test").unwrap(); assert_eq!(url.to_string(), "file:///c:/Test"); } #[test] fn test_drive_without_colon_passthrough() { - let url = Url::from_file_path(r#"\\localhost\C$\my_dir"#).expect("Should work"); - let url = lowercase_drive_letter(&url); + let url = url_from_path_with_drive_lowercasing(r#"\\localhost\C$\my_dir"#).unwrap(); - assert_eq!(url.to_string(), "file:///C$/my_dir"); + assert_eq!(url.to_string(), "file://localhost/C$/my_dir"); } -- cgit v1.2.3 From 40116af598ef51cab8a1059dceda7508f994387c Mon Sep 17 00:00:00 2001 From: Omer Ben-Amram Date: Sun, 15 Dec 2019 17:54:24 +0200 Subject: cfg gated tests that only work on windows. --- crates/ra_lsp_server/src/world.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 63a820012..8b48726ee 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -325,16 +325,22 @@ fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> Result { } } -#[test] -fn test_lowercase_drive_letter_with_drive() { - let url = url_from_path_with_drive_lowercasing("C:\\Test").unwrap(); - - assert_eq!(url.to_string(), "file:///c:/Test"); -} +// `Url` is not able to parse windows paths on unix machines. +#[cfg(target_os = "windows")] +#[cfg(test)] +mod path_conversion_windows_tests { + use super::url_from_path_with_drive_lowercasing; + #[test] + fn test_lowercase_drive_letter_with_drive() { + let url = url_from_path_with_drive_lowercasing("C:\\Test").unwrap(); + + assert_eq!(url.to_string(), "file:///c:/Test"); + } -#[test] -fn test_drive_without_colon_passthrough() { - let url = url_from_path_with_drive_lowercasing(r#"\\localhost\C$\my_dir"#).unwrap(); + #[test] + fn test_drive_without_colon_passthrough() { + let url = url_from_path_with_drive_lowercasing(r#"\\localhost\C$\my_dir"#).unwrap(); - assert_eq!(url.to_string(), "file://localhost/C$/my_dir"); + assert_eq!(url.to_string(), "file://localhost/C$/my_dir"); + } } -- cgit v1.2.3 From 6fba427bf35bebdc7aa08a241ecbe83a2f725127 Mon Sep 17 00:00:00 2001 From: Omer Ben-Amram Date: Sun, 15 Dec 2019 18:15:24 +0200 Subject: remove unnecessary turbofish. --- crates/ra_lsp_server/src/world.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 8b48726ee..16cc11e8c 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -306,8 +306,7 @@ fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> Result { let url_original = Url::from_file_path(&path) .map_err(|_| format!("can't convert path to url: {}", path.as_ref().display()))?; - let drive_partition: Vec<&str> = - url_original.as_str().rsplitn(2, ':').collect::>(); + let drive_partition: Vec<&str> = url_original.as_str().rsplitn(2, ':').collect(); // There is a drive partition, but we never found a colon. // This should not happen, but in this case we just pass it through. -- cgit v1.2.3 From 0d5d63a80ea08f2af439bcc72fff9b24d144c70d Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 20 Dec 2019 15:14:30 -0500 Subject: Clippy lints --- crates/ra_lsp_server/src/main_loop.rs | 2 +- crates/ra_lsp_server/src/main_loop/handlers.rs | 2 +- crates/ra_lsp_server/src/world.rs | 20 ++++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 965e7c53c..9e207415e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -131,7 +131,7 @@ pub fn main_loop( let feature_flags = { let mut ff = FeatureFlags::default(); for (flag, value) in config.feature_flags { - if let Err(_) = ff.set(flag.as_str(), value) { + if ff.set(flag.as_str(), value).is_err() { log::error!("unknown feature flag: {:?}", flag); show_message( req::MessageType::Error, diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5b64b27cd..5e3b1a73f 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -164,7 +164,7 @@ pub fn handle_on_type_formatting( // in `ra_ide`, the `on_type` invariant is that // `text.char_at(position) == typed_char`. - position.offset = position.offset - TextUnit::of_char('.'); + position.offset -= TextUnit::of_char('.'); let char_typed = params.ch.chars().next().unwrap_or('\0'); // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 16cc11e8c..f89b23089 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -287,19 +287,15 @@ impl WorldSnapshot { /// /// When processing non-windows path, this is essentially the same as `Url::from_file_path`. fn url_from_path_with_drive_lowercasing(path: impl AsRef) -> Result { - let component_has_windows_drive = path - .as_ref() - .components() - .find(|comp| { - if let Component::Prefix(c) = comp { - match c.kind() { - Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, - _ => return false, - } + let component_has_windows_drive = path.as_ref().components().any(|comp| { + if let Component::Prefix(c) = comp { + match c.kind() { + Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, + _ => return false, } - false - }) - .is_some(); + } + false + }); // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. if component_has_windows_drive { -- cgit v1.2.3 From 429199d4815a001e1b60089b4f34c3ae6b7204f9 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Fri, 20 Dec 2019 18:57:31 -0500 Subject: Use SelectionRange from LSP 3.15 --- crates/ra_lsp_server/Cargo.toml | 2 +- crates/ra_lsp_server/src/caps.rs | 11 ++++++----- crates/ra_lsp_server/src/req.rs | 27 +++------------------------ 3 files changed, 10 insertions(+), 30 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index e29b688fd..e826c10ef 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" log = "0.4.3" -lsp-types = { version = "0.63.1", features = ["proposed"] } +lsp-types = { version = "0.65.0", features = ["proposed"] } rustc-hash = "1.0" parking_lot = "0.10.0" jod-thread = "0.1.0" diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index e0bb75666..d812ff7ca 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -2,10 +2,11 @@ use lsp_types::{ CodeActionProviderCapability, CodeLensOptions, CompletionOptions, - DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability, - ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, - SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, - TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, + DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, + ImplementationProviderCapability, RenameOptions, RenameProviderCapability, + SelectionRangeProviderCapability, ServerCapabilities, SignatureHelpOptions, + TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, + TypeDefinitionProviderCapability, WorkDoneProgressOptions, }; pub fn server_capabilities() -> ServerCapabilities { @@ -44,7 +45,7 @@ pub fn server_capabilities() -> ServerCapabilities { first_trigger_character: "=".to_string(), more_trigger_character: Some(vec![".".to_string(), ">".to_string()]), }), - selection_range_provider: Some(GenericCapability::default()), + selection_range_provider: Some(SelectionRangeProviderCapability::Simple(true)), folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), rename_provider: Some(RenameProviderCapability::Options(RenameOptions { prepare_provider: Some(true), diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 39361b7e8..2a22b655c 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -10,8 +10,9 @@ pub use lsp_types::{ DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions, DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, FileSystemWatcher, Hover, InitializeResult, MessageType, PublishDiagnosticsParams, - ReferenceParams, Registration, RegistrationParams, ShowMessageParams, SignatureHelp, - TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, + ReferenceParams, Registration, RegistrationParams, SelectionRange, SelectionRangeParams, + ShowMessageParams, SignatureHelp, TextDocumentEdit, TextDocumentPositionParams, TextEdit, + WorkspaceEdit, WorkspaceSymbolParams, }; pub enum AnalyzerStatus {} @@ -67,28 +68,6 @@ pub struct ExpandMacroParams { pub position: Option, } -pub enum SelectionRangeRequest {} - -impl Request for SelectionRangeRequest { - type Params = SelectionRangeParams; - type Result = Vec; - const METHOD: &'static str = "textDocument/selectionRange"; -} - -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct SelectionRangeParams { - pub text_document: TextDocumentIdentifier, - pub positions: Vec, -} - -#[derive(Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct SelectionRange { - pub range: Range, - pub parent: Option>, -} - pub enum FindMatchingBrace {} impl Request for FindMatchingBrace { -- cgit v1.2.3 From 4ef5cd9a89fd5ee02ae655ba08486087af9ffcf4 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Sat, 21 Dec 2019 15:27:38 -0500 Subject: Add some module docs --- crates/ra_lsp_server/src/caps.rs | 2 +- crates/ra_lsp_server/src/conv.rs | 2 +- crates/ra_lsp_server/src/main_loop.rs | 3 ++- crates/ra_lsp_server/src/main_loop/handlers.rs | 3 ++- crates/ra_lsp_server/src/main_loop/pending_requests.rs | 2 +- crates/ra_lsp_server/src/main_loop/subscriptions.rs | 2 +- crates/ra_lsp_server/src/markdown.rs | 2 +- crates/ra_lsp_server/src/req.rs | 2 +- crates/ra_lsp_server/src/world.rs | 5 ++++- 9 files changed, 14 insertions(+), 9 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index d812ff7ca..eeca67ee1 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! Advertizes the capabilities of the LSP Server. use lsp_types::{ CodeActionProviderCapability, CodeLensOptions, CompletionOptions, diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 5561f6270..e93d4ea33 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! Convenience module responsible for translating between rust-analyzer's types and LSP types. use lsp_types::{ self, CreateFile, DiagnosticSeverity, DocumentChangeOperation, DocumentChanges, Documentation, diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 9e207415e..81fd08c91 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -1,4 +1,5 @@ -//! FIXME: write short doc here +//! The main loop of `ra_lsp_server` responsible for dispatching LSP requests/replies and +//! notifications back to the client. mod handlers; mod subscriptions; diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5e3b1a73f..39eb3df3e 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -1,4 +1,5 @@ -//! FIXME: write short doc here +//! This module is responsible for implementing handlers for Lanuage Server Protocol. +//! The majority of requests are fulfilled by calling into the `ra_ide` crate. use std::{fmt::Write as _, io::Write as _}; diff --git a/crates/ra_lsp_server/src/main_loop/pending_requests.rs b/crates/ra_lsp_server/src/main_loop/pending_requests.rs index e7ea7aa5b..2d2213464 100644 --- a/crates/ra_lsp_server/src/main_loop/pending_requests.rs +++ b/crates/ra_lsp_server/src/main_loop/pending_requests.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! Datastructures that keep track of inflight requests. use std::time::{Duration, Instant}; diff --git a/crates/ra_lsp_server/src/main_loop/subscriptions.rs b/crates/ra_lsp_server/src/main_loop/subscriptions.rs index 609b2adcc..b0bae90f5 100644 --- a/crates/ra_lsp_server/src/main_loop/subscriptions.rs +++ b/crates/ra_lsp_server/src/main_loop/subscriptions.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! Keeps track of file subscriptions. use ra_ide::FileId; use rustc_hash::FxHashSet; diff --git a/crates/ra_lsp_server/src/markdown.rs b/crates/ra_lsp_server/src/markdown.rs index f51fc4ade..76bef45cc 100644 --- a/crates/ra_lsp_server/src/markdown.rs +++ b/crates/ra_lsp_server/src/markdown.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! Transforms markdown pub(crate) fn format_docs(src: &str) -> String { let mut processed_lines = Vec::new(); diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 2a22b655c..b34e6f9b8 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! Defines `rust-analyzer` specific custom messages. use lsp_types::{Location, Position, Range, TextDocumentIdentifier, Url}; use rustc_hash::FxHashMap; diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index f89b23089..5e53b0278 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -1,4 +1,7 @@ -//! FIXME: write short doc here +//! The context or environment in which the language server functions. +//! In our server implementation this is know as the `WorldState`. +//! +//! Each tick provides an immutable snapshot of the state as `WorldSnapshot`. use std::{ path::{Path, PathBuf}, -- cgit v1.2.3 From 6acef5a7c088bcc1cdf8a64e28b8f20ddf9dcde7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 22 Dec 2019 13:56:19 +0100 Subject: Don't fire no-op changes after files are saved to disk --- crates/ra_lsp_server/src/main_loop.rs | 10 ++++++---- crates/ra_lsp_server/src/world.rs | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 81fd08c91..dda318e43 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -305,7 +305,6 @@ fn loop_turn( log::info!("queued count = {}", queue_count); } - let mut state_changed = false; match event { Event::Task(task) => { on_task(task, &connection.sender, &mut loop_state.pending_requests, world_state); @@ -313,7 +312,6 @@ fn loop_turn( } Event::Vfs(task) => { world_state.vfs.write().handle_task(task); - state_changed = true; } Event::Lib(lib) => { world_state.add_lib(lib); @@ -338,7 +336,6 @@ fn loop_turn( &mut loop_state.subscriptions, not, )?; - state_changed = true; } Message::Response(resp) => { let removed = loop_state.pending_responses.remove(&resp.id); @@ -349,7 +346,12 @@ fn loop_turn( }, }; - loop_state.pending_libraries.extend(world_state.process_changes()); + let mut state_changed = false; + if let Some(changes) = world_state.process_changes() { + state_changed = true; + loop_state.pending_libraries.extend(changes); + } + while loop_state.in_flight_libraries < MAX_IN_FLIGHT_LIBS && !loop_state.pending_libraries.is_empty() { diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 5e53b0278..79431e7e6 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -145,10 +145,10 @@ impl WorldState { /// FIXME: better API here pub fn process_changes( &mut self, - ) -> Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc)>)> { + ) -> Option)>)>> { let changes = self.vfs.write().commit_changes(); if changes.is_empty() { - return Vec::new(); + return None; } let mut libs = Vec::new(); let mut change = AnalysisChange::new(); @@ -182,7 +182,7 @@ impl WorldState { } } self.analysis_host.apply_change(change); - libs + Some(libs) } pub fn add_lib(&mut self, data: LibraryData) { -- cgit v1.2.3 From 700e74df4ab8d6c043eec524e993f721f13d2180 Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Mon, 23 Dec 2019 11:02:54 +0100 Subject: Bump lsp-types to 0.66.0 (fixes #2651) --- crates/ra_lsp_server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index e826c10ef..60cbc38a9 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0.34" serde = { version = "1.0.83", features = ["derive"] } crossbeam-channel = "0.4" log = "0.4.3" -lsp-types = { version = "0.65.0", features = ["proposed"] } +lsp-types = { version = "0.66.0", features = ["proposed"] } rustc-hash = "1.0" parking_lot = "0.10.0" jod-thread = "0.1.0" -- cgit v1.2.3