From 2dbc7e3e1a6ca07124d3aeaddd42aa8c0bce987d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 2 Sep 2023 14:01:58 +0200 Subject: [PATCH] Restructure some modules in rust-analyzer crate --- crates/rust-analyzer/src/caps.rs | 10 +- crates/rust-analyzer/src/cli/lsif.rs | 2 +- crates/rust-analyzer/src/diagnostics.rs | 40 ++++++- .../rust-analyzer/src/diagnostics/to_proto.rs | 4 +- crates/rust-analyzer/src/dispatch.rs | 2 +- crates/rust-analyzer/src/global_state.rs | 6 +- .../src/handlers/notification.rs | 8 +- crates/rust-analyzer/src/handlers/request.rs | 8 +- crates/rust-analyzer/src/lib.rs | 29 +---- crates/rust-analyzer/src/lsp.rs | 29 +++++ .../src/{lsp_ext.rs => lsp/ext.rs} | 0 .../rust-analyzer/src/{ => lsp}/from_proto.rs | 2 +- .../src/{ => lsp}/semantic_tokens.rs | 0 .../rust-analyzer/src/{ => lsp}/to_proto.rs | 11 +- .../src/{lsp_utils.rs => lsp/utils.rs} | 4 +- crates/rust-analyzer/src/main_loop.rs | 106 +++++------------- crates/rust-analyzer/src/markdown.rs | 1 + crates/rust-analyzer/src/reload.rs | 1 + crates/rust-analyzer/tests/slow-tests/main.rs | 2 +- .../rust-analyzer/tests/slow-tests/support.rs | 6 +- crates/rust-analyzer/tests/slow-tests/tidy.rs | 6 +- docs/dev/lsp-extensions.md | 2 +- 22 files changed, 145 insertions(+), 134 deletions(-) create mode 100644 crates/rust-analyzer/src/lsp.rs rename crates/rust-analyzer/src/{lsp_ext.rs => lsp/ext.rs} (100%) rename crates/rust-analyzer/src/{ => lsp}/from_proto.rs (99%) rename crates/rust-analyzer/src/{ => lsp}/semantic_tokens.rs (100%) rename crates/rust-analyzer/src/{ => lsp}/to_proto.rs (99%) rename crates/rust-analyzer/src/{lsp_utils.rs => lsp/utils.rs} (99%) diff --git a/crates/rust-analyzer/src/caps.rs b/crates/rust-analyzer/src/caps.rs index ab06b96814a..822811e67f5 100644 --- a/crates/rust-analyzer/src/caps.rs +++ b/crates/rust-analyzer/src/caps.rs @@ -16,10 +16,12 @@ use lsp_types::{ }; use serde_json::json; -use crate::config::{Config, RustfmtConfig}; -use crate::line_index::PositionEncoding; -use crate::lsp_ext::negotiated_encoding; -use crate::semantic_tokens; +use crate::{ + config::{Config, RustfmtConfig}, + line_index::PositionEncoding, + lsp::semantic_tokens, + lsp_ext::negotiated_encoding, +}; pub fn server_capabilities(config: &Config) -> ServerCapabilities { ServerCapabilities { diff --git a/crates/rust-analyzer/src/cli/lsif.rs b/crates/rust-analyzer/src/cli/lsif.rs index 42d180114e5..d6a45ce06f2 100644 --- a/crates/rust-analyzer/src/cli/lsif.rs +++ b/crates/rust-analyzer/src/cli/lsif.rs @@ -21,7 +21,7 @@ use vfs::{AbsPathBuf, Vfs}; use crate::{ cli::flags, line_index::{LineEndings, LineIndex, PositionEncoding}, - to_proto, + lsp::to_proto, version::version, }; diff --git a/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs index b65f38a0c71..71701ef1617 100644 --- a/crates/rust-analyzer/src/diagnostics.rs +++ b/crates/rust-analyzer/src/diagnostics.rs @@ -9,7 +9,7 @@ use nohash_hasher::{IntMap, IntSet}; use rustc_hash::FxHashSet; use triomphe::Arc; -use crate::lsp_ext; +use crate::{global_state::GlobalStateSnapshot, lsp, lsp_ext}; pub(crate) type CheckFixes = Arc>>>; @@ -122,3 +122,41 @@ fn are_diagnostics_equal(left: &lsp_types::Diagnostic, right: &lsp_types::Diagno && left.range == right.range && left.message == right.message } + +pub(crate) fn fetch_native_diagnostics( + snapshot: GlobalStateSnapshot, + subscriptions: Vec, +) -> Vec<(FileId, Vec)> { + let _p = profile::span("fetch_native_diagnostics"); + let _ctx = stdx::panic_context::enter("fetch_native_diagnostics".to_owned()); + subscriptions + .into_iter() + .filter_map(|file_id| { + let line_index = snapshot.file_line_index(file_id).ok()?; + let diagnostics = snapshot + .analysis + .diagnostics( + &snapshot.config.diagnostics(), + ide::AssistResolveStrategy::None, + file_id, + ) + .ok()? + .into_iter() + .map(move |d| lsp_types::Diagnostic { + range: lsp::to_proto::range(&line_index, d.range), + severity: Some(lsp::to_proto::diagnostic_severity(d.severity)), + code: Some(lsp_types::NumberOrString::String(d.code.as_str().to_string())), + code_description: Some(lsp_types::CodeDescription { + href: lsp_types::Url::parse(&d.code.url()).unwrap(), + }), + source: Some("rust-analyzer".to_string()), + message: d.message, + related_information: None, + tags: d.unused.then(|| vec![lsp_types::DiagnosticTag::UNNECESSARY]), + data: None, + }) + .collect::>(); + Some((file_id, diagnostics)) + }) + .collect() +} diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 06564578d80..731580557c2 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -8,8 +8,8 @@ use stdx::format_to; use vfs::{AbsPath, AbsPathBuf}; use crate::{ - global_state::GlobalStateSnapshot, line_index::PositionEncoding, lsp_ext, - to_proto::url_from_abs_path, + global_state::GlobalStateSnapshot, line_index::PositionEncoding, + lsp::to_proto::url_from_abs_path, lsp_ext, }; use super::{DiagnosticsMapConfig, Fix}; diff --git a/crates/rust-analyzer/src/dispatch.rs b/crates/rust-analyzer/src/dispatch.rs index 5e5cd9a0269..7da43118881 100644 --- a/crates/rust-analyzer/src/dispatch.rs +++ b/crates/rust-analyzer/src/dispatch.rs @@ -8,9 +8,9 @@ use stdx::thread::ThreadIntent; use crate::{ global_state::{GlobalState, GlobalStateSnapshot}, + lsp::LspError, main_loop::Task, version::version, - LspError, }; /// A visitor for routing a raw JSON request to an appropriate handler function. diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 5024e04ffd3..22a7dd1548f 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -22,15 +22,14 @@ use vfs::{AnchoredPathBuf, Vfs}; use crate::{ config::{Config, ConfigError}, diagnostics::{CheckFixes, DiagnosticCollection}, - from_proto, line_index::{LineEndings, LineIndex}, + lsp::{from_proto, to_proto::url_from_abs_path}, lsp_ext, main_loop::Task, mem_docs::MemDocs, op_queue::OpQueue, reload, task_pool::TaskPool, - to_proto::url_from_abs_path, }; // Enforces drop order @@ -40,7 +39,7 @@ pub(crate) struct Handle { } pub(crate) type ReqHandler = fn(&mut GlobalState, lsp_server::Response); -pub(crate) type ReqQueue = lsp_server::ReqQueue<(String, Instant), ReqHandler>; +type ReqQueue = lsp_server::ReqQueue<(String, Instant), ReqHandler>; /// `GlobalState` is the primary mutable state of the language server /// @@ -49,6 +48,7 @@ pub(crate) type ReqQueue = lsp_server::ReqQueue<(String, Instant), ReqHandler>; /// incremental salsa database. /// /// Note that this struct has more than one impl in various modules! +#[doc(alias = "GlobalMess")] pub(crate) struct GlobalState { sender: Sender, req_queue: ReqQueue, diff --git a/crates/rust-analyzer/src/handlers/notification.rs b/crates/rust-analyzer/src/handlers/notification.rs index 3fd10274e0d..93f33d7cac9 100644 --- a/crates/rust-analyzer/src/handlers/notification.rs +++ b/crates/rust-analyzer/src/handlers/notification.rs @@ -13,8 +13,12 @@ use triomphe::Arc; use vfs::{AbsPathBuf, ChangeKind, VfsPath}; use crate::{ - config::Config, from_proto, global_state::GlobalState, lsp_ext::RunFlycheckParams, - lsp_utils::apply_document_changes, mem_docs::DocumentData, reload, + config::Config, + global_state::GlobalState, + lsp::{from_proto, utils::apply_document_changes}, + lsp_ext::RunFlycheckParams, + mem_docs::DocumentData, + reload, }; pub(crate) fn handle_cancel(state: &mut GlobalState, params: CancelParams) -> anyhow::Result<()> { diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index 85ac690a411..36158e8115e 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -36,15 +36,17 @@ use crate::{ cargo_target_spec::CargoTargetSpec, config::{Config, RustfmtConfig, WorkspaceSymbolConfig}, diff::diff, - from_proto, global_state::{GlobalState, GlobalStateSnapshot}, line_index::LineEndings, + lsp::{ + from_proto, to_proto, + utils::{all_edits_are_disjoint, invalid_params_error}, + LspError, + }, lsp_ext::{ self, CrateInfoResult, ExternalDocsPair, ExternalDocsResponse, FetchDependencyListParams, FetchDependencyListResult, PositionOrRange, ViewCrateGraphParams, WorkspaceSymbolParams, }, - lsp_utils::{all_edits_are_disjoint, invalid_params_error}, - to_proto, LspError, }; pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> anyhow::Result<()> { diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs index 57e26c241bb..04ac77b1f6c 100644 --- a/crates/rust-analyzer/src/lib.rs +++ b/crates/rust-analyzer/src/lib.rs @@ -23,18 +23,14 @@ mod cargo_target_spec; mod diagnostics; mod diff; mod dispatch; -mod from_proto; mod global_state; mod line_index; -mod lsp_utils; mod main_loop; mod markdown; mod mem_docs; mod op_queue; mod reload; -mod semantic_tokens; mod task_pool; -mod to_proto; mod version; mod handlers { @@ -43,13 +39,12 @@ mod handlers { } pub mod config; -pub mod lsp_ext; +pub mod lsp; +use self::lsp::ext as lsp_ext; #[cfg(test)] mod integrated_benchmarks; -use std::fmt; - use serde::de::DeserializeOwned; pub use crate::{caps::server_capabilities, main_loop::main_loop, version::version}; @@ -61,23 +56,3 @@ pub fn from_json( serde_json::from_value(json.clone()) .map_err(|e| anyhow::format_err!("Failed to deserialize {what}: {e}; {json}")) } - -#[derive(Debug)] -struct LspError { - code: i32, - message: String, -} - -impl LspError { - fn new(code: i32, message: String) -> LspError { - LspError { code, message } - } -} - -impl fmt::Display for LspError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Language Server request failed with {}. ({})", self.code, self.message) - } -} - -impl std::error::Error for LspError {} diff --git a/crates/rust-analyzer/src/lsp.rs b/crates/rust-analyzer/src/lsp.rs new file mode 100644 index 00000000000..ac7e1a95e62 --- /dev/null +++ b/crates/rust-analyzer/src/lsp.rs @@ -0,0 +1,29 @@ +//! Custom LSP definitions and protocol conversions. + +use core::fmt; + +pub(crate) mod utils; +pub(crate) mod semantic_tokens; +pub mod ext; +pub(crate) mod from_proto; +pub(crate) mod to_proto; + +#[derive(Debug)] +pub(crate) struct LspError { + pub(crate) code: i32, + pub(crate) message: String, +} + +impl LspError { + pub(crate) fn new(code: i32, message: String) -> LspError { + LspError { code, message } + } +} + +impl fmt::Display for LspError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Language Server request failed with {}. ({})", self.code, self.message) + } +} + +impl std::error::Error for LspError {} diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp/ext.rs similarity index 100% rename from crates/rust-analyzer/src/lsp_ext.rs rename to crates/rust-analyzer/src/lsp/ext.rs diff --git a/crates/rust-analyzer/src/from_proto.rs b/crates/rust-analyzer/src/lsp/from_proto.rs similarity index 99% rename from crates/rust-analyzer/src/from_proto.rs rename to crates/rust-analyzer/src/lsp/from_proto.rs index c247e1bb229..06efe6ca911 100644 --- a/crates/rust-analyzer/src/from_proto.rs +++ b/crates/rust-analyzer/src/lsp/from_proto.rs @@ -12,8 +12,8 @@ use crate::{ from_json, global_state::GlobalStateSnapshot, line_index::{LineIndex, PositionEncoding}, + lsp::utils::invalid_params_error, lsp_ext, - lsp_utils::invalid_params_error, }; pub(crate) fn abs_path(url: &lsp_types::Url) -> anyhow::Result { diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/lsp/semantic_tokens.rs similarity index 100% rename from crates/rust-analyzer/src/semantic_tokens.rs rename to crates/rust-analyzer/src/lsp/semantic_tokens.rs diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs similarity index 99% rename from crates/rust-analyzer/src/to_proto.rs rename to crates/rust-analyzer/src/lsp/to_proto.rs index 7b32180e3eb..daa7f5fe19d 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -22,9 +22,12 @@ use crate::{ config::{CallInfoConfig, Config}, global_state::GlobalStateSnapshot, line_index::{LineEndings, LineIndex, PositionEncoding}, + lsp::{ + semantic_tokens::{self, standard_fallback_type}, + utils::invalid_params_error, + LspError, + }, lsp_ext::{self, SnippetTextEdit}, - lsp_utils::invalid_params_error, - semantic_tokens::{self, standard_fallback_type}, }; pub(crate) fn position(line_index: &LineIndex, offset: TextSize) -> lsp_types::Position { @@ -1425,8 +1428,8 @@ pub(crate) mod command { use crate::{ global_state::GlobalStateSnapshot, + lsp::to_proto::{location, location_link}, lsp_ext, - to_proto::{location, location_link}, }; pub(crate) fn show_references( @@ -1532,7 +1535,7 @@ pub(crate) fn markup_content( lsp_types::MarkupContent { kind, value } } -pub(crate) fn rename_error(err: RenameError) -> crate::LspError { +pub(crate) fn rename_error(err: RenameError) -> LspError { // This is wrong, but we don't have a better alternative I suppose? // https://github.com/microsoft/language-server-protocol/issues/1341 invalid_params_error(err.to_string()) diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp/utils.rs similarity index 99% rename from crates/rust-analyzer/src/lsp_utils.rs rename to crates/rust-analyzer/src/lsp/utils.rs index 74e79e8e605..b388b317599 100644 --- a/crates/rust-analyzer/src/lsp_utils.rs +++ b/crates/rust-analyzer/src/lsp/utils.rs @@ -6,10 +6,10 @@ use lsp_types::request::Request; use triomphe::Arc; use crate::{ - from_proto, global_state::GlobalState, line_index::{LineEndings, LineIndex, PositionEncoding}, - lsp_ext, LspError, + lsp::{from_proto, LspError}, + lsp_ext, }; pub(crate) fn invalid_params_error(message: String) -> LspError { diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index effa24c9371..da4bef730b3 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -17,11 +17,14 @@ use vfs::FileId; use crate::{ config::Config, + diagnostics::fetch_native_diagnostics, dispatch::{NotificationDispatcher, RequestDispatcher}, - from_proto, global_state::{file_id_to_url, url_to_file_id, GlobalState}, + lsp::{ + from_proto, + utils::{notification_is, Progress}, + }, lsp_ext, - lsp_utils::{notification_is, Progress}, reload::{BuildDataProgress, ProcMacroProgress, ProjectWorkspaceProgress}, }; @@ -420,6 +423,32 @@ impl GlobalState { }); } + fn update_diagnostics(&mut self) { + let db = self.analysis_host.raw_database(); + let subscriptions = self + .mem_docs + .iter() + .map(|path| self.vfs.read().0.file_id(path).unwrap()) + .filter(|&file_id| { + let source_root = db.file_source_root(file_id); + // Only publish diagnostics for files in the workspace, not from crates.io deps + // or the sysroot. + // While theoretically these should never have errors, we have quite a few false + // positives particularly in the stdlib, and those diagnostics would stay around + // forever if we emitted them here. + !db.source_root(source_root).is_library + }) + .collect::>(); + tracing::trace!("updating notifications for {:?}", subscriptions); + + // Diagnostics are triggered by the user typing + // so we run them on a latency sensitive thread. + self.task_pool.handle.spawn(ThreadIntent::LatencySensitive, { + let snapshot = self.snapshot(); + move || Task::Diagnostics(fetch_native_diagnostics(snapshot, subscriptions)) + }); + } + fn update_status_or_notify(&mut self) { let status = self.current_status(); if self.last_reported_status.as_ref() != Some(&status) { @@ -785,77 +814,4 @@ impl GlobalState { .finish(); Ok(()) } - - fn update_diagnostics(&mut self) { - let db = self.analysis_host.raw_database(); - let subscriptions = self - .mem_docs - .iter() - .map(|path| self.vfs.read().0.file_id(path).unwrap()) - .filter(|&file_id| { - let source_root = db.file_source_root(file_id); - // Only publish diagnostics for files in the workspace, not from crates.io deps - // or the sysroot. - // While theoretically these should never have errors, we have quite a few false - // positives particularly in the stdlib, and those diagnostics would stay around - // forever if we emitted them here. - !db.source_root(source_root).is_library - }) - .collect::>(); - - tracing::trace!("updating notifications for {:?}", subscriptions); - - let snapshot = self.snapshot(); - - // Diagnostics are triggered by the user typing - // so we run them on a latency sensitive thread. - self.task_pool.handle.spawn(ThreadIntent::LatencySensitive, move || { - let _p = profile::span("publish_diagnostics"); - let _ctx = stdx::panic_context::enter("publish_diagnostics".to_owned()); - let diagnostics = subscriptions - .into_iter() - .filter_map(|file_id| { - let line_index = snapshot.file_line_index(file_id).ok()?; - Some(( - file_id, - line_index, - snapshot - .analysis - .diagnostics( - &snapshot.config.diagnostics(), - ide::AssistResolveStrategy::None, - file_id, - ) - .ok()?, - )) - }) - .map(|(file_id, line_index, it)| { - ( - file_id, - it.into_iter() - .map(move |d| lsp_types::Diagnostic { - range: crate::to_proto::range(&line_index, d.range), - severity: Some(crate::to_proto::diagnostic_severity(d.severity)), - code: Some(lsp_types::NumberOrString::String( - d.code.as_str().to_string(), - )), - code_description: Some(lsp_types::CodeDescription { - href: lsp_types::Url::parse(&d.code.url()).unwrap(), - }), - source: Some("rust-analyzer".to_string()), - message: d.message, - related_information: None, - tags: if d.unused { - Some(vec![lsp_types::DiagnosticTag::UNNECESSARY]) - } else { - None - }, - data: None, - }) - .collect::>(), - ) - }); - Task::Diagnostics(diagnostics.collect()) - }); - } } diff --git a/crates/rust-analyzer/src/markdown.rs b/crates/rust-analyzer/src/markdown.rs index 58426c66a85..3201b0ed520 100644 --- a/crates/rust-analyzer/src/markdown.rs +++ b/crates/rust-analyzer/src/markdown.rs @@ -3,6 +3,7 @@ use ide_db::rust_doc::is_rust_fence; const RUSTDOC_FENCES: [&str; 2] = ["```", "~~~"]; +// FIXME: why is this in this crate? pub(crate) fn format_docs(src: &str) -> String { let mut processed_lines = Vec::new(); let mut in_code_block = false; diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 0a2bb822475..3fae08b82e2 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -12,6 +12,7 @@ //! correct. Instead, we try to provide a best-effort service. Even if the //! project is currently loading and we don't have a full project model, we //! still want to respond to various requests. +// FIXME: This is a mess that needs some untangling work use std::{iter, mem}; use flycheck::{FlycheckConfig, FlycheckHandle}; diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs index ed6ef47c8e0..d5991429899 100644 --- a/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/crates/rust-analyzer/tests/slow-tests/main.rs @@ -29,7 +29,7 @@ use lsp_types::{ PartialResultParams, Position, Range, RenameFilesParams, TextDocumentItem, TextDocumentPositionParams, WorkDoneProgressParams, }; -use rust_analyzer::lsp_ext::{OnEnter, Runnables, RunnablesParams}; +use rust_analyzer::lsp::ext::{OnEnter, Runnables, RunnablesParams}; use serde_json::json; use test_utils::skip_slow_tests; diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs index 3c52ef5ef7f..e49b5768fa4 100644 --- a/crates/rust-analyzer/tests/slow-tests/support.rs +++ b/crates/rust-analyzer/tests/slow-tests/support.rs @@ -9,7 +9,7 @@ use std::{ use crossbeam_channel::{after, select, Receiver}; use lsp_server::{Connection, Message, Notification, Request}; use lsp_types::{notification::Exit, request::Shutdown, TextDocumentIdentifier, Url}; -use rust_analyzer::{config::Config, lsp_ext, main_loop}; +use rust_analyzer::{config::Config, lsp, main_loop}; use serde::Serialize; use serde_json::{json, to_string_pretty, Value}; use test_utils::FixtureWithProjectMeta; @@ -260,9 +260,9 @@ impl Server { Message::Notification(n) if n.method == "experimental/serverStatus" => { let status = n .clone() - .extract::("experimental/serverStatus") + .extract::("experimental/serverStatus") .unwrap(); - if status.health != lsp_ext::Health::Ok { + if status.health != lsp::ext::Health::Ok { panic!("server errored/warned while loading workspace: {:?}", status.message); } status.quiescent diff --git a/crates/rust-analyzer/tests/slow-tests/tidy.rs b/crates/rust-analyzer/tests/slow-tests/tidy.rs index f230cba2bf8..9d984f0833a 100644 --- a/crates/rust-analyzer/tests/slow-tests/tidy.rs +++ b/crates/rust-analyzer/tests/slow-tests/tidy.rs @@ -35,7 +35,7 @@ fn check_lsp_extensions_docs() { let expected_hash = { let lsp_ext_rs = sh - .read_file(sourcegen::project_root().join("crates/rust-analyzer/src/lsp_ext.rs")) + .read_file(sourcegen::project_root().join("crates/rust-analyzer/src/lsp/ext.rs")) .unwrap(); stable_hash(lsp_ext_rs.as_str()) }; @@ -45,7 +45,7 @@ fn check_lsp_extensions_docs() { sh.read_file(sourcegen::project_root().join("docs/dev/lsp-extensions.md")).unwrap(); let text = lsp_extensions_md .lines() - .find_map(|line| line.strip_prefix("lsp_ext.rs hash:")) + .find_map(|line| line.strip_prefix("lsp/ext.rs hash:")) .unwrap() .trim(); u64::from_str_radix(text, 16).unwrap() @@ -54,7 +54,7 @@ fn check_lsp_extensions_docs() { if actual_hash != expected_hash { panic!( " -lsp_ext.rs was changed without touching lsp-extensions.md. +lsp/ext.rs was changed without touching lsp-extensions.md. Expected hash: {expected_hash:x} Actual hash: {actual_hash:x} diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 024acb87709..67d82a68548 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md @@ -1,5 +1,5 @@