Remove some of the panics, just log instead.

This commit is contained in:
Blaž Hrastnik 2021-05-08 18:17:13 +09:00
parent d24844b73d
commit caf4349925
3 changed files with 20 additions and 8 deletions

View file

@ -130,10 +130,10 @@ pub enum Notification {
} }
impl Notification { impl Notification {
pub fn parse(method: &str, params: jsonrpc::Params) -> Notification { pub fn parse(method: &str, params: jsonrpc::Params) -> Option<Notification> {
use lsp::notification::Notification as _; use lsp::notification::Notification as _;
match method { let notification = match method {
lsp::notification::PublishDiagnostics::METHOD => { lsp::notification::PublishDiagnostics::METHOD => {
let params: lsp::PublishDiagnosticsParams = params let params: lsp::PublishDiagnosticsParams = params
.parse() .parse()
@ -155,8 +155,13 @@ impl Notification {
Notification::LogMessage(params) Notification::LogMessage(params)
} }
_ => unimplemented!("unhandled notification: {}", method), _ => {
} log::error!("unhandled LSP notification: {}", method);
return None;
}
};
Some(notification)
} }
} }

View file

@ -145,7 +145,11 @@ impl Application {
use helix_lsp::{Call, Notification}; use helix_lsp::{Call, Notification};
match call { match call {
Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => { Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => {
let notification = Notification::parse(&method, params); let notification = match Notification::parse(&method, params) {
Some(notification) => notification,
None => return,
};
// TODO: parse should return Result/Option // TODO: parse should return Result/Option
match notification { match notification {
Notification::PublishDiagnostics(params) => { Notification::PublishDiagnostics(params) => {

View file

@ -1883,7 +1883,8 @@ pub fn format_selections(cx: &mut Context) {
}; };
// TODO: handle fails // TODO: handle fails
// TODO: concurrent map // TODO: concurrent map
unimplemented!(); // neeed to block to get the formatting
// TODO: need to block to get the formatting
// let edits = block_on(language_server.text_document_range_formatting( // let edits = block_on(language_server.text_document_range_formatting(
// doc.identifier(), // doc.identifier(),
@ -2098,10 +2099,12 @@ pub fn hover(cx: &mut Context) {
lsp::HoverContents::Scalar(contents) => { lsp::HoverContents::Scalar(contents) => {
// markedstring(string/languagestring to be highlighted) // markedstring(string/languagestring to be highlighted)
// TODO // TODO
unimplemented!("{:?}", contents) log::error!("hover contents {:?}", contents);
return;
} }
lsp::HoverContents::Array(contents) => { lsp::HoverContents::Array(contents) => {
unimplemented!("{:?}", contents) log::error!("hover contents {:?}", contents);
return;
} }
// TODO: render markdown // TODO: render markdown
lsp::HoverContents::Markup(contents) => contents.value, lsp::HoverContents::Markup(contents) => contents.value,