diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 14a0550e558ce..4a09ef21adc74 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -679,9 +679,6 @@ config_data! { /// Whether to show `can't find Cargo.toml` error message. notifications_cargoTomlNotFound: bool = true, - /// Whether to send an UnindexedProject notification to the client. - notifications_unindexedProject: bool = false, - /// How many worker threads in the main loop. The default `null` means to pick automatically. numThreads: Option = None, @@ -1236,7 +1233,6 @@ pub enum FilesWatcher { #[derive(Debug, Clone)] pub struct NotificationsConfig { pub cargo_toml_not_found: bool, - pub unindexed_project: bool, } #[derive(Debug, Clone)] @@ -1800,7 +1796,6 @@ impl Config { pub fn notifications(&self) -> NotificationsConfig { NotificationsConfig { cargo_toml_not_found: self.notifications_cargoTomlNotFound().to_owned(), - unindexed_project: self.notifications_unindexedProject().to_owned(), } } diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs index 06e893f0f4719..4b14dcfc3721b 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs @@ -73,9 +73,7 @@ pub(crate) fn handle_did_open_text_document( tracing::info!("New file content set {:?}", params.text_document.text); state.vfs.write().0.set_file_contents(path, Some(params.text_document.text.into_bytes())); - if state.config.discover_workspace_config().is_some() - || state.config.notifications().unindexed_project - { + if state.config.discover_workspace_config().is_some() { tracing::debug!("queuing task"); let _ = state .deferred_task_queue diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs index efa5d47fbaab1..813e9fcd476a5 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs @@ -834,16 +834,3 @@ pub struct CompletionImport { pub struct ClientCommandOptions { pub commands: Vec, } - -pub enum UnindexedProject {} - -impl Notification for UnindexedProject { - type Params = UnindexedProjectParams; - const METHOD: &'static str = "rust-analyzer/unindexedProject"; -} - -#[derive(Deserialize, Serialize, Debug)] -#[serde(rename_all = "camelCase")] -pub struct UnindexedProjectParams { - pub text_documents: Vec, -} diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs index 1b4bff6225768..e64095ba9eebb 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs @@ -90,7 +90,6 @@ pub(crate) enum QueuedTask { pub(crate) enum Task { Response(lsp_server::Response), DiscoverLinkedProjects(DiscoverProjectParam), - ClientNotification(lsp_ext::UnindexedProjectParams), Retry(lsp_server::Request), Diagnostics(DiagnosticsGeneration, Vec<(FileId, Vec)>), DiscoverTest(lsp_ext::DiscoverTestResults), @@ -642,9 +641,6 @@ impl GlobalState { fn handle_task(&mut self, prime_caches_progress: &mut Vec, task: Task) { match task { Task::Response(response) => self.respond(response), - Task::ClientNotification(params) => { - self.send_notification::(params) - } // Only retry requests that haven't been cancelled. Otherwise we do unnecessary work. Task::Retry(req) if !self.is_completed(&req) => self.on_request(req), Task::Retry(_) => (), @@ -825,12 +821,7 @@ impl GlobalState { from_proto::abs_path(&uri).expect("Unable to get AbsPath"); let arg = DiscoverProjectParam::Path(path); sender.send(Task::DiscoverLinkedProjects(arg)).unwrap(); - } else if snap.config.notifications().unindexed_project { - let params = lsp_ext::UnindexedProjectParams { - text_documents: vec![lsp_types::TextDocumentIdentifier { uri }], - }; - sender.send(Task::ClientNotification(params)).unwrap(); - }; + } } else { tracing::debug!(?uri, "is indexed"); } diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs index 6bbf82a77547d..b1ef48377178b 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs @@ -27,7 +27,7 @@ use lsp_types::{ InlayHint, InlayHintLabel, InlayHintParams, PartialResultParams, Position, Range, RenameFilesParams, TextDocumentItem, TextDocumentPositionParams, WorkDoneProgressParams, }; -use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams, UnindexedProject}; +use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams}; use serde_json::json; use stdx::format_to_acc; @@ -811,66 +811,6 @@ fn main() {{}} ); } -#[test] -fn test_opening_a_file_outside_of_indexed_workspace() { - if skip_slow_tests() { - return; - } - - let tmp_dir = TestDir::new(); - let path = tmp_dir.path(); - - let project = json!({ - "roots": [path], - "crates": [ { - "root_module": path.join("src/crate_one/lib.rs"), - "deps": [], - "edition": "2015", - "cfg": [ "cfg_atom_1", "feature=\"cfg_1\""], - } ] - }); - - let code = format!( - r#" -//- /rust-project.json -{project} - -//- /src/crate_one/lib.rs -mod bar; - -fn main() {{}} -"#, - ); - - let server = Project::with_fixture(&code) - .tmp_dir(tmp_dir) - .with_config(serde_json::json!({ - "notifications": { - "unindexedProject": true - }, - })) - .server() - .wait_until_workspace_is_loaded(); - - let uri = server.doc_id("src/crate_two/lib.rs").uri; - server.notification::(DidOpenTextDocumentParams { - text_document: TextDocumentItem { - uri: uri.clone(), - language_id: "rust".to_owned(), - version: 0, - text: "/// Docs\nfn foo() {}".to_owned(), - }, - }); - let expected = json!({ - "textDocuments": [ - { - "uri": uri - } - ] - }); - server.expect_notification::(expected); -} - #[test] fn diagnostics_dont_block_typing() { if skip_slow_tests() { diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/support.rs b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/support.rs index 66100971fbf34..081ee5fa3e4e7 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/support.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/support.rs @@ -256,40 +256,6 @@ impl Server { self.send_notification(r) } - pub(crate) fn expect_notification(&self, expected: Value) - where - N: lsp_types::notification::Notification, - N::Params: Serialize, - { - while let Some(Message::Notification(actual)) = - recv_timeout(&self.client.receiver).unwrap_or_else(|_| panic!("timed out")) - { - if actual.method == N::METHOD { - let actual = actual - .clone() - .extract::(N::METHOD) - .expect("was not able to extract notification"); - - tracing::debug!(?actual, "got notification"); - if let Some((expected_part, actual_part)) = find_mismatch(&expected, &actual) { - panic!( - "JSON mismatch\nExpected:\n{}\nWas:\n{}\nExpected part:\n{}\nActual part:\n{}\n", - to_string_pretty(&expected).unwrap(), - to_string_pretty(&actual).unwrap(), - to_string_pretty(expected_part).unwrap(), - to_string_pretty(actual_part).unwrap(), - ); - } else { - tracing::debug!("successfully matched notification"); - return; - } - } else { - continue; - } - } - panic!("never got expected notification"); - } - #[track_caller] pub(crate) fn request(&self, params: R::Params, expected_resp: Value) where diff --git a/src/tools/rust-analyzer/docs/dev/lsp-extensions.md b/src/tools/rust-analyzer/docs/dev/lsp-extensions.md index fbb4fc6113f9a..a29b42a857c95 100644 --- a/src/tools/rust-analyzer/docs/dev/lsp-extensions.md +++ b/src/tools/rust-analyzer/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@