aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-01-15 17:48:28 +0000
committerAleksey Kladov <[email protected]>2020-01-15 17:48:28 +0000
commitef1326ee19c9ff707dcf96ce289102deedcf4d5f (patch)
tree13315f0f9fdbe1d69d228d745147b28a5edd99ab /crates/ra_assists/src
parent7d2d3ac3db6ea7bbb3d77569495176da3b2992e6 (diff)
More orthogonal path editing
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/ast_transform.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index eac2903d1..56b7588ef 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -2,7 +2,7 @@
2use rustc_hash::FxHashMap; 2use rustc_hash::FxHashMap;
3 3
4use hir::{db::HirDatabase, InFile, PathResolution}; 4use hir::{db::HirDatabase, InFile, PathResolution};
5use ra_syntax::ast::{self, make, AstNode}; 5use ra_syntax::ast::{self, AstNode};
6 6
7pub trait AstTransform<'a> { 7pub trait AstTransform<'a> {
8 fn get_substitution( 8 fn get_substitution(
@@ -134,11 +134,18 @@ impl<'a, DB: HirDatabase> QualifyPaths<'a, DB> {
134 match resolution { 134 match resolution {
135 PathResolution::Def(def) => { 135 PathResolution::Def(def) => {
136 let found_path = from.find_use_path(self.db, def)?; 136 let found_path = from.find_use_path(self.db, def)?;
137 let args = p 137 let mut path = path_to_ast(found_path);
138
139 let type_args = p
138 .segment() 140 .segment()
139 .and_then(|s| s.type_arg_list()) 141 .and_then(|s| s.type_arg_list())
140 .map(|arg_list| apply(self, node.with_value(arg_list))); 142 .map(|arg_list| apply(self, node.with_value(arg_list)));
141 Some(make::path_with_type_arg_list(path_to_ast(found_path), args).syntax().clone()) 143 if let Some(type_args) = type_args {
144 let last_segment = path.segment().unwrap();
145 path = path.with_segment(last_segment.with_type_args(type_args))
146 }
147
148 Some(path.syntax().clone())
142 } 149 }
143 PathResolution::Local(_) 150 PathResolution::Local(_)
144 | PathResolution::TypeParam(_) 151 | PathResolution::TypeParam(_)