mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
refactor requirements put forward mkladov
This commit is contained in:
parent
e7899625e6
commit
06ff8e6c76
3 changed files with 22 additions and 21 deletions
File diff suppressed because one or more lines are too long
|
@ -42,6 +42,7 @@ const ASSISTS_TESTS: &str = "crates/ra_assists/src/tests/generated.rs";
|
|||
|
||||
const REPOSITORY_URL: &str = "https://github.com/rust-lang/rust";
|
||||
const UNSTABLE_FEATURE: &str = "crates/ra_ide/src/completion/unstable_feature_descriptor.rs";
|
||||
const REPO_PATH: &str = "src/doc/unstable-book/src";
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum Mode {
|
||||
|
|
|
@ -2,27 +2,13 @@
|
|||
|
||||
use crate::codegen::update;
|
||||
use crate::codegen::{self, project_root, Mode, Result};
|
||||
use crate::not_bash::{fs2, pushd, run};
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::quote;
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
use std::path::PathBuf;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub fn generate_unstable_future_descriptor(mode: Mode) -> Result<()> {
|
||||
let path = project_root().join(codegen::STORAGE);
|
||||
fs::create_dir_all(path.clone())?;
|
||||
|
||||
Command::new("git").current_dir(path.clone()).arg("init").output()?;
|
||||
Command::new("git")
|
||||
.current_dir(path.clone())
|
||||
.args(&["remote", "add", "-f", "origin", codegen::REPOSITORY_URL])
|
||||
.output()?;
|
||||
Command::new("git")
|
||||
.current_dir(path.clone())
|
||||
.args(&["sparse-checkout", "set", "/src/doc/unstable-book/src/"])
|
||||
.output()?;
|
||||
Command::new("git").current_dir(path.clone()).args(&["pull", "origin", "master"]).output()?;
|
||||
|
||||
let src_dir = path.join("src/doc/unstable-book/src");
|
||||
fn generate_descriptor(src_dir: PathBuf) -> Result<TokenStream> {
|
||||
let files = WalkDir::new(src_dir.join("language-features"))
|
||||
.into_iter()
|
||||
.chain(WalkDir::new(src_dir.join("library-features")))
|
||||
|
@ -49,13 +35,27 @@ pub fn generate_unstable_future_descriptor(mode: Mode) -> Result<()> {
|
|||
let ts = quote! {
|
||||
use crate::completion::LintCompletion;
|
||||
|
||||
pub const UNSTABLE_FEATURE_DESCRIPTOR: &[LintCompletion] = &[
|
||||
pub(crate) const UNSTABLE_FEATURE_DESCRIPTOR: &[LintCompletion] = &[
|
||||
#(#definitions),*
|
||||
];
|
||||
};
|
||||
Ok(ts)
|
||||
}
|
||||
|
||||
pub fn generate_unstable_future_descriptor(mode: Mode) -> Result<()> {
|
||||
let path = project_root().join(codegen::STORAGE);
|
||||
fs2::create_dir_all(path.clone())?;
|
||||
|
||||
let _d = pushd(path.clone());
|
||||
run!("git init")?;
|
||||
run!("git remote add -f origin {}", codegen::REPOSITORY_URL)?;
|
||||
run!("git pull origin master")?;
|
||||
|
||||
let src_dir = path.join(codegen::REPO_PATH);
|
||||
let content = generate_descriptor(src_dir)?.to_string();
|
||||
|
||||
let contents = crate::reformat(content)?;
|
||||
let destination = project_root().join(codegen::UNSTABLE_FEATURE);
|
||||
let contents = crate::reformat(ts.to_string())?;
|
||||
update(destination.as_path(), &contents, mode)?;
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue