From 59b6b2278b7f7d2089b5caf6fcfd57528d9aafd0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 16:25:06 +0200 Subject: [PATCH] Start ast/generated/tokens --- crates/ra_syntax/src/ast/generated.rs | 1 + crates/ra_syntax/src/ast/generated/tokens.rs | 1 + xtask/src/codegen.rs | 1 + xtask/src/codegen/gen_syntax.rs | 10 +++++++--- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 crates/ra_syntax/src/ast/generated/tokens.rs diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 6216641d88..1e0ba3f71b 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1,3 +1,4 @@ //! This file is actually hand-written, but the submodules are indeed generated. pub(super) mod nodes; +pub(super) mod tokens; diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs new file mode 100644 index 0000000000..4494af1be9 --- /dev/null +++ b/crates/ra_syntax/src/ast/generated/tokens.rs @@ -0,0 +1 @@ +//! Generated file, do not edit by hand, see `xtask/src/codegen` \ No newline at end of file diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index e6ba2009c1..678b40133b 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -24,6 +24,7 @@ const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs"; const AST_NODES: &str = "crates/ra_syntax/src/ast/generated/nodes.rs"; +const AST_TOKENS: &str = "crates/ra_syntax/src/ast/generated/tokens.rs"; const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs"; diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs index c2734d638b..75bcd1973e 100644 --- a/xtask/src/codegen/gen_syntax.rs +++ b/xtask/src/codegen/gen_syntax.rs @@ -22,9 +22,13 @@ pub fn generate_syntax(mode: Mode) -> Result<()> { let syntax_kinds = generate_syntax_kinds(KINDS_SRC)?; update(syntax_kinds_file.as_path(), &syntax_kinds, mode)?; - let ast_file = project_root().join(codegen::AST_NODES); - let ast = generate_ast(KINDS_SRC, AST_SRC)?; - update(ast_file.as_path(), &ast, mode)?; + let ast_nodes_file = project_root().join(codegen::AST_NODES); + let contents = generate_ast(KINDS_SRC, AST_SRC)?; + update(ast_nodes_file.as_path(), &contents, mode)?; + + let ast_tokens_file = project_root().join(codegen::AST_TOKENS); + let contents = "//! Generated file, do not edit by hand, see `xtask/src/codegen`"; + update(ast_tokens_file.as_path(), &contents, mode)?; Ok(()) }