aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-01-10 17:40:45 +0000
committerFlorian Diebold <[email protected]>2020-01-11 22:33:04 +0000
commit4496e2a06a91e5825f355ce730af802643e8018a (patch)
treef0f41e2d9ff5045f34b38cd3d23bae11e5d56139 /crates/ra_assists
parent15fc643e05bf8273e378243edbfb3be7aea7ce11 (diff)
Apply review suggestions
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/ast_transform.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs
index 846661587..ace59f290 100644
--- a/crates/ra_assists/src/ast_transform.rs
+++ b/crates/ra_assists/src/ast_transform.rs
@@ -60,6 +60,8 @@ impl<'a, DB: HirDatabase> SubstituteTypeParams<'a, DB> {
60 previous: Box::new(NullTransformer), 60 previous: Box::new(NullTransformer),
61 }; 61 };
62 62
63 // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the
64 // trait ref, and then go from the types in the substs back to the syntax)
63 fn get_syntactic_substs(impl_block: ast::ImplBlock) -> Option<Vec<ast::TypeRef>> { 65 fn get_syntactic_substs(impl_block: ast::ImplBlock) -> Option<Vec<ast::TypeRef>> {
64 let target_trait = impl_block.target_trait()?; 66 let target_trait = impl_block.target_trait()?;
65 let path_type = match target_trait { 67 let path_type = match target_trait {
@@ -131,12 +133,12 @@ impl<'a, DB: HirDatabase> QualifyPaths<'a, DB> {
131 let resolution = analyzer.resolve_path(self.db, &p)?; 133 let resolution = analyzer.resolve_path(self.db, &p)?;
132 match resolution { 134 match resolution {
133 PathResolution::Def(def) => { 135 PathResolution::Def(def) => {
134 let found_path = from.find_path(self.db, def)?; 136 let found_path = from.find_use_path(self.db, def)?;
135 let args = p 137 let args = p
136 .segment() 138 .segment()
137 .and_then(|s| s.type_arg_list()) 139 .and_then(|s| s.type_arg_list())
138 .map(|arg_list| apply(self, node.with_value(arg_list))); 140 .map(|arg_list| apply(self, node.with_value(arg_list)));
139 Some(make::path_with_type_arg_list(found_path.to_ast(), args).syntax().clone()) 141 Some(make::path_with_type_arg_list(path_to_ast(found_path), args).syntax().clone())
140 } 142 }
141 PathResolution::Local(_) 143 PathResolution::Local(_)
142 | PathResolution::TypeParam(_) 144 | PathResolution::TypeParam(_)
@@ -171,8 +173,7 @@ impl<'a, DB: HirDatabase> AstTransform<'a> for QualifyPaths<'a, DB> {
171 } 173 }
172} 174}
173 175
174// FIXME: It would probably be nicer if we could get this via HIR (i.e. get the 176fn path_to_ast(path: hir::ModPath) -> ast::Path {
175// trait ref, and then go from the types in the substs back to the syntax) 177 let parse = ast::SourceFile::parse(&path.to_string());
176// FIXME: This should be a general utility (not even just for assists) 178 parse.tree().syntax().descendants().find_map(ast::Path::cast).unwrap()
177 179}
178// FIXME: This should be a general utility (not even just for assists)