Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/syntax/src/ast/make.rs')
-rw-r--r--crates/syntax/src/ast/make.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs
index 00971569a2..ac02cc9e43 100644
--- a/crates/syntax/src/ast/make.rs
+++ b/crates/syntax/src/ast/make.rs
@@ -1322,6 +1322,18 @@ pub fn meta_path(path: ast::Path) -> ast::Meta {
ast_from_text(&format!("#[{path}]"))
}
+pub fn cfg_attr_meta(
+ predicate: ast::CfgPredicate,
+ inner: impl IntoIterator<Item = ast::Meta>,
+) -> ast::CfgAttrMeta {
+ let inner = inner.into_iter().join(", ");
+ ast_from_text(&format!("#![cfg_attr({predicate}, {inner})]"))
+}
+
+pub fn cfg_flag(flag: &str) -> ast::CfgPredicate {
+ ast_from_text(&format!("#![cfg({flag})]"))
+}
+
pub fn token_tree(
delimiter: SyntaxKind,
tt: impl IntoIterator<Item = NodeOrToken<ast::TokenTree, SyntaxToken>>,