Skip to content

Commit ecc1de5

Browse files
committed
Remove rust-analyzer/addProject in favor of notifying r-a that configuration has changed
1 parent cef2d62 commit ecc1de5

File tree

7 files changed

+8
-65
lines changed

7 files changed

+8
-65
lines changed

crates/project-model/src/cfg_flag.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::{fmt, str::FromStr};
55

66
use cfg::CfgOptions;
7-
use serde::Serialize;
87

98
#[derive(Clone, Eq, PartialEq, Debug)]
109
pub enum CfgFlag {
@@ -39,18 +38,6 @@ impl<'de> serde::Deserialize<'de> for CfgFlag {
3938
}
4039
}
4140

42-
impl Serialize for CfgFlag {
43-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
44-
where
45-
S: serde::Serializer,
46-
{
47-
match self {
48-
CfgFlag::Atom(s) => serializer.serialize_str(s),
49-
CfgFlag::KeyValue { .. } => serializer.serialize_str(&format!("{}", &self)),
50-
}
51-
}
52-
}
53-
5441
impl Extend<CfgFlag> for CfgOptions {
5542
fn extend<T: IntoIterator<Item = CfgFlag>>(&mut self, iter: T) {
5643
for cfg_flag in iter {

crates/project-model/src/project_json.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use std::path::PathBuf;
5454
use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition};
5555
use paths::{AbsPath, AbsPathBuf};
5656
use rustc_hash::FxHashMap;
57-
use serde::{de, ser, Deserialize, Serialize};
57+
use serde::{de, Deserialize};
5858

5959
use crate::cfg_flag::CfgFlag;
6060

@@ -171,14 +171,14 @@ impl ProjectJson {
171171
}
172172
}
173173

174-
#[derive(Serialize, Deserialize, Debug, Clone)]
174+
#[derive(Deserialize, Debug, Clone)]
175175
pub struct ProjectJsonData {
176176
sysroot: Option<PathBuf>,
177177
sysroot_src: Option<PathBuf>,
178178
crates: Vec<CrateData>,
179179
}
180180

181-
#[derive(Serialize, Deserialize, Debug, Clone)]
181+
#[derive(Deserialize, Debug, Clone)]
182182
struct CrateData {
183183
display_name: Option<String>,
184184
root_module: PathBuf,
@@ -200,7 +200,7 @@ struct CrateData {
200200
repository: Option<String>,
201201
}
202202

203-
#[derive(Serialize, Deserialize, Debug, Clone)]
203+
#[derive(Deserialize, Debug, Clone)]
204204
#[serde(rename = "edition")]
205205
enum EditionData {
206206
#[serde(rename = "2015")]
@@ -221,16 +221,16 @@ impl From<EditionData> for Edition {
221221
}
222222
}
223223

224-
#[derive(Serialize, Deserialize, Debug, Clone)]
224+
#[derive(Deserialize, Debug, Clone)]
225225
struct DepData {
226226
/// Identifies a crate by position in the crates array.
227227
#[serde(rename = "crate")]
228228
krate: usize,
229-
#[serde(deserialize_with = "deserialize_crate_name", serialize_with = "serialize_crate_name")]
229+
#[serde(deserialize_with = "deserialize_crate_name")]
230230
name: CrateName,
231231
}
232232

233-
#[derive(Serialize, Deserialize, Debug, Clone)]
233+
#[derive(Deserialize, Debug, Clone)]
234234
struct CrateSource {
235235
include_dirs: Vec<PathBuf>,
236236
exclude_dirs: Vec<PathBuf>,
@@ -243,10 +243,3 @@ where
243243
let name = String::deserialize(de)?;
244244
CrateName::new(&name).map_err(|err| de::Error::custom(format!("invalid crate name: {err:?}")))
245245
}
246-
247-
fn serialize_crate_name<S>(crate_name: &CrateName, serializer: S) -> Result<S::Ok, S::Error>
248-
where
249-
S: ser::Serializer,
250-
{
251-
crate_name.serialize(serializer)
252-
}

crates/rust-analyzer/src/handlers.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use std::{
66
io::Write as _,
77
process::{self, Stdio},
8-
sync::Arc,
98
};
109

1110
use anyhow::Context;
@@ -53,21 +52,6 @@ pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> Result<
5352
Ok(())
5453
}
5554

56-
pub(crate) fn handle_add_project(
57-
state: &mut GlobalState,
58-
params: lsp_ext::AddProjectParams,
59-
) -> Result<()> {
60-
state.proc_macro_clients.clear();
61-
state.proc_macro_changed = false;
62-
63-
let config = Arc::make_mut(&mut state.config);
64-
config.add_linked_projects(params.project);
65-
66-
state.fetch_workspaces_queue.request_op("linked projects changed".to_string());
67-
state.fetch_build_data_queue.request_op("linked projects changed".to_string());
68-
Ok(())
69-
}
70-
7155
pub(crate) fn handle_cancel_flycheck(state: &mut GlobalState, _: ()) -> Result<()> {
7256
let _p = profile::span("handle_stop_flycheck");
7357
state.flycheck.iter().for_each(|flycheck| flycheck.cancel());

crates/rust-analyzer/src/lsp_ext.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use lsp_types::{
99
notification::Notification, CodeActionKind, DocumentOnTypeFormattingParams,
1010
PartialResultParams, Position, Range, TextDocumentIdentifier, WorkDoneProgressParams,
1111
};
12-
use project_model::ProjectJsonData;
1312
use serde::{Deserialize, Serialize};
1413

1514
use crate::line_index::PositionEncoding;
@@ -52,20 +51,6 @@ impl Request for ReloadWorkspace {
5251
const METHOD: &'static str = "rust-analyzer/reloadWorkspace";
5352
}
5453

55-
pub enum AddProject {}
56-
57-
impl Request for AddProject {
58-
type Params = AddProjectParams;
59-
type Result = ();
60-
const METHOD: &'static str = "rust-analyzer/addProject";
61-
}
62-
63-
#[derive(Serialize, Deserialize, Debug)]
64-
#[serde(rename_all = "camelCase")]
65-
pub struct AddProjectParams {
66-
pub project: Vec<ProjectJsonData>,
67-
}
68-
6954
pub enum SyntaxTree {}
7055

7156
impl Request for SyntaxTree {

crates/rust-analyzer/src/main_loop.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ impl GlobalState {
627627
.on_sync_mut::<lsp_ext::ReloadWorkspace>(handlers::handle_workspace_reload)
628628
.on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)
629629
.on_sync_mut::<lsp_ext::ShuffleCrateGraph>(handlers::handle_shuffle_crate_graph)
630-
.on_sync_mut::<lsp_ext::AddProject>(handlers::handle_add_project)
631630
.on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)
632631
.on_sync::<lsp_ext::OnEnter>(handlers::handle_on_enter)
633632
.on_sync::<lsp_types::request::SelectionRangeRequest>(handlers::handle_selection_range)

editors/code/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as lc from "vscode-languageclient/node";
33
import * as vscode from "vscode";
44
import * as ra from "../src/lsp_ext";
55
import * as Is from "vscode-languageclient/lib/common/utils/is";
6-
import { assert, log } from "./util";
6+
import { assert } from "./util";
77
import * as diagnostics from "./diagnostics";
88
import { WorkspaceEdit } from "vscode";
99
import { Config, prepareVSCodeConfig } from "./config";

editors/code/src/lsp_ext.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
4343
"rust-analyzer/relatedTests"
4444
);
4545
export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
46-
export const addProject = new lc.RequestType<AddProjectParams, string, void>(
47-
"rust-analyzer/addProject"
48-
);
4946

5047
export const runFlycheck = new lc.NotificationType<{
5148
textDocument: lc.TextDocumentIdentifier | null;
@@ -72,8 +69,6 @@ export const viewItemTree = new lc.RequestType<ViewItemTreeParams, string, void>
7269

7370
export type AnalyzerStatusParams = { textDocument?: lc.TextDocumentIdentifier };
7471

75-
export type AddProjectParams = { project: JsonProject[] };
76-
7772
export type ExpandMacroParams = {
7873
textDocument: lc.TextDocumentIdentifier;
7974
position: lc.Position;

0 commit comments

Comments
 (0)