From 952da31f44b717d5679c1c0baffcd998c0f67266 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 3 Sep 2018 23:32:42 +0300 Subject: switch to internal feedback --- crates/server/src/main.rs | 2 +- crates/server/src/main_loop/mod.rs | 14 ++++++++++++-- crates/server/src/project_model.rs | 11 ++++------- crates/server/src/req.rs | 9 ++++----- 4 files changed, 21 insertions(+), 15 deletions(-) (limited to 'crates/server/src') diff --git a/crates/server/src/main.rs b/crates/server/src/main.rs index 119f020d3..5c0166a61 100644 --- a/crates/server/src/main.rs +++ b/crates/server/src/main.rs @@ -34,7 +34,7 @@ fn main_inner() -> Result<()> { let root = ::std::env::current_dir()?; run_server( m::server_capabilities(), - |r, s| m::main_loop(root, r, s), + |r, s| m::main_loop(false, root, r, s), receiver, sender, )?; diff --git a/crates/server/src/main_loop/mod.rs b/crates/server/src/main_loop/mod.rs index 3d131274f..b66a24de1 100644 --- a/crates/server/src/main_loop/mod.rs +++ b/crates/server/src/main_loop/mod.rs @@ -32,6 +32,7 @@ enum Task { } pub fn main_loop( + internal_mode: bool, root: PathBuf, msg_receriver: &mut Receiver, msg_sender: &mut Sender, @@ -47,6 +48,7 @@ pub fn main_loop( let mut pending_requests = HashMap::new(); let mut subs = Subscriptions::new(); let main_res = main_loop_inner( + internal_mode, root, &pool, msg_sender, @@ -80,6 +82,7 @@ pub fn main_loop( } fn main_loop_inner( + internal_mode: bool, ws_root: PathBuf, pool: &ThreadPool, msg_sender: &mut Sender, @@ -145,8 +148,7 @@ fn main_loop_inner( match ws { Ok(ws) => { let workspaces = vec![ws]; - let not = RawNotification::new::(&workspaces); - msg_sender.send(RawMessage::Notification(not)); + feedback(internal_mode, "workspace loaded", msg_sender); for ws in workspaces.iter() { for pkg in ws.packages().filter(|pkg| !pkg.is_member(ws)) { debug!("sending root, {}", pkg.root(ws).to_path_buf().display()); @@ -404,3 +406,11 @@ fn update_file_notifications_on_threadpool( } }); } + +fn feedback(intrnal_mode: bool, msg: &str, sender: &Sender) { + if !intrnal_mode { + return; + } + let not = RawNotification::new::(&msg.to_string()); + sender.send(RawMessage::Notification(not)); +} diff --git a/crates/server/src/project_model.rs b/crates/server/src/project_model.rs index 517836e62..a712106d9 100644 --- a/crates/server/src/project_model.rs +++ b/crates/server/src/project_model.rs @@ -11,7 +11,7 @@ use { thread_watcher::ThreadWatcher, }; -#[derive(Debug, Serialize, Clone)] +#[derive(Debug, Clone)] pub struct CargoWorkspace { packages: Vec, targets: Vec, @@ -22,7 +22,7 @@ pub struct Package(usize); #[derive(Clone, Copy, Debug, Serialize)] pub struct Target(usize); -#[derive(Debug, Serialize, Clone)] +#[derive(Debug, Clone)] struct PackageData { name: SmolStr, manifest: PathBuf, @@ -30,7 +30,7 @@ struct PackageData { is_member: bool, } -#[derive(Debug, Serialize, Clone)] +#[derive(Debug, Clone)] struct TargetData { pkg: Package, name: SmolStr, @@ -38,7 +38,7 @@ struct TargetData { kind: TargetKind, } -#[derive(Debug, Serialize, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum TargetKind { Bin, Lib, Example, Test, Bench, Other, } @@ -47,9 +47,6 @@ impl Package { pub fn name(self, ws: &CargoWorkspace) -> &str { ws.pkg(self).name.as_str() } - pub fn manifest(self, ws: &CargoWorkspace) -> &Path { - ws.pkg(self).manifest.as_path() - } pub fn root(self, ws: &CargoWorkspace) -> &Path { ws.pkg(self).manifest.parent().unwrap() } diff --git a/crates/server/src/req.rs b/crates/server/src/req.rs index b9e0c3796..4af61dbbd 100644 --- a/crates/server/src/req.rs +++ b/crates/server/src/req.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use languageserver_types::{TextDocumentIdentifier, Range, Url, Position, Location}; use url_serde; -use project_model::CargoWorkspace; pub use languageserver_types::{ request::*, notification::*, @@ -169,9 +168,9 @@ pub enum FileSystemEdit { } } -pub enum DidReloadWorkspace {} +pub enum InternalFeedback {} -impl Notification for DidReloadWorkspace { - const METHOD: &'static str = "m/didReloadWorkspace"; - type Params = Vec; +impl Notification for InternalFeedback { + const METHOD: &'static str = "internalFeedback"; + type Params = String; } -- cgit v1.2.3