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