diff options
Diffstat (limited to 'crates/rust-analyzer/src/lib.rs')
-rw-r--r-- | crates/rust-analyzer/src/lib.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs new file mode 100644 index 000000000..0dae30e46 --- /dev/null +++ b/crates/rust-analyzer/src/lib.rs | |||
@@ -0,0 +1,54 @@ | |||
1 | //! Implementation of the LSP for rust-analyzer. | ||
2 | //! | ||
3 | //! This crate takes Rust-specific analysis results from ra_ide and translates | ||
4 | //! into LSP types. | ||
5 | //! | ||
6 | //! It also is the root of all state. `world` module defines the bulk of the | ||
7 | //! state, and `main_loop` module defines the rules for modifying it. | ||
8 | //! | ||
9 | //! The `cli` submodule implements some batch-processing analysis, primarily as | ||
10 | //! a debugging aid. | ||
11 | #![recursion_limit = "512"] | ||
12 | |||
13 | pub mod cli; | ||
14 | |||
15 | #[allow(unused)] | ||
16 | macro_rules! println { | ||
17 | ($($tt:tt)*) => { | ||
18 | compile_error!("stdout is locked, use eprintln") | ||
19 | }; | ||
20 | } | ||
21 | |||
22 | #[allow(unused)] | ||
23 | macro_rules! print { | ||
24 | ($($tt:tt)*) => { | ||
25 | compile_error!("stdout is locked, use eprint") | ||
26 | }; | ||
27 | } | ||
28 | |||
29 | mod vfs_glob; | ||
30 | mod caps; | ||
31 | mod cargo_target_spec; | ||
32 | mod conv; | ||
33 | mod main_loop; | ||
34 | mod markdown; | ||
35 | pub mod req; | ||
36 | mod config; | ||
37 | mod world; | ||
38 | mod diagnostics; | ||
39 | |||
40 | use serde::de::DeserializeOwned; | ||
41 | |||
42 | pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; | ||
43 | pub use crate::{ | ||
44 | caps::server_capabilities, | ||
45 | config::ServerConfig, | ||
46 | main_loop::LspError, | ||
47 | main_loop::{main_loop, show_message}, | ||
48 | }; | ||
49 | |||
50 | pub fn from_json<T: DeserializeOwned>(what: &'static str, json: serde_json::Value) -> Result<T> { | ||
51 | let res = T::deserialize(&json) | ||
52 | .map_err(|e| format!("Failed to deserialize {}: {}; {}", what, e, json))?; | ||
53 | Ok(res) | ||
54 | } | ||