aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_syntax/src/ast/edit.rs4
-rw-r--r--crates/ra_syntax/src/ast/make.rs13
2 files changed, 4 insertions, 13 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index e4cdccdb4..40a04b9c5 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -139,7 +139,7 @@ impl ast::RecordFieldList {
139 let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new(); 139 let mut to_insert: ArrayVec<[SyntaxElement; 4]> = ArrayVec::new();
140 to_insert.push(space.into()); 140 to_insert.push(space.into());
141 to_insert.push(field.syntax().clone().into()); 141 to_insert.push(field.syntax().clone().into());
142 to_insert.push(tokens::comma().into()); 142 to_insert.push(make::token(T![,]).into());
143 143
144 macro_rules! after_l_curly { 144 macro_rules! after_l_curly {
145 () => {{ 145 () => {{
@@ -160,7 +160,7 @@ impl ast::RecordFieldList {
160 { 160 {
161 InsertPosition::After(comma) 161 InsertPosition::After(comma)
162 } else { 162 } else {
163 to_insert.insert(0, tokens::comma().into()); 163 to_insert.insert(0, make::token(T![,]).into());
164 InsertPosition::After($anchor.syntax().clone().into()) 164 InsertPosition::After($anchor.syntax().clone().into())
165 } 165 }
166 }; 166 };
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 22c54f363..f25b526b6 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -240,22 +240,13 @@ fn unroot(n: SyntaxNode) -> SyntaxNode {
240} 240}
241 241
242pub mod tokens { 242pub mod tokens {
243 use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T};
244 use once_cell::sync::Lazy; 243 use once_cell::sync::Lazy;
245 244
245 use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken};
246
246 pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = 247 pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> =
247 Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;")); 248 Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;"));
248 249
249 pub fn comma() -> SyntaxToken {
250 SOURCE_FILE
251 .tree()
252 .syntax()
253 .descendants_with_tokens()
254 .filter_map(|it| it.into_token())
255 .find(|it| it.kind() == T![,])
256 .unwrap()
257 }
258
259 pub fn single_space() -> SyntaxToken { 250 pub fn single_space() -> SyntaxToken {
260 SOURCE_FILE 251 SOURCE_FILE
261 .tree() 252 .tree()