From e7206467d57c555f1ca1fee6acc0461d7579f4f7 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 9 Mar 2020 00:13:04 +0800 Subject: Add parse_to_token_tree --- crates/ra_syntax/src/ast/make.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 53d6fa562..ae8829807 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -267,6 +267,12 @@ pub mod tokens { sf.syntax().first_child_or_token().unwrap().into_token().unwrap() } + pub fn doc_comment(text: &str) -> SyntaxToken { + assert!(!text.trim().is_empty()); + let sf = SourceFile::parse(text).ok().unwrap(); + sf.syntax().first_child_or_token().unwrap().into_token().unwrap() + } + pub fn literal(text: &str) -> SyntaxToken { assert_eq!(text.trim(), text); let lit: ast::Literal = super::ast_from_text(&format!("fn f() {{ let _ = {}; }}", text)); -- cgit v1.2.3