aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/make.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-01-10 17:26:18 +0000
committerFlorian Diebold <[email protected]>2020-01-11 22:33:04 +0000
commit15fc643e05bf8273e378243edbfb3be7aea7ce11 (patch)
tree9b5bad379840dd25b548158ad962fadd31c54d33 /crates/ra_syntax/src/ast/make.rs
parent12905e5b58f22df026ef30afa6f0bdf7319cbddd (diff)
Fix ordering problem between qualifying paths and substituting params
Diffstat (limited to 'crates/ra_syntax/src/ast/make.rs')
-rw-r--r--crates/ra_syntax/src/ast/make.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 68d64a0cc..9781b748f 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::{ast, AstNode, SourceFile}; 5use crate::{algo, ast, AstNode, SourceFile};
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))
@@ -23,7 +23,14 @@ fn path_from_text(text: &str) -> ast::Path {
23} 23}
24pub fn path_with_type_arg_list(path: ast::Path, args: Option<ast::TypeArgList>) -> ast::Path { 24pub fn path_with_type_arg_list(path: ast::Path, args: Option<ast::TypeArgList>) -> ast::Path {
25 if let Some(args) = args { 25 if let Some(args) = args {
26 ast_from_text(&format!("const X: {}{}", path.syntax(), args.syntax())) 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()
27 } else { 34 } else {
28 path 35 path
29 } 36 }