aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-03-02 06:05:15 +0000
committerEdwin Cheng <[email protected]>2020-03-03 17:21:14 +0000
commit1465cc0c4feb52958d3281f066a663e0a52ed67e (patch)
tree933d006064847260d5ec0d816fef5a381e674f90 /crates/ra_syntax
parent0d554540730925c074693b43503e65476eadbd65 (diff)
Implement concat macro
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/make.rs8
1 files changed, 7 insertions, 1 deletions
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 {
219} 219}
220 220
221pub mod tokens { 221pub mod tokens {
222 use crate::{AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T}; 222 use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T};
223 use once_cell::sync::Lazy; 223 use once_cell::sync::Lazy;
224 224
225 pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = 225 pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> =
@@ -251,6 +251,12 @@ pub mod tokens {
251 sf.syntax().first_child_or_token().unwrap().into_token().unwrap() 251 sf.syntax().first_child_or_token().unwrap().into_token().unwrap()
252 } 252 }
253 253
254 pub fn literal(text: &str) -> SyntaxToken {
255 assert_eq!(text.trim(), text);
256 let lit: ast::Literal = super::ast_from_text(&format!("fn f() {{ let _ = {}; }}", text));
257 lit.syntax().first_child_or_token().unwrap().into_token().unwrap()
258 }
259
254 pub fn single_newline() -> SyntaxToken { 260 pub fn single_newline() -> SyntaxToken {
255 SOURCE_FILE 261 SOURCE_FILE
256 .tree() 262 .tree()