mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Remove now dead code
This commit is contained in:
parent
095b9110b5
commit
e89c0e3961
9 changed files with 76 additions and 90 deletions
|
@ -2,14 +2,16 @@
|
|||
|
||||
use std::{fmt, path::Path};
|
||||
|
||||
use xshell::write_file;
|
||||
|
||||
use crate::{
|
||||
codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE},
|
||||
codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, PREAMBLE},
|
||||
project_root, rust_files_in, Result,
|
||||
};
|
||||
|
||||
pub(crate) fn generate_assists_tests(mode: Mode) -> Result<()> {
|
||||
pub(crate) fn generate_assists_tests() -> Result<()> {
|
||||
let assists = Assist::collect()?;
|
||||
generate_tests(&assists, mode)
|
||||
generate_tests(&assists)
|
||||
}
|
||||
|
||||
pub(crate) fn generate_assists_docs() -> Result<()> {
|
||||
|
@ -17,7 +19,8 @@ pub(crate) fn generate_assists_docs() -> Result<()> {
|
|||
let contents = assists.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
|
||||
let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim());
|
||||
let dst = project_root().join("docs/user/generated_assists.adoc");
|
||||
codegen::update(&dst, &contents, Mode::Overwrite)
|
||||
write_file(dst, &contents)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -111,7 +114,7 @@ impl fmt::Display for Assist {
|
|||
}
|
||||
}
|
||||
|
||||
fn generate_tests(assists: &[Assist], mode: Mode) -> Result<()> {
|
||||
fn generate_tests(assists: &[Assist]) -> Result<()> {
|
||||
let mut buf = String::from("use super::check_doc_test;\n");
|
||||
|
||||
for assist in assists.iter() {
|
||||
|
@ -135,7 +138,10 @@ r#####"
|
|||
buf.push_str(&test)
|
||||
}
|
||||
let buf = reformat(&buf)?;
|
||||
codegen::update(&project_root().join("crates/ide_assists/src/tests/generated.rs"), &buf, mode)
|
||||
codegen::ensure_file_contents(
|
||||
&project_root().join("crates/ide_assists/src/tests/generated.rs"),
|
||||
&buf,
|
||||
)
|
||||
}
|
||||
|
||||
fn hide_hash_comments(text: &str) -> String {
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
use std::{fmt, path::PathBuf};
|
||||
|
||||
use xshell::write_file;
|
||||
|
||||
use crate::{
|
||||
codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
|
||||
codegen::{extract_comment_blocks_with_empty_lines, Location, PREAMBLE},
|
||||
project_root, rust_files, Result,
|
||||
};
|
||||
|
||||
|
@ -13,7 +15,7 @@ pub(crate) fn generate_diagnostic_docs() -> Result<()> {
|
|||
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
|
||||
let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim());
|
||||
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
|
||||
codegen::update(&dst, &contents, Mode::Overwrite)?;
|
||||
write_file(&dst, &contents)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
use std::{fmt, path::PathBuf};
|
||||
|
||||
use xshell::write_file;
|
||||
|
||||
use crate::{
|
||||
codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
|
||||
codegen::{extract_comment_blocks_with_empty_lines, Location, PREAMBLE},
|
||||
project_root, rust_files, Result,
|
||||
};
|
||||
|
||||
|
@ -12,7 +14,7 @@ pub(crate) fn generate_feature_docs() -> Result<()> {
|
|||
let contents = features.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
|
||||
let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim());
|
||||
let dst = project_root().join("docs/user/generated_features.adoc");
|
||||
codegen::update(&dst, &contents, Mode::Overwrite)?;
|
||||
write_file(&dst, &contents)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,9 @@ use std::path::{Path, PathBuf};
|
|||
use walkdir::WalkDir;
|
||||
use xshell::{cmd, read_file};
|
||||
|
||||
use crate::{
|
||||
codegen::{project_root, reformat, update, Mode, Result},
|
||||
run_rustfmt,
|
||||
};
|
||||
use crate::codegen::{ensure_file_contents, project_root, reformat, Result};
|
||||
|
||||
pub(crate) fn generate_lint_completions(mode: Mode) -> Result<()> {
|
||||
pub(crate) fn generate_lint_completions() -> Result<()> {
|
||||
if !Path::new("./target/rust").exists() {
|
||||
cmd!("git clone --depth=1 https://github.com/rust-lang/rust ./target/rust").run()?;
|
||||
}
|
||||
|
@ -25,8 +22,7 @@ pub(crate) fn generate_lint_completions(mode: Mode) -> Result<()> {
|
|||
|
||||
let destination =
|
||||
project_root().join("crates/ide_completion/src/generated_lint_completions.rs");
|
||||
update(destination.as_path(), &contents, mode)?;
|
||||
run_rustfmt(mode)?;
|
||||
ensure_file_contents(destination.as_path(), &contents)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@ use std::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
codegen::{extract_comment_blocks, update, Mode},
|
||||
codegen::{ensure_file_contents, extract_comment_blocks},
|
||||
project_root, Result,
|
||||
};
|
||||
|
||||
pub(crate) fn generate_parser_tests(mode: Mode) -> Result<()> {
|
||||
pub(crate) fn generate_parser_tests() -> Result<()> {
|
||||
let tests = tests_from_dir(&project_root().join(Path::new("crates/parser/src/grammar")))?;
|
||||
fn install_tests(tests: &HashMap<String, Test>, into: &str, mode: Mode) -> Result<()> {
|
||||
fn install_tests(tests: &HashMap<String, Test>, into: &str) -> Result<()> {
|
||||
let tests_dir = project_root().join(into);
|
||||
if !tests_dir.is_dir() {
|
||||
fs::create_dir_all(&tests_dir)?;
|
||||
|
@ -35,12 +35,12 @@ pub(crate) fn generate_parser_tests(mode: Mode) -> Result<()> {
|
|||
tests_dir.join(file_name)
|
||||
}
|
||||
};
|
||||
update(&path, &test.text, mode)?;
|
||||
ensure_file_contents(&path, &test.text)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
install_tests(&tests.ok, "crates/syntax/test_data/parser/inline/ok", mode)?;
|
||||
install_tests(&tests.err, "crates/syntax/test_data/parser/inline/err", mode)
|
||||
install_tests(&tests.ok, "crates/syntax/test_data/parser/inline/ok")?;
|
||||
install_tests(&tests.err, "crates/syntax/test_data/parser/inline/err")
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -14,25 +14,25 @@ use ungrammar::{rust_grammar, Grammar, Rule};
|
|||
|
||||
use crate::{
|
||||
ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc, KINDS_SRC},
|
||||
codegen::{reformat, update, Mode},
|
||||
codegen::{ensure_file_contents, reformat},
|
||||
project_root, Result,
|
||||
};
|
||||
|
||||
pub(crate) fn generate_syntax(mode: Mode) -> Result<()> {
|
||||
pub(crate) fn generate_syntax() -> Result<()> {
|
||||
let grammar = rust_grammar();
|
||||
let ast = lower(&grammar);
|
||||
|
||||
let syntax_kinds_file = project_root().join("crates/parser/src/syntax_kind/generated.rs");
|
||||
let syntax_kinds = generate_syntax_kinds(KINDS_SRC)?;
|
||||
update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?;
|
||||
ensure_file_contents(syntax_kinds_file.as_path(), &syntax_kinds)?;
|
||||
|
||||
let ast_tokens_file = project_root().join("crates/syntax/src/ast/generated/tokens.rs");
|
||||
let contents = generate_tokens(&ast)?;
|
||||
update(ast_tokens_file.as_path(), &contents, mode)?;
|
||||
ensure_file_contents(ast_tokens_file.as_path(), &contents)?;
|
||||
|
||||
let ast_nodes_file = project_root().join("crates/syntax/src/ast/generated/nodes.rs");
|
||||
let contents = generate_nodes(KINDS_SRC, &ast)?;
|
||||
update(ast_nodes_file.as_path(), &contents, mode)?;
|
||||
ensure_file_contents(ast_nodes_file.as_path(), &contents)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue