rust/crates/rust-analyzer/src/lib.rs

47 lines
1.2 KiB
Rust
Raw Normal View History

2019-11-22 01:33:08 -06:00
//! Implementation of the LSP for rust-analyzer.
//!
2020-02-18 05:11:32 -06:00
//! This crate takes Rust-specific analysis results from ra_ide and translates
//! into LSP types.
2019-11-22 01:33:08 -06:00
//!
//! It also is the root of all state. `world` module defines the bulk of the
//! state, and `main_loop` module defines the rules for modifying it.
2020-02-18 05:11:32 -06:00
//!
//! The `cli` submodule implements some batch-processing analysis, primarily as
//! a debugging aid.
2019-06-26 01:12:46 -05:00
#![recursion_limit = "512"]
2019-11-22 01:33:08 -06:00
2020-02-17 12:03:03 -06:00
pub mod cli;
2019-11-22 01:33:08 -06:00
#[allow(unused)]
2020-04-06 09:58:16 -05:00
macro_rules! eprintln {
($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
2019-11-22 01:33:08 -06:00
}
2020-02-17 12:07:30 -06:00
mod vfs_glob;
2018-09-01 10:16:08 -05:00
mod caps;
mod cargo_target_spec;
mod to_proto;
mod from_proto;
2018-09-01 10:16:08 -05:00
mod main_loop;
mod markdown;
2020-05-10 12:25:37 -05:00
pub mod lsp_ext;
2020-04-01 11:46:26 -05:00
pub mod config;
2019-06-01 02:31:40 -05:00
mod world;
mod diagnostics;
mod semantic_tokens;
2018-09-01 10:16:08 -05:00
use serde::de::DeserializeOwned;
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
pub use crate::{
caps::server_capabilities,
main_loop::LspError,
main_loop::{main_loop, show_message},
};
pub fn from_json<T: DeserializeOwned>(what: &'static str, json: serde_json::Value) -> Result<T> {
let res = T::deserialize(&json)
.map_err(|e| format!("Failed to deserialize {}: {}; {}", what, e, json))?;
Ok(res)
}