aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/rust-analyzer/src/lib.rs')
-rw-r--r--crates/rust-analyzer/src/lib.rs54
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
13pub mod cli;
14
15#[allow(unused)]
16macro_rules! println {
17 ($($tt:tt)*) => {
18 compile_error!("stdout is locked, use eprintln")
19 };
20}
21
22#[allow(unused)]
23macro_rules! print {
24 ($($tt:tt)*) => {
25 compile_error!("stdout is locked, use eprint")
26 };
27}
28
29mod vfs_glob;
30mod caps;
31mod cargo_target_spec;
32mod conv;
33mod main_loop;
34mod markdown;
35pub mod req;
36mod config;
37mod world;
38mod diagnostics;
39
40use serde::de::DeserializeOwned;
41
42pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
43pub use crate::{
44 caps::server_capabilities,
45 config::ServerConfig,
46 main_loop::LspError,
47 main_loop::{main_loop, show_message},
48};
49
50pub 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}