From 4926bed42680d329f906be93450bec6b2ba0e99b Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Thu, 12 Sep 2019 02:01:07 +0800 Subject: Support path starting with a type --- crates/ra_assists/src/auto_import.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs index 1158adbbc..5ecda1ff5 100644 --- a/crates/ra_assists/src/auto_import.rs +++ b/crates/ra_assists/src/auto_import.rs @@ -504,7 +504,7 @@ fn apply_auto_import( } } -pub fn collect_hir_path_segments(path: &hir::Path) -> Vec { +pub fn collect_hir_path_segments(path: &hir::Path) -> Option> { let mut ps = Vec::::with_capacity(10); match path.kind { hir::PathKind::Abs => ps.push("".into()), @@ -512,11 +512,12 @@ pub fn collect_hir_path_segments(path: &hir::Path) -> Vec { hir::PathKind::Plain => {} hir::PathKind::Self_ => ps.push("self".into()), hir::PathKind::Super => ps.push("super".into()), + hir::PathKind::Type => return None, } for s in path.segments.iter() { ps.push(s.name.to_string().into()); } - ps + Some(ps) } // This function produces sequence of text edits into edit @@ -552,7 +553,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx) -> Option Date: Sun, 15 Sep 2019 19:48:24 +0800 Subject: Move store TypeRef of type based path in PathKind --- crates/ra_assists/src/auto_import.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs index 5ecda1ff5..5aae98546 100644 --- a/crates/ra_assists/src/auto_import.rs +++ b/crates/ra_assists/src/auto_import.rs @@ -512,7 +512,7 @@ pub fn collect_hir_path_segments(path: &hir::Path) -> Option> { hir::PathKind::Plain => {} hir::PathKind::Self_ => ps.push("self".into()), hir::PathKind::Super => ps.push("super".into()), - hir::PathKind::Type => return None, + hir::PathKind::Type(_) => return None, } for s in path.segments.iter() { ps.push(s.name.to_string().into()); -- cgit v1.2.3