summaryrefslogtreecommitdiff
path: root/cli/lsp/utils.rs
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2020-12-21 14:44:26 +0100
committerGitHub <noreply@github.com>2020-12-21 08:44:26 -0500
commitbd85d0ed420b792eebdd81f88fca503e028c9565 (patch)
treed6f8d5baf4c3c0d760bea2b6b221189674d2e54b /cli/lsp/utils.rs
parent3078fcf55a8aa04d26316ab353d84f2c9512bd47 (diff)
refactor: rewrite lsp to be async (#8727)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
Diffstat (limited to 'cli/lsp/utils.rs')
-rw-r--r--cli/lsp/utils.rs62
1 files changed, 0 insertions, 62 deletions
diff --git a/cli/lsp/utils.rs b/cli/lsp/utils.rs
index 0c3d5a635..3bdd00875 100644
--- a/cli/lsp/utils.rs
+++ b/cli/lsp/utils.rs
@@ -1,71 +1,9 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-use deno_core::error::custom_error;
use deno_core::error::AnyError;
-use deno_core::serde_json::Value;
use deno_core::url::Position;
use deno_core::url::Url;
use deno_core::ModuleSpecifier;
-use lsp_server::Notification;
-use serde::de::DeserializeOwned;
-use std::error::Error;
-use std::fmt;
-
-// TODO(@kitsonk) support actually supporting cancellation requests from the
-// client.
-
-pub struct Canceled {
- _private: (),
-}
-
-impl Canceled {
- #[allow(unused)]
- pub fn new() -> Self {
- Self { _private: () }
- }
-
- #[allow(unused)]
- pub fn throw() -> ! {
- std::panic::resume_unwind(Box::new(Canceled::new()))
- }
-}
-
-impl fmt::Display for Canceled {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "cancelled")
- }
-}
-
-impl fmt::Debug for Canceled {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "Canceled")
- }
-}
-
-impl Error for Canceled {}
-
-pub fn from_json<T: DeserializeOwned>(
- what: &'static str,
- json: Value,
-) -> Result<T, AnyError> {
- let response = T::deserialize(&json).map_err(|err| {
- custom_error(
- "DeserializeFailed",
- format!("Failed to deserialize {}: {}; {}", what, err, json),
- )
- })?;
- Ok(response)
-}
-
-pub fn is_canceled(e: &(dyn Error + 'static)) -> bool {
- e.downcast_ref::<Canceled>().is_some()
-}
-
-pub fn notification_is<N: lsp_types::notification::Notification>(
- notification: &Notification,
-) -> bool {
- notification.method == N::METHOD
-}
/// Normalizes a file name returned from the TypeScript compiler into a URI that
/// should be sent by the language server to the client.