feat: handle shutdown and exit

close #33
This commit is contained in:
kbwo 2024-09-23 11:18:15 +09:00
parent daa8db434c
commit 73a179f90b
2 changed files with 16 additions and 0 deletions

View file

@ -85,6 +85,13 @@ fn main_loop(server: &mut TestingLS) -> Result<(), LSError> {
let id = value["id"].as_i64().unwrap();
server.initialize(id, initialize_params)?;
}
"shutdown" => {
let id = value["id"].as_i64().unwrap();
server.shutdown(id)?;
}
"exit" => {
std::process::exit(0);
}
"workspace/diagnostic" => {
server.diagnose_workspace()?;
}

View file

@ -452,6 +452,15 @@ impl TestingLS {
}))?;
Ok(())
}
pub fn shutdown(&self, id: i64) -> Result<(), LSError> {
send_stdout(&json!({
"jsonrpc": "2.0",
"id": id,
"method": json!(null),
}))?;
Ok(())
}
}
#[cfg(test)]