From 1465cc0c4feb52958d3281f066a663e0a52ed67e Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 2 Mar 2020 14:05:15 +0800 Subject: Implement concat macro --- crates/ra_syntax/src/ast/make.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 3f11b747f..0da24560e 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -219,7 +219,7 @@ fn unroot(n: SyntaxNode) -> SyntaxNode { } pub mod tokens { - use crate::{AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T}; + use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T}; use once_cell::sync::Lazy; pub(super) static SOURCE_FILE: Lazy> = @@ -251,6 +251,12 @@ pub mod tokens { 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)); + lit.syntax().first_child_or_token().unwrap().into_token().unwrap() + } + pub fn single_newline() -> SyntaxToken { SOURCE_FILE .tree() -- cgit v1.2.3