Update generated lint definitions

This commit is contained in:
Lukas Wirth 2024-07-07 08:35:18 +02:00
parent 90682c393d
commit 9b3e912d67
8 changed files with 1040 additions and 812 deletions

View file

@ -1,4 +1,4 @@
//! Generated by `sourcegen_assists_docs`, do not edit by hand.
//! Generated by `cargo codegen assists-doc-tests`, do not edit by hand.
use super::check_doc_test;

File diff suppressed because it is too large Load diff

View file

@ -18,6 +18,7 @@ impl flags::Codegen {
flags::CodegenType::All => {
diagnostics_docs::generate(self.check);
assists_doc_tests::generate(self.check);
// diagnostics_docs::generate(self.check) doesn't generate any tests
// lints::generate(self.check) Updating clones the rust repo, so don't run it unless
// explicitly asked for
}
@ -175,7 +176,8 @@ fn reformat(text: String) -> String {
}
fn add_preamble(generator: &'static str, mut text: String) -> String {
let preamble = format!("//! Generated by `{generator}`, do not edit by hand.\n\n");
let preamble =
format!("//! Generated by `cargo codegen {generator}`, do not edit by hand.\n\n");
text.insert_str(0, &preamble);
text
}

View file

@ -45,7 +45,7 @@ r#####"
buf.push_str(&test)
}
}
let buf = add_preamble("sourcegen_assists_docs", reformat(buf));
let buf = add_preamble("assists-doc-tests", reformat(buf));
ensure_file_contents(
&project_root().join("crates/ide-assists/src/tests/generated.rs"),
&buf,

View file

@ -12,7 +12,7 @@ pub(crate) fn generate(check: bool) {
if !check {
let contents =
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
let contents = add_preamble("sourcegen_diagnostic_docs", contents);
let contents = add_preamble("diagnostics-docs", contents);
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
fs::write(dst, contents).unwrap();
}

View file

@ -69,7 +69,7 @@ fn generate_tokens(grammar: &AstSrc) -> String {
});
add_preamble(
"sourcegen_ast",
"grammar",
reformat(
quote! {
use crate::{SyntaxKind::{self, *}, SyntaxToken, ast::AstToken};
@ -328,7 +328,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
}
}
let res = add_preamble("sourcegen_ast", reformat(res));
let res = add_preamble("grammar", reformat(res));
res.replace("#[derive", "\n#[derive")
}
@ -458,7 +458,7 @@ fn generate_syntax_kinds(grammar: KindsSrc<'_>) -> String {
}
};
add_preamble("sourcegen_ast", reformat(ast.to_string()))
add_preamble("grammar", reformat(ast.to_string()))
}
fn to_upper_snake_case(s: &str) -> String {

View file

@ -28,7 +28,7 @@ pub(crate) fn generate(check: bool) {
cmd!(
sh,
"git -C {rust_repo} submodule update --init --recursive --depth=1 --
compiler library src/tools"
compiler library src/tools src/doc/book"
)
.run()
.unwrap();
@ -73,7 +73,7 @@ pub struct LintGroup {
.unwrap();
generate_descriptor_clippy(&mut contents, &lints_json);
let contents = add_preamble("sourcegen_lints", reformat(contents));
let contents = add_preamble("lint-definitions", reformat(contents));
let destination = project_root().join(DESTINATION);
ensure_file_contents(destination.as_path(), &contents, check);

View file

@ -195,7 +195,7 @@ impl FromStr for CodegenType {
"grammar" => Ok(Self::Grammar),
"assists-doc-tests" => Ok(Self::AssistsDocTests),
"diagnostics-docs" => Ok(Self::DiagnosticsDocs),
"lints-definitions" => Ok(Self::LintDefinitions),
"lint-definitions" => Ok(Self::LintDefinitions),
_ => Err("Invalid option".to_owned()),
}
}