Skip to content

Commit 7eff641

Browse files
committed
internal: remove UnindexedProject notification
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
1 parent b2e3cec commit 7eff641

File tree

15 files changed

+13
-374
lines changed

15 files changed

+13
-374
lines changed

crates/rust-analyzer/src/config.rs

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

682-
/// Whether to send an UnindexedProject notification to the client.
683-
notifications_unindexedProject: bool = false,
684-
685682
/// How many worker threads in the main loop. The default `null` means to pick automatically.
686683
numThreads: Option<NumThreads> = None,
687684

@@ -1215,7 +1212,6 @@ pub enum FilesWatcher {
12151212
#[derive(Debug, Clone)]
12161213
pub struct NotificationsConfig {
12171214
pub cargo_toml_not_found: bool,
1218-
pub unindexed_project: bool,
12191215
}
12201216

12211217
#[derive(Debug, Clone)]
@@ -1776,7 +1772,6 @@ impl Config {
17761772
pub fn notifications(&self) -> NotificationsConfig {
17771773
NotificationsConfig {
17781774
cargo_toml_not_found: self.notifications_cargoTomlNotFound().to_owned(),
1779-
unindexed_project: self.notifications_unindexedProject().to_owned(),
17801775
}
17811776
}
17821777

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_workspace_config().is_some()
77-
|| state.config.notifications().unindexed_project
78-
{
76+
if state.config.discover_workspace_config().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
@@ -834,16 +834,3 @@ pub struct CompletionImport {
834834
pub struct ClientCommandOptions {
835835
pub commands: Vec<String>,
836836
}
837-
838-
pub enum UnindexedProject {}
839-
840-
impl Notification for UnindexedProject {
841-
type Params = UnindexedProjectParams;
842-
const METHOD: &'static str = "rust-analyzer/unindexedProject";
843-
}
844-
845-
#[derive(Deserialize, Serialize, Debug)]
846-
#[serde(rename_all = "camelCase")]
847-
pub struct UnindexedProjectParams {
848-
pub text_documents: Vec<TextDocumentIdentifier>,
849-
}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub(crate) enum QueuedTask {
9090
pub(crate) enum Task {
9191
Response(lsp_server::Response),
9292
DiscoverLinkedProjects(DiscoverProjectParam),
93-
ClientNotification(lsp_ext::UnindexedProjectParams),
9493
Retry(lsp_server::Request),
9594
Diagnostics(DiagnosticsGeneration, Vec<(FileId, Vec<lsp_types::Diagnostic>)>),
9695
DiscoverTest(lsp_ext::DiscoverTestResults),
@@ -642,9 +641,6 @@ impl GlobalState {
642641
fn handle_task(&mut self, prime_caches_progress: &mut Vec<PrimeCachesProgress>, task: Task) {
643642
match task {
644643
Task::Response(response) => self.respond(response),
645-
Task::ClientNotification(params) => {
646-
self.send_notification::<lsp_ext::UnindexedProject>(params)
647-
}
648644
// Only retry requests that haven't been cancelled. Otherwise we do unnecessary work.
649645
Task::Retry(req) if !self.is_completed(&req) => self.on_request(req),
650646
Task::Retry(_) => (),
@@ -825,12 +821,7 @@ impl GlobalState {
825821
from_proto::abs_path(&uri).expect("Unable to get AbsPath");
826822
let arg = DiscoverProjectParam::Path(path);
827823
sender.send(Task::DiscoverLinkedProjects(arg)).unwrap();
828-
} else if snap.config.notifications().unindexed_project {
829-
let params = lsp_ext::UnindexedProjectParams {
830-
text_documents: vec![lsp_types::TextDocumentIdentifier { uri }],
831-
};
832-
sender.send(Task::ClientNotification(params)).unwrap();
833-
};
824+
}
834825
} else {
835826
tracing::debug!(?uri, "is indexed");
836827
}

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

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

@@ -811,66 +811,6 @@ fn main() {{}}
811811
);
812812
}
813813

814-
#[test]
815-
fn test_opening_a_file_outside_of_indexed_workspace() {
816-
if skip_slow_tests() {
817-
return;
818-
}
819-
820-
let tmp_dir = TestDir::new();
821-
let path = tmp_dir.path();
822-
823-
let project = json!({
824-
"roots": [path],
825-
"crates": [ {
826-
"root_module": path.join("src/crate_one/lib.rs"),
827-
"deps": [],
828-
"edition": "2015",
829-
"cfg": [ "cfg_atom_1", "feature=\"cfg_1\""],
830-
} ]
831-
});
832-
833-
let code = format!(
834-
r#"
835-
//- /rust-project.json
836-
{project}
837-
838-
//- /src/crate_one/lib.rs
839-
mod bar;
840-
841-
fn main() {{}}
842-
"#,
843-
);
844-
845-
let server = Project::with_fixture(&code)
846-
.tmp_dir(tmp_dir)
847-
.with_config(serde_json::json!({
848-
"notifications": {
849-
"unindexedProject": true
850-
},
851-
}))
852-
.server()
853-
.wait_until_workspace_is_loaded();
854-
855-
let uri = server.doc_id("src/crate_two/lib.rs").uri;
856-
server.notification::<DidOpenTextDocument>(DidOpenTextDocumentParams {
857-
text_document: TextDocumentItem {
858-
uri: uri.clone(),
859-
language_id: "rust".to_owned(),
860-
version: 0,
861-
text: "/// Docs\nfn foo() {}".to_owned(),
862-
},
863-
});
864-
let expected = json!({
865-
"textDocuments": [
866-
{
867-
"uri": uri
868-
}
869-
]
870-
});
871-
server.expect_notification::<UnindexedProject>(expected);
872-
}
873-
874814
#[test]
875815
fn diagnostics_dont_block_typing() {
876816
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
@@ -616,25 +616,6 @@ Reloads project information (that is, re-executes `cargo metadata`).
616616

617617
Rebuilds build scripts and proc-macros, and runs the build scripts to reseed the build data.
618618

619-
## Unindexed Project
620-
621-
**Experimental Client Capability:** `{ "unindexedProject": boolean }`
622-
623-
**Method:** `rust-analyzer/unindexedProject`
624-
625-
**Notification:**
626-
627-
```typescript
628-
interface UnindexedProjectParams {
629-
/// A list of documents that rust-analyzer has determined are not indexed.
630-
textDocuments: lc.TextDocumentIdentifier[]
631-
}
632-
```
633-
634-
This notification is sent from the server to the client. The client is expected
635-
to determine the appropriate owners of `textDocuments` and update `linkedProjects`
636-
if an owner can be determined successfully.
637-
638619
## Server Status
639620

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

docs/user/generated_config.adoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,6 @@ Sets the LRU capacity of the specified queries.
830830
--
831831
Whether to show `can't find Cargo.toml` error message.
832832
--
833-
[[rust-analyzer.notifications.unindexedProject]]rust-analyzer.notifications.unindexedProject (default: `false`)::
834-
+
835-
--
836-
Whether to send an UnindexedProject notification to the client.
837-
--
838833
[[rust-analyzer.numThreads]]rust-analyzer.numThreads (default: `null`)::
839834
+
840835
--

editors/code/package.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,16 +2267,6 @@
22672267
}
22682268
}
22692269
},
2270-
{
2271-
"title": "notifications",
2272-
"properties": {
2273-
"rust-analyzer.notifications.unindexedProject": {
2274-
"markdownDescription": "Whether to send an UnindexedProject notification to the client.",
2275-
"default": false,
2276-
"type": "boolean"
2277-
}
2278-
}
2279-
},
22802270
{
22812271
"title": "general",
22822272
"properties": {

editors/code/src/client.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,7 @@ export async function createClient(
4242
const resp = await next(params, token);
4343
if (resp && Array.isArray(resp)) {
4444
return resp.map((val) => {
45-
return prepareVSCodeConfig(val, (key, cfg) => {
46-
// we only want to set discovered workspaces on the right key
47-
// and if a workspace has been discovered.
48-
if (
49-
key === "linkedProjects" &&
50-
config.discoveredWorkspaces.length > 0
51-
) {
52-
cfg[key] = config.discoveredWorkspaces;
53-
}
54-
});
45+
return prepareVSCodeConfig(val);
5546
});
5647
} else {
5748
return resp;

editors/code/src/config.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import * as Is from "vscode-languageclient/lib/common/utils/is";
22
import * as os from "os";
33
import * as path from "path";
44
import * as vscode from "vscode";
5-
import { type Env, log, unwrapUndefinable, expectNotUndefined } from "./util";
6-
import type { JsonProject } from "./rust_project";
7-
import type { Disposable } from "./ctx";
5+
import { Env, expectNotUndefined, log, unwrapUndefinable } from "./util";
6+
import { Disposable } from "vscode";
87

98
export type RunnableEnvCfgItem = {
109
mask?: string;
@@ -31,7 +30,6 @@ export class Config {
3130
);
3231

3332
constructor(disposables: Disposable[]) {
34-
this.discoveredWorkspaces = [];
3533
vscode.workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, disposables);
3634
this.refreshLogging();
3735
this.configureLanguage();
@@ -52,8 +50,6 @@ export class Config {
5250
log.info("Using configuration", Object.fromEntries(cfg));
5351
}
5452

55-
public discoveredWorkspaces: JsonProject[];
56-
5753
private async onDidChangeConfiguration(event: vscode.ConfigurationChangeEvent) {
5854
this.refreshLogging();
5955

@@ -342,18 +338,7 @@ export class Config {
342338
}
343339
}
344340

345-
// the optional `cb?` parameter is meant to be used to add additional
346-
// key/value pairs to the VS Code configuration. This needed for, e.g.,
347-
// including a `rust-project.json` into the `linkedProjects` key as part
348-
// of the configuration/InitializationParams _without_ causing VS Code
349-
// configuration to be written out to workspace-level settings. This is
350-
// undesirable behavior because rust-project.json files can be tens of
351-
// thousands of lines of JSON, most of which is not meant for humans
352-
// to interact with.
353-
export function prepareVSCodeConfig<T>(
354-
resp: T,
355-
cb?: (key: Extract<keyof T, string>, res: { [key: string]: any }) => void,
356-
): T {
341+
export function prepareVSCodeConfig<T>(resp: T): T {
357342
if (Is.string(resp)) {
358343
return substituteVSCodeVariableInString(resp) as T;
359344
} else if (resp && Is.array<any>(resp)) {
@@ -365,9 +350,6 @@ export function prepareVSCodeConfig<T>(
365350
for (const key in resp) {
366351
const val = resp[key];
367352
res[key] = prepareVSCodeConfig(val);
368-
if (cb) {
369-
cb(key, res);
370-
}
371353
}
372354
return res as T;
373355
}

0 commit comments

Comments
 (0)