forked from rust-lang/rust-analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to showing prime chaches progress
This is a part of rust-lang#4074
- Loading branch information
Showing
6 changed files
with
227 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::req; | ||
use crossbeam_channel::Sender; | ||
use lsp_server::{Message, Notification, Request, RequestId}; | ||
use ra_db::Canceled; | ||
use serde::{de::DeserializeOwned, Serialize}; | ||
use std::error::Error; | ||
|
||
pub fn show_message(typ: req::MessageType, message: impl Into<String>, sender: &Sender<Message>) { | ||
let message = message.into(); | ||
let params = req::ShowMessageParams { typ, message }; | ||
let not = notification_new::<req::ShowMessage>(params); | ||
sender.send(not.into()).unwrap(); | ||
} | ||
|
||
pub(crate) fn is_canceled(e: &(dyn Error + 'static)) -> bool { | ||
e.downcast_ref::<Canceled>().is_some() | ||
} | ||
|
||
pub(crate) fn notification_is<N: lsp_types::notification::Notification>( | ||
notification: &Notification, | ||
) -> bool { | ||
notification.method == N::METHOD | ||
} | ||
|
||
pub(crate) fn notification_cast<N>(notification: Notification) -> Result<N::Params, Notification> | ||
where | ||
N: lsp_types::notification::Notification, | ||
N::Params: DeserializeOwned, | ||
{ | ||
notification.extract(N::METHOD) | ||
} | ||
|
||
pub(crate) fn notification_new<N>(params: N::Params) -> Notification | ||
where | ||
N: lsp_types::notification::Notification, | ||
N::Params: Serialize, | ||
{ | ||
Notification::new(N::METHOD.to_string(), params) | ||
} | ||
|
||
pub(crate) fn request_new<R>(id: RequestId, params: R::Params) -> Request | ||
where | ||
R: lsp_types::request::Request, | ||
R::Params: Serialize, | ||
{ | ||
Request::new(id, R::METHOD.to_string(), params) | ||
} |
Oops, something went wrong.