aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
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()