aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/make.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast/make.rs')
-rw-r--r--crates/ra_syntax/src/ast/make.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 9749327fa..40db570da 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -173,10 +173,21 @@ fn ast_from_text<N: AstNode>(text: &str) -> N {
173} 173}
174 174
175pub mod tokens { 175pub mod tokens {
176 use crate::{AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T}; 176 use crate::{AstNode, Parse, SourceFile, SyntaxKind, SyntaxKind::*, SyntaxToken, T};
177 use once_cell::sync::Lazy; 177 use once_cell::sync::Lazy;
178 178
179 static SOURCE_FILE: Lazy<Parse<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;")); 179 static SOURCE_FILE: Lazy<Parse<SourceFile>> =
180 Lazy::new(|| SourceFile::parse("const C: () = (1 != 1, 2 == 2)\n;"));
181
182 pub fn op(op: SyntaxKind) -> SyntaxToken {
183 SOURCE_FILE
184 .tree()
185 .syntax()
186 .descendants_with_tokens()
187 .filter_map(|it| it.into_token())
188 .find(|it| it.kind() == op)
189 .unwrap()
190 }
180 191
181 pub fn comma() -> SyntaxToken { 192 pub fn comma() -> SyntaxToken {
182 SOURCE_FILE 193 SOURCE_FILE