Skip to content

Commit 46c3ffe

Browse files
committed
internal: remove UnindexedProject notification
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
1 parent 8a3f255 commit 46c3ffe

File tree

15 files changed

+11
-372
lines changed

15 files changed

+11
-372
lines changed

crates/rust-analyzer/src/config.rs

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

588-
/// Whether to send an UnindexedProject notification to the client.
589-
notifications_unindexedProject: bool = false,
590-
591588
/// How many worker threads in the main loop. The default `null` means to pick automatically.
592589
numThreads: Option<NumThreads> = None,
593590

@@ -1118,7 +1115,6 @@ pub enum FilesWatcher {
11181115
#[derive(Debug, Clone)]
11191116
pub struct NotificationsConfig {
11201117
pub cargo_toml_not_found: bool,
1121-
pub unindexed_project: bool,
11221118
}
11231119

11241120
#[derive(Debug, Clone)]
@@ -1828,7 +1824,6 @@ impl Config {
18281824
pub fn notifications(&self) -> NotificationsConfig {
18291825
NotificationsConfig {
18301826
cargo_toml_not_found: self.notifications_cargoTomlNotFound().to_owned(),
1831-
unindexed_project: self.notifications_unindexedProject().to_owned(),
18321827
}
18331828
}
18341829

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

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

7474
tracing::info!("New file content set {:?}", params.text_document.text);
7575
state.vfs.write().0.set_file_contents(path, Some(params.text_document.text.into_bytes()));
76-
if state.config.discover_command().is_some()
77-
|| state.config.notifications().unindexed_project
78-
{
76+
if state.config.discover_command().is_some() {
7977
tracing::debug!("queuing task");
8078
let _ = state
8179
.deferred_task_queue

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -856,16 +856,3 @@ pub struct CompletionImport {
856856
pub struct ClientCommandOptions {
857857
pub commands: Vec<String>,
858858
}
859-
860-
pub enum UnindexedProject {}
861-
862-
impl Notification for UnindexedProject {
863-
type Params = UnindexedProjectParams;
864-
const METHOD: &'static str = "rust-analyzer/unindexedProject";
865-
}
866-
867-
#[derive(Deserialize, Serialize, Debug)]
868-
#[serde(rename_all = "camelCase")]
869-
pub struct UnindexedProjectParams {
870-
pub text_documents: Vec<TextDocumentIdentifier>,
871-
}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ pub(crate) enum QueuedTask {
9191
pub(crate) enum Task {
9292
Response(lsp_server::Response),
9393
DiscoverLinkedProjects(DiscoverProjectParam),
94-
ClientNotification(lsp_ext::UnindexedProjectParams),
9594
Retry(lsp_server::Request),
9695
Diagnostics(DiagnosticsGeneration, Vec<(FileId, Vec<lsp_types::Diagnostic>)>),
9796
DiscoverTest(lsp_ext::DiscoverTestResults),
@@ -634,9 +633,6 @@ impl GlobalState {
634633
fn handle_task(&mut self, prime_caches_progress: &mut Vec<PrimeCachesProgress>, task: Task) {
635634
match task {
636635
Task::Response(response) => self.respond(response),
637-
Task::ClientNotification(params) => {
638-
self.send_notification::<lsp_ext::UnindexedProject>(params)
639-
}
640636
// Only retry requests that haven't been cancelled. Otherwise we do unnecessary work.
641637
Task::Retry(req) if !self.is_completed(&req) => self.on_request(req),
642638
Task::Retry(_) => (),
@@ -813,12 +809,7 @@ impl GlobalState {
813809
if snap.config.discover_command().is_some() {
814810
let arg = DiscoverProjectParam::Path(uri);
815811
sender.send(Task::DiscoverLinkedProjects(arg)).unwrap();
816-
} else if snap.config.notifications().unindexed_project {
817-
let params = lsp_ext::UnindexedProjectParams {
818-
text_documents: vec![lsp_types::TextDocumentIdentifier { uri }],
819-
};
820-
sender.send(Task::ClientNotification(params)).unwrap();
821-
};
812+
}
822813
} else {
823814
tracing::debug!(?uri, "is indexed");
824815
}

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

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use lsp_types::{
3131
InlayHint, InlayHintLabel, InlayHintParams, PartialResultParams, Position, Range,
3232
RenameFilesParams, TextDocumentItem, TextDocumentPositionParams, WorkDoneProgressParams,
3333
};
34-
use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams, UnindexedProject};
34+
use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams};
3535
use serde_json::json;
3636
use stdx::format_to_acc;
3737

@@ -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
@@ -256,40 +256,6 @@ impl Server {
256256
self.send_notification(r)
257257
}
258258

259-
pub(crate) fn expect_notification<N>(&self, expected: Value)
260-
where
261-
N: lsp_types::notification::Notification,
262-
N::Params: Serialize,
263-
{
264-
while let Some(Message::Notification(actual)) =
265-
recv_timeout(&self.client.receiver).unwrap_or_else(|_| panic!("timed out"))
266-
{
267-
if actual.method == N::METHOD {
268-
let actual = actual
269-
.clone()
270-
.extract::<Value>(N::METHOD)
271-
.expect("was not able to extract notification");
272-
273-
tracing::debug!(?actual, "got notification");
274-
if let Some((expected_part, actual_part)) = find_mismatch(&expected, &actual) {
275-
panic!(
276-
"JSON mismatch\nExpected:\n{}\nWas:\n{}\nExpected part:\n{}\nActual part:\n{}\n",
277-
to_string_pretty(&expected).unwrap(),
278-
to_string_pretty(&actual).unwrap(),
279-
to_string_pretty(expected_part).unwrap(),
280-
to_string_pretty(actual_part).unwrap(),
281-
);
282-
} else {
283-
tracing::debug!("successfully matched notification");
284-
return;
285-
}
286-
} else {
287-
continue;
288-
}
289-
}
290-
panic!("never got expected notification");
291-
}
292-
293259
#[track_caller]
294260
pub(crate) fn request<R>(&self, params: R::Params, expected_resp: Value)
295261
where

docs/dev/lsp-extensions.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -592,25 +592,6 @@ Reloads project information (that is, re-executes `cargo metadata`).
592592

593593
Rebuilds build scripts and proc-macros, and runs the build scripts to reseed the build data.
594594

595-
## Unindexed Project
596-
597-
**Experimental Client Capability:** `{ "unindexedProject": boolean }`
598-
599-
**Method:** `rust-analyzer/unindexedProject`
600-
601-
**Notification:**
602-
603-
```typescript
604-
interface UnindexedProjectParams {
605-
/// A list of documents that rust-analyzer has determined are not indexed.
606-
textDocuments: lc.TextDocumentIdentifier[]
607-
}
608-
```
609-
610-
This notification is sent from the server to the client. The client is expected
611-
to determine the appropriate owners of `textDocuments` and update `linkedProjects`
612-
if an owner can be determined successfully.
613-
614595
## Server Status
615596

616597
**Experimental Client Capability:** `{ "serverStatusNotification": boolean }`

docs/user/generated_config.adoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -811,11 +811,6 @@ Sets the LRU capacity of the specified queries.
811811
--
812812
Whether to show `can't find Cargo.toml` error message.
813813
--
814-
[[rust-analyzer.notifications.unindexedProject]]rust-analyzer.notifications.unindexedProject (default: `false`)::
815-
+
816-
--
817-
Whether to send an UnindexedProject notification to the client.
818-
--
819814
[[rust-analyzer.numThreads]]rust-analyzer.numThreads (default: `null`)::
820815
+
821816
--

editors/code/package.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,16 +2224,6 @@
22242224
}
22252225
}
22262226
},
2227-
{
2228-
"title": "notifications",
2229-
"properties": {
2230-
"rust-analyzer.notifications.unindexedProject": {
2231-
"markdownDescription": "Whether to send an UnindexedProject notification to the client.",
2232-
"default": false,
2233-
"type": "boolean"
2234-
}
2235-
}
2236-
},
22372227
{
22382228
"title": "general",
22392229
"properties": {

editors/code/src/client.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,7 @@ export async function createClient(
102102
const resp = await next(params, token);
103103
if (resp && Array.isArray(resp)) {
104104
return resp.map((val) => {
105-
return prepareVSCodeConfig(val, (key, cfg) => {
106-
// we only want to set discovered workspaces on the right key
107-
// and if a workspace has been discovered.
108-
if (
109-
key === "linkedProjects" &&
110-
config.discoveredWorkspaces.length > 0
111-
) {
112-
cfg[key] = config.discoveredWorkspaces;
113-
}
114-
});
105+
return prepareVSCodeConfig(val);
115106
});
116107
} else {
117108
return resp;

0 commit comments

Comments
 (0)