aboutsummaryrefslogtreecommitdiff
path: root/crates/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/server/src')
-rw-r--r--crates/server/src/main.rs2
-rw-r--r--crates/server/src/main_loop/mod.rs14
-rw-r--r--crates/server/src/project_model.rs11
-rw-r--r--crates/server/src/req.rs9
4 files changed, 21 insertions, 15 deletions
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<()> {
34 let root = ::std::env::current_dir()?; 34 let root = ::std::env::current_dir()?;
35 run_server( 35 run_server(
36 m::server_capabilities(), 36 m::server_capabilities(),
37 |r, s| m::main_loop(root, r, s), 37 |r, s| m::main_loop(false, root, r, s),
38 receiver, 38 receiver,
39 sender, 39 sender,
40 )?; 40 )?;
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 {
32} 32}
33 33
34pub fn main_loop( 34pub fn main_loop(
35 internal_mode: bool,
35 root: PathBuf, 36 root: PathBuf,
36 msg_receriver: &mut Receiver<RawMessage>, 37 msg_receriver: &mut Receiver<RawMessage>,
37 msg_sender: &mut Sender<RawMessage>, 38 msg_sender: &mut Sender<RawMessage>,
@@ -47,6 +48,7 @@ pub fn main_loop(
47 let mut pending_requests = HashMap::new(); 48 let mut pending_requests = HashMap::new();
48 let mut subs = Subscriptions::new(); 49 let mut subs = Subscriptions::new();
49 let main_res = main_loop_inner( 50 let main_res = main_loop_inner(
51 internal_mode,
50 root, 52 root,
51 &pool, 53 &pool,
52 msg_sender, 54 msg_sender,
@@ -80,6 +82,7 @@ pub fn main_loop(
80} 82}
81 83
82fn main_loop_inner( 84fn main_loop_inner(
85 internal_mode: bool,
83 ws_root: PathBuf, 86 ws_root: PathBuf,
84 pool: &ThreadPool, 87 pool: &ThreadPool,
85 msg_sender: &mut Sender<RawMessage>, 88 msg_sender: &mut Sender<RawMessage>,
@@ -145,8 +148,7 @@ fn main_loop_inner(
145 match ws { 148 match ws {
146 Ok(ws) => { 149 Ok(ws) => {
147 let workspaces = vec![ws]; 150 let workspaces = vec![ws];
148 let not = RawNotification::new::<req::DidReloadWorkspace>(&workspaces); 151 feedback(internal_mode, "workspace loaded", msg_sender);
149 msg_sender.send(RawMessage::Notification(not));
150 for ws in workspaces.iter() { 152 for ws in workspaces.iter() {
151 for pkg in ws.packages().filter(|pkg| !pkg.is_member(ws)) { 153 for pkg in ws.packages().filter(|pkg| !pkg.is_member(ws)) {
152 debug!("sending root, {}", pkg.root(ws).to_path_buf().display()); 154 debug!("sending root, {}", pkg.root(ws).to_path_buf().display());
@@ -404,3 +406,11 @@ fn update_file_notifications_on_threadpool(
404 } 406 }
405 }); 407 });
406} 408}
409
410fn feedback(intrnal_mode: bool, msg: &str, sender: &Sender<RawMessage>) {
411 if !intrnal_mode {
412 return;
413 }
414 let not = RawNotification::new::<req::InternalFeedback>(&msg.to_string());
415 sender.send(RawMessage::Notification(not));
416}
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 {
11 thread_watcher::ThreadWatcher, 11 thread_watcher::ThreadWatcher,
12}; 12};
13 13
14#[derive(Debug, Serialize, Clone)] 14#[derive(Debug, Clone)]
15pub struct CargoWorkspace { 15pub struct CargoWorkspace {
16 packages: Vec<PackageData>, 16 packages: Vec<PackageData>,
17 targets: Vec<TargetData>, 17 targets: Vec<TargetData>,
@@ -22,7 +22,7 @@ pub struct Package(usize);
22#[derive(Clone, Copy, Debug, Serialize)] 22#[derive(Clone, Copy, Debug, Serialize)]
23pub struct Target(usize); 23pub struct Target(usize);
24 24
25#[derive(Debug, Serialize, Clone)] 25#[derive(Debug, Clone)]
26struct PackageData { 26struct PackageData {
27 name: SmolStr, 27 name: SmolStr,
28 manifest: PathBuf, 28 manifest: PathBuf,
@@ -30,7 +30,7 @@ struct PackageData {
30 is_member: bool, 30 is_member: bool,
31} 31}
32 32
33#[derive(Debug, Serialize, Clone)] 33#[derive(Debug, Clone)]
34struct TargetData { 34struct TargetData {
35 pkg: Package, 35 pkg: Package,
36 name: SmolStr, 36 name: SmolStr,
@@ -38,7 +38,7 @@ struct TargetData {
38 kind: TargetKind, 38 kind: TargetKind,
39} 39}
40 40
41#[derive(Debug, Serialize, Clone, Copy, PartialEq, Eq)] 41#[derive(Debug, Clone, Copy, PartialEq, Eq)]
42pub enum TargetKind { 42pub enum TargetKind {
43 Bin, Lib, Example, Test, Bench, Other, 43 Bin, Lib, Example, Test, Bench, Other,
44} 44}
@@ -47,9 +47,6 @@ impl Package {
47 pub fn name(self, ws: &CargoWorkspace) -> &str { 47 pub fn name(self, ws: &CargoWorkspace) -> &str {
48 ws.pkg(self).name.as_str() 48 ws.pkg(self).name.as_str()
49 } 49 }
50 pub fn manifest(self, ws: &CargoWorkspace) -> &Path {
51 ws.pkg(self).manifest.as_path()
52 }
53 pub fn root(self, ws: &CargoWorkspace) -> &Path { 50 pub fn root(self, ws: &CargoWorkspace) -> &Path {
54 ws.pkg(self).manifest.parent().unwrap() 51 ws.pkg(self).manifest.parent().unwrap()
55 } 52 }
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 @@
1use std::collections::HashMap; 1use std::collections::HashMap;
2use languageserver_types::{TextDocumentIdentifier, Range, Url, Position, Location}; 2use languageserver_types::{TextDocumentIdentifier, Range, Url, Position, Location};
3use url_serde; 3use url_serde;
4use project_model::CargoWorkspace;
5 4
6pub use languageserver_types::{ 5pub use languageserver_types::{
7 request::*, notification::*, 6 request::*, notification::*,
@@ -169,9 +168,9 @@ pub enum FileSystemEdit {
169 } 168 }
170} 169}
171 170
172pub enum DidReloadWorkspace {} 171pub enum InternalFeedback {}
173 172
174impl Notification for DidReloadWorkspace { 173impl Notification for InternalFeedback {
175 const METHOD: &'static str = "m/didReloadWorkspace"; 174 const METHOD: &'static str = "internalFeedback";
176 type Params = Vec<CargoWorkspace>; 175 type Params = String;
177} 176}