2019-11-22 07:33:08 +00:00
|
|
|
//! Implementation of the LSP for rust-analyzer.
|
|
|
|
//!
|
2020-02-18 11:11:32 +00:00
|
|
|
//! This crate takes Rust-specific analysis results from ra_ide and translates
|
|
|
|
//! into LSP types.
|
2019-11-22 07:33:08 +00: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 11:11:32 +00:00
|
|
|
//!
|
|
|
|
//! The `cli` submodule implements some batch-processing analysis, primarily as
|
|
|
|
//! a debugging aid.
|
2019-06-26 06:12:46 +00:00
|
|
|
#![recursion_limit = "512"]
|
2019-11-22 07:33:08 +00:00
|
|
|
|
2020-02-17 18:03:03 +00:00
|
|
|
pub mod cli;
|
|
|
|
|
2019-11-22 07:33:08 +00:00
|
|
|
#[allow(unused)]
|
|
|
|
macro_rules! println {
|
|
|
|
($($tt:tt)*) => {
|
|
|
|
compile_error!("stdout is locked, use eprintln")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[allow(unused)]
|
|
|
|
macro_rules! print {
|
|
|
|
($($tt:tt)*) => {
|
|
|
|
compile_error!("stdout is locked, use eprint")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-02-17 18:07:30 +00:00
|
|
|
mod vfs_glob;
|
2018-09-01 15:16:08 +00:00
|
|
|
mod caps;
|
2019-01-12 18:00:58 +00:00
|
|
|
mod cargo_target_spec;
|
2018-09-01 15:16:08 +00:00
|
|
|
mod conv;
|
|
|
|
mod main_loop;
|
2019-01-30 02:39:09 +00:00
|
|
|
mod markdown;
|
2018-10-15 21:44:23 +00:00
|
|
|
pub mod req;
|
2019-10-11 19:13:15 +00:00
|
|
|
mod config;
|
2019-06-01 07:31:40 +00:00
|
|
|
mod world;
|
2020-01-31 18:23:25 +00:00
|
|
|
mod diagnostics;
|
2018-09-01 15:16:08 +00:00
|
|
|
|
2020-02-11 08:46:45 +00:00
|
|
|
use serde::de::DeserializeOwned;
|
|
|
|
|
2019-06-14 20:42:56 +00:00
|
|
|
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
2019-07-04 20:05:17 +00:00
|
|
|
pub use crate::{
|
2019-08-22 08:08:22 +00:00
|
|
|
caps::server_capabilities,
|
|
|
|
config::ServerConfig,
|
|
|
|
main_loop::LspError,
|
|
|
|
main_loop::{main_loop, show_message},
|
2019-07-04 20:05:17 +00:00
|
|
|
};
|
2020-02-11 08:46:45 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|