Skip to content

Commit

Permalink
add registered dynamic capabilities to status response
Browse files Browse the repository at this point in the history
  • Loading branch information
pr2502 committed Mar 11, 2024
1 parent 86aeacb commit 9f88342
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,20 @@ pub async fn status(json: bool) -> Result<()> {
}

for instance in res.instances {
println!("- Instance pid {}", instance.pid);
println!("- Instance");
println!(" pid: {}", instance.pid);
println!(" server: {:?} {:?}", instance.server, instance.args);
println!(" path: {:?}", instance.workspace_root);
let now = time::OffsetDateTime::now_utc().unix_timestamp();
println!(" last used: {}s ago", now - instance.last_used);
println!(" registered dynamic capabilities:");
for cap in instance.registered_dyn_capabilities {
println!(" - {}", cap);
}
println!(" clients:");
for client in instance.clients {
println!(" - Client port {}", client.port);
println!(" - Client");
println!(" port: {}", client.port);
}
}
Ok(())
Expand Down
22 changes: 16 additions & 6 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,28 @@ impl Instance {
}

pub fn get_status(&self) -> ext::Instance {
let clients = self
.clients
.blocking_lock()
.values()
.map(|client| client.get_status())
.collect();

let registered_dyn_capabilities = self
.dynamic_capabilities
.blocking_lock()
.values()
.map(|reg| reg.method.clone())
.collect();

ext::Instance {
pid: self.pid,
server: self.key.server.clone(),
args: self.key.args.clone(),
workspace_root: self.key.workspace_root.clone(),
last_used: self.last_used.load(Ordering::Relaxed),
clients: self
.clients
.blocking_lock()
.values()
.map(|client| client.get_status())
.collect(),
clients,
registered_dyn_capabilities,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/lsp/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ pub struct Instance {
pub server: String,
pub args: Vec<String>,
pub workspace_root: String,
pub registered_dyn_capabilities: Vec<String>,
pub last_used: i64,
pub clients: Vec<Client>,
}
Expand Down

0 comments on commit 9f88342

Please sign in to comment.