Skip to content

Commit 7be18d0

Browse files
committed
internal: remove client notification for unindexed projects
1 parent 5726e57 commit 7be18d0

File tree

5 files changed

+2
-116
lines changed

5 files changed

+2
-116
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ config_data! {
375375
/// Whether to show `can't find Cargo.toml` error message.
376376
notifications_cargoTomlNotFound: bool = true,
377377

378-
/// Whether to send an UnindexedProject notification to the client.
379-
notifications_unindexedProject: bool = false,
380-
381378
/// How many worker threads in the main loop. The default `null` means to pick automatically.
382379
numThreads: Option<usize> = None,
383380

@@ -831,7 +828,6 @@ pub enum FilesWatcher {
831828
#[derive(Debug, Clone)]
832829
pub struct NotificationsConfig {
833830
pub cargo_toml_not_found: bool,
834-
pub unindexed_project: bool,
835831
}
836832

837833
#[derive(Debug, Clone)]
@@ -1589,7 +1585,6 @@ impl Config {
15891585
pub fn notifications(&self) -> NotificationsConfig {
15901586
NotificationsConfig {
15911587
cargo_toml_not_found: self.notifications_cargoTomlNotFound().to_owned(),
1592-
unindexed_project: self.notifications_unindexedProject().to_owned(),
15931588
}
15941589
}
15951590

crates/rust-analyzer/src/handlers/notification.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ pub(crate) fn handle_did_open_text_document(
7272
}
7373

7474
state.vfs.write().0.set_file_contents(path, Some(params.text_document.text.into_bytes()));
75-
if state.config.notifications().unindexed_project
76-
|| state.config.discover_command().is_some()
77-
{
75+
if state.config.discover_command().is_some() {
7876
tracing::debug!("queuing task");
7977
let _ = state
8078
.deferred_task_queue

crates/rust-analyzer/src/lsp/ext.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -825,16 +825,3 @@ pub struct CompletionImport {
825825
pub struct ClientCommandOptions {
826826
pub commands: Vec<String>,
827827
}
828-
829-
pub enum UnindexedProject {}
830-
831-
impl Notification for UnindexedProject {
832-
type Params = UnindexedProjectParams;
833-
const METHOD: &'static str = "rust-analyzer/unindexedProject";
834-
}
835-
836-
#[derive(Deserialize, Serialize, Debug)]
837-
#[serde(rename_all = "camelCase")]
838-
pub struct UnindexedProjectParams {
839-
pub text_documents: Vec<TextDocumentIdentifier>,
840-
}

crates/rust-analyzer/tests/slow-tests/main.rs

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use lsp_types::{
3030
InlayHint, InlayHintLabel, InlayHintParams, PartialResultParams, Position, Range,
3131
RenameFilesParams, TextDocumentItem, TextDocumentPositionParams, WorkDoneProgressParams,
3232
};
33-
use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams, UnindexedProject};
33+
use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams};
3434
use serde_json::json;
3535
use stdx::format_to_acc;
3636
use test_utils::skip_slow_tests;
@@ -822,66 +822,6 @@ fn main() {{}}
822822
);
823823
}
824824

825-
#[test]
826-
fn test_opening_a_file_outside_of_indexed_workspace() {
827-
if skip_slow_tests() {
828-
return;
829-
}
830-
831-
let tmp_dir = TestDir::new();
832-
let path = tmp_dir.path();
833-
834-
let project = json!({
835-
"roots": [path],
836-
"crates": [ {
837-
"root_module": path.join("src/crate_one/lib.rs"),
838-
"deps": [],
839-
"edition": "2015",
840-
"cfg": [ "cfg_atom_1", "feature=\"cfg_1\""],
841-
} ]
842-
});
843-
844-
let code = format!(
845-
r#"
846-
//- /rust-project.json
847-
{project}
848-
849-
//- /src/crate_one/lib.rs
850-
mod bar;
851-
852-
fn main() {{}}
853-
"#,
854-
);
855-
856-
let server = Project::with_fixture(&code)
857-
.tmp_dir(tmp_dir)
858-
.with_config(serde_json::json!({
859-
"notifications": {
860-
"unindexedProject": true
861-
},
862-
}))
863-
.server()
864-
.wait_until_workspace_is_loaded();
865-
866-
let uri = server.doc_id("src/crate_two/lib.rs").uri;
867-
server.notification::<DidOpenTextDocument>(DidOpenTextDocumentParams {
868-
text_document: TextDocumentItem {
869-
uri: uri.clone(),
870-
language_id: "rust".to_owned(),
871-
version: 0,
872-
text: "/// Docs\nfn foo() {}".to_owned(),
873-
},
874-
});
875-
let expected = json!({
876-
"textDocuments": [
877-
{
878-
"uri": uri
879-
}
880-
]
881-
});
882-
server.expect_notification::<UnindexedProject>(expected);
883-
}
884-
885825
#[test]
886826
fn diagnostics_dont_block_typing() {
887827
if skip_slow_tests() {

crates/rust-analyzer/tests/slow-tests/support.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -231,40 +231,6 @@ impl Server {
231231
self.send_notification(r)
232232
}
233233

234-
pub(crate) fn expect_notification<N>(&self, expected: Value)
235-
where
236-
N: lsp_types::notification::Notification,
237-
N::Params: Serialize,
238-
{
239-
while let Some(Message::Notification(actual)) =
240-
recv_timeout(&self.client.receiver).unwrap_or_else(|_| panic!("timed out"))
241-
{
242-
if actual.method == N::METHOD {
243-
let actual = actual
244-
.clone()
245-
.extract::<Value>(N::METHOD)
246-
.expect("was not able to extract notification");
247-
248-
tracing::debug!(?actual, "got notification");
249-
if let Some((expected_part, actual_part)) = find_mismatch(&expected, &actual) {
250-
panic!(
251-
"JSON mismatch\nExpected:\n{}\nWas:\n{}\nExpected part:\n{}\nActual part:\n{}\n",
252-
to_string_pretty(&expected).unwrap(),
253-
to_string_pretty(&actual).unwrap(),
254-
to_string_pretty(expected_part).unwrap(),
255-
to_string_pretty(actual_part).unwrap(),
256-
);
257-
} else {
258-
tracing::debug!("successfully matched notification");
259-
return;
260-
}
261-
} else {
262-
continue;
263-
}
264-
}
265-
panic!("never got expected notification");
266-
}
267-
268234
#[track_caller]
269235
pub(crate) fn request<R>(&self, params: R::Params, expected_resp: Value)
270236
where

0 commit comments

Comments
 (0)