Skip to content

Commit 14ddae7

Browse files
committed
internal: remove client notification for unindexed projects
1 parent ba28ffc commit 14ddae7

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
@@ -823,16 +823,3 @@ pub struct CompletionImport {
823823
pub struct ClientCommandOptions {
824824
pub commands: Vec<String>,
825825
}
826-
827-
pub enum UnindexedProject {}
828-
829-
impl Notification for UnindexedProject {
830-
type Params = UnindexedProjectParams;
831-
const METHOD: &'static str = "rust-analyzer/unindexedProject";
832-
}
833-
834-
#[derive(Deserialize, Serialize, Debug)]
835-
#[serde(rename_all = "camelCase")]
836-
pub struct UnindexedProjectParams {
837-
pub text_documents: Vec<TextDocumentIdentifier>,
838-
}

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;
@@ -729,66 +729,6 @@ fn main() {{}}
729729
);
730730
}
731731

732-
#[test]
733-
fn test_opening_a_file_outside_of_indexed_workspace() {
734-
if skip_slow_tests() {
735-
return;
736-
}
737-
738-
let tmp_dir = TestDir::new();
739-
let path = tmp_dir.path();
740-
741-
let project = json!({
742-
"roots": [path],
743-
"crates": [ {
744-
"root_module": path.join("src/crate_one/lib.rs"),
745-
"deps": [],
746-
"edition": "2015",
747-
"cfg": [ "cfg_atom_1", "feature=\"cfg_1\""],
748-
} ]
749-
});
750-
751-
let code = format!(
752-
r#"
753-
//- /rust-project.json
754-
{project}
755-
756-
//- /src/crate_one/lib.rs
757-
mod bar;
758-
759-
fn main() {{}}
760-
"#,
761-
);
762-
763-
let server = Project::with_fixture(&code)
764-
.tmp_dir(tmp_dir)
765-
.with_config(serde_json::json!({
766-
"notifications": {
767-
"unindexedProject": true
768-
},
769-
}))
770-
.server()
771-
.wait_until_workspace_is_loaded();
772-
773-
let uri = server.doc_id("src/crate_two/lib.rs").uri;
774-
server.notification::<DidOpenTextDocument>(DidOpenTextDocumentParams {
775-
text_document: TextDocumentItem {
776-
uri: uri.clone(),
777-
language_id: "rust".to_owned(),
778-
version: 0,
779-
text: "/// Docs\nfn foo() {}".to_owned(),
780-
},
781-
});
782-
let expected = json!({
783-
"textDocuments": [
784-
{
785-
"uri": uri
786-
}
787-
]
788-
});
789-
server.expect_notification::<UnindexedProject>(expected);
790-
}
791-
792732
#[test]
793733
fn diagnostics_dont_block_typing() {
794734
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)