mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Add reminder to update lsp-extensions.md
This commit is contained in:
parent
b62f48f535
commit
d852189e56
2 changed files with 55 additions and 0 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
<!---
|
||||||
|
lsp_ext.rs hash: 286f8bbac885531a
|
||||||
|
|
||||||
|
If you need to change the above hash to make the test pass, please check if you
|
||||||
|
need to adjust this doc as well and ping this issue:
|
||||||
|
|
||||||
|
https://github.com/rust-analyzer/rust-analyzer/issues/4604
|
||||||
|
|
||||||
|
--->
|
||||||
|
|
||||||
# LSP Extensions
|
# LSP Extensions
|
||||||
|
|
||||||
This document describes LSP extensions used by rust-analyzer.
|
This document describes LSP extensions used by rust-analyzer.
|
||||||
|
|
|
@ -44,6 +44,41 @@ fn smoke_test_docs_generation() {
|
||||||
codegen::generate_feature_docs(Mode::Overwrite).unwrap();
|
codegen::generate_feature_docs(Mode::Overwrite).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn check_lsp_extensions_docs() {
|
||||||
|
let expected_hash = {
|
||||||
|
let lsp_ext_rs =
|
||||||
|
fs2::read_to_string(project_root().join("crates/rust-analyzer/src/lsp_ext.rs"))
|
||||||
|
.unwrap();
|
||||||
|
stable_hash(lsp_ext_rs.as_str())
|
||||||
|
};
|
||||||
|
|
||||||
|
let actual_hash = {
|
||||||
|
let lsp_extensions_md =
|
||||||
|
fs2::read_to_string(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:"))
|
||||||
|
.unwrap()
|
||||||
|
.trim();
|
||||||
|
u64::from_str_radix(text, 16).unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
|
if actual_hash != expected_hash {
|
||||||
|
panic!(
|
||||||
|
"
|
||||||
|
lsp_ext.rs was changed without touching lsp-extensions.md.
|
||||||
|
|
||||||
|
Expected hash: {:x}
|
||||||
|
Actual hash: {:x}
|
||||||
|
|
||||||
|
Please adjust docs/dev/lsp-extensions.md.
|
||||||
|
",
|
||||||
|
expected_hash, actual_hash
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rust_files_are_tidy() {
|
fn rust_files_are_tidy() {
|
||||||
let mut tidy_docs = TidyDocs::default();
|
let mut tidy_docs = TidyDocs::default();
|
||||||
|
@ -280,3 +315,13 @@ fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool {
|
||||||
.filter_map(|it| it.as_os_str().to_str())
|
.filter_map(|it| it.as_os_str().to_str())
|
||||||
.any(|it| dirs_to_exclude.contains(&it))
|
.any(|it| dirs_to_exclude.contains(&it))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
|
fn stable_hash(text: &str) -> u64 {
|
||||||
|
use std::hash::{Hash, Hasher, SipHasher};
|
||||||
|
|
||||||
|
let text = text.replace('\r', "");
|
||||||
|
let mut hasher = SipHasher::default();
|
||||||
|
text.hash(&mut hasher);
|
||||||
|
hasher.finish()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue