Unnamed repository; edit this file 'description' to name the repository.
Remove `rust-analyzer/addProject` in favor of notifying r-a that configuration has changed
David Barsky 2023-03-14
parent 8d9bff0 · commit 56273b3
-rw-r--r--crates/project-model/src/cfg_flag.rs13
-rw-r--r--crates/project-model/src/project_json.rs21
-rw-r--r--crates/rust-analyzer/src/handlers.rs16
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs15
-rw-r--r--crates/rust-analyzer/src/main_loop.rs1
-rw-r--r--editors/code/src/client.ts2
-rw-r--r--editors/code/src/lsp_ext.ts5
7 files changed, 8 insertions, 65 deletions
diff --git a/crates/project-model/src/cfg_flag.rs b/crates/project-model/src/cfg_flag.rs
index 2a4767970c..c134b78ab3 100644
--- a/crates/project-model/src/cfg_flag.rs
+++ b/crates/project-model/src/cfg_flag.rs
@@ -4,7 +4,6 @@
use std::{fmt, str::FromStr};
use cfg::CfgOptions;
-use serde::Serialize;
#[derive(Clone, Eq, PartialEq, Debug)]
pub enum CfgFlag {
@@ -39,18 +38,6 @@ impl<'de> serde::Deserialize<'de> for CfgFlag {
}
}
-impl Serialize for CfgFlag {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: serde::Serializer,
- {
- match self {
- CfgFlag::Atom(s) => serializer.serialize_str(s),
- CfgFlag::KeyValue { .. } => serializer.serialize_str(&format!("{}", &self)),
- }
- }
-}
-
impl Extend<CfgFlag> for CfgOptions {
fn extend<T: IntoIterator<Item = CfgFlag>>(&mut self, iter: T) {
for cfg_flag in iter {
diff --git a/crates/project-model/src/project_json.rs b/crates/project-model/src/project_json.rs
index 0f779e5307..4b2448e47f 100644
--- a/crates/project-model/src/project_json.rs
+++ b/crates/project-model/src/project_json.rs
@@ -54,7 +54,7 @@ use std::path::PathBuf;
use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition};
use paths::{AbsPath, AbsPathBuf};
use rustc_hash::FxHashMap;
-use serde::{de, ser, Deserialize, Serialize};
+use serde::{de, Deserialize};
use crate::cfg_flag::CfgFlag;
@@ -171,14 +171,14 @@ impl ProjectJson {
}
}
-#[derive(Serialize, Deserialize, Debug, Clone)]
+#[derive(Deserialize, Debug, Clone)]
pub struct ProjectJsonData {
sysroot: Option<PathBuf>,
sysroot_src: Option<PathBuf>,
crates: Vec<CrateData>,
}
-#[derive(Serialize, Deserialize, Debug, Clone)]
+#[derive(Deserialize, Debug, Clone)]
struct CrateData {
display_name: Option<String>,
root_module: PathBuf,
@@ -200,7 +200,7 @@ struct CrateData {
repository: Option<String>,
}
-#[derive(Serialize, Deserialize, Debug, Clone)]
+#[derive(Deserialize, Debug, Clone)]
#[serde(rename = "edition")]
enum EditionData {
#[serde(rename = "2015")]
@@ -221,16 +221,16 @@ impl From<EditionData> for Edition {
}
}
-#[derive(Serialize, Deserialize, Debug, Clone)]
+#[derive(Deserialize, Debug, Clone)]
struct DepData {
/// Identifies a crate by position in the crates array.
#[serde(rename = "crate")]
krate: usize,
- #[serde(deserialize_with = "deserialize_crate_name", serialize_with = "serialize_crate_name")]
+ #[serde(deserialize_with = "deserialize_crate_name")]
name: CrateName,
}
-#[derive(Serialize, Deserialize, Debug, Clone)]
+#[derive(Deserialize, Debug, Clone)]
struct CrateSource {
include_dirs: Vec<PathBuf>,
exclude_dirs: Vec<PathBuf>,
@@ -243,10 +243,3 @@ where
let name = String::deserialize(de)?;
CrateName::new(&name).map_err(|err| de::Error::custom(format!("invalid crate name: {err:?}")))
}
-
-fn serialize_crate_name<S>(crate_name: &CrateName, serializer: S) -> Result<S::Ok, S::Error>
-where
- S: ser::Serializer,
-{
- crate_name.serialize(serializer)
-}
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 4ac76557df..d7fc889132 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -5,7 +5,6 @@
use std::{
io::Write as _,
process::{self, Stdio},
- sync::Arc,
};
use anyhow::Context;
@@ -53,21 +52,6 @@ pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> Result<
Ok(())
}
-pub(crate) fn handle_add_project(
- state: &mut GlobalState,
- params: lsp_ext::AddProjectParams,
-) -> Result<()> {
- state.proc_macro_clients.clear();
- state.proc_macro_changed = false;
-
- let config = Arc::make_mut(&mut state.config);
- config.add_linked_projects(params.project);
-
- state.fetch_workspaces_queue.request_op("linked projects changed".to_string());
- state.fetch_build_data_queue.request_op("linked projects changed".to_string());
- Ok(())
-}
-
pub(crate) fn handle_cancel_flycheck(state: &mut GlobalState, _: ()) -> Result<()> {
let _p = profile::span("handle_stop_flycheck");
state.flycheck.iter().for_each(|flycheck| flycheck.cancel());
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index e6caebe353..c7b513db98 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -9,7 +9,6 @@ use lsp_types::{
notification::Notification, CodeActionKind, DocumentOnTypeFormattingParams,
PartialResultParams, Position, Range, TextDocumentIdentifier, WorkDoneProgressParams,
};
-use project_model::ProjectJsonData;
use serde::{Deserialize, Serialize};
use crate::line_index::PositionEncoding;
@@ -52,20 +51,6 @@ impl Request for ReloadWorkspace {
const METHOD: &'static str = "rust-analyzer/reloadWorkspace";
}
-pub enum AddProject {}
-
-impl Request for AddProject {
- type Params = AddProjectParams;
- type Result = ();
- const METHOD: &'static str = "rust-analyzer/addProject";
-}
-
-#[derive(Serialize, Deserialize, Debug)]
-#[serde(rename_all = "camelCase")]
-pub struct AddProjectParams {
- pub project: Vec<ProjectJsonData>,
-}
-
pub enum SyntaxTree {}
impl Request for SyntaxTree {
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 1cc771552a..dd0804b439 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -625,7 +625,6 @@ impl GlobalState {
.on_sync_mut::<lsp_ext::ReloadWorkspace>(handlers::handle_workspace_reload)
.on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)
.on_sync_mut::<lsp_ext::ShuffleCrateGraph>(handlers::handle_shuffle_crate_graph)
- .on_sync_mut::<lsp_ext::AddProject>(handlers::handle_add_project)
.on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)
.on_sync::<lsp_ext::OnEnter>(handlers::handle_on_enter)
.on_sync::<lsp_types::request::SelectionRangeRequest>(handlers::handle_selection_range)
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 9103ef2f8f..03f5d43051 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -3,7 +3,7 @@ import * as lc from "vscode-languageclient/node";
import * as vscode from "vscode";
import * as ra from "../src/lsp_ext";
import * as Is from "vscode-languageclient/lib/common/utils/is";
-import { assert, log } from "./util";
+import { assert } from "./util";
import * as diagnostics from "./diagnostics";
import { WorkspaceEdit } from "vscode";
import { Config, prepareVSCodeConfig } from "./config";
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 942573c0f1..872d7199b8 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -43,9 +43,6 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
"rust-analyzer/relatedTests"
);
export const reloadWorkspace = new lc.RequestType0<null, void>("rust-analyzer/reloadWorkspace");
-export const addProject = new lc.RequestType<AddProjectParams, string, void>(
- "rust-analyzer/addProject"
-);
export const runFlycheck = new lc.NotificationType<{
textDocument: lc.TextDocumentIdentifier | null;
@@ -72,8 +69,6 @@ export const viewItemTree = new lc.RequestType<ViewItemTreeParams, string, void>
export type AnalyzerStatusParams = { textDocument?: lc.TextDocumentIdentifier };
-export type AddProjectParams = { project: JsonProject[] };
-
export type ExpandMacroParams = {
textDocument: lc.TextDocumentIdentifier;
position: lc.Position;