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.rs18
1 files changed, 2 insertions, 16 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 4a79d0dec..36e648180 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -2,7 +2,7 @@
2//! of smaller pieces. 2//! of smaller pieces.
3use itertools::Itertools; 3use itertools::Itertools;
4 4
5use crate::{algo, ast, AstNode, SourceFile, SyntaxKind, SyntaxToken}; 5use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxToken};
6 6
7pub fn name(text: &str) -> ast::Name { 7pub fn name(text: &str) -> ast::Name {
8 ast_from_text(&format!("mod {};", text)) 8 ast_from_text(&format!("mod {};", text))
@@ -21,20 +21,6 @@ pub fn path_qualified(qual: ast::Path, name_ref: ast::NameRef) -> ast::Path {
21fn path_from_text(text: &str) -> ast::Path { 21fn path_from_text(text: &str) -> ast::Path {
22 ast_from_text(text) 22 ast_from_text(text)
23} 23}
24pub fn path_with_type_arg_list(path: ast::Path, args: Option<ast::TypeArgList>) -> ast::Path {
25 if let Some(args) = args {
26 let syntax = path.syntax();
27 // FIXME: remove existing type args
28 let new_syntax = algo::insert_children(
29 syntax,
30 crate::algo::InsertPosition::Last,
31 &mut Some(args).into_iter().map(|n| n.syntax().clone().into()),
32 );
33 ast::Path::cast(new_syntax).unwrap()
34 } else {
35 path
36 }
37}
38 24
39pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField { 25pub fn record_field(name: ast::NameRef, expr: Option<ast::Expr>) -> ast::RecordField {
40 return match expr { 26 return match expr {
@@ -201,7 +187,7 @@ pub mod tokens {
201 use once_cell::sync::Lazy; 187 use once_cell::sync::Lazy;
202 188
203 pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = 189 pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> =
204 Lazy::new(|| SourceFile::parse("const C: () = (1 != 1, 2 == 2)\n;")); 190 Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2)\n;"));
205 191
206 pub fn comma() -> SyntaxToken { 192 pub fn comma() -> SyntaxToken {
207 SOURCE_FILE 193 SOURCE_FILE