aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-16 13:43:21 +0100
committerGitHub <[email protected]>2019-09-16 13:43:21 +0100
commitba583091e60553633dd3cc9ab37a1d9f64827a1e (patch)
tree41a9b72f46b1119ff32964f77365459fdb46a37d /crates/ra_assists/src
parent6b33b90091b0cecd4c092d34451aba9f2492063c (diff)
parent7ed3be32916facf3b709d5277381408cd3ec134a (diff)
Merge #1817
1817: Support path starting with a type r=matklad a=uHOOCCOOHu The path syntax `<Ty>::foo` Co-authored-by: uHOOCCOOHu <[email protected]>
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/auto_import.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs
index 1158adbbc..5aae98546 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(
504 } 504 }
505} 505}
506 506
507pub fn collect_hir_path_segments(path: &hir::Path) -> Vec<SmolStr> { 507pub fn collect_hir_path_segments(path: &hir::Path) -> Option<Vec<SmolStr>> {
508 let mut ps = Vec::<SmolStr>::with_capacity(10); 508 let mut ps = Vec::<SmolStr>::with_capacity(10);
509 match path.kind { 509 match path.kind {
510 hir::PathKind::Abs => ps.push("".into()), 510 hir::PathKind::Abs => ps.push("".into()),
@@ -512,11 +512,12 @@ pub fn collect_hir_path_segments(path: &hir::Path) -> Vec<SmolStr> {
512 hir::PathKind::Plain => {} 512 hir::PathKind::Plain => {}
513 hir::PathKind::Self_ => ps.push("self".into()), 513 hir::PathKind::Self_ => ps.push("self".into()),
514 hir::PathKind::Super => ps.push("super".into()), 514 hir::PathKind::Super => ps.push("super".into()),
515 hir::PathKind::Type(_) => return None,
515 } 516 }
516 for s in path.segments.iter() { 517 for s in path.segments.iter() {
517 ps.push(s.name.to_string().into()); 518 ps.push(s.name.to_string().into());
518 } 519 }
519 ps 520 Some(ps)
520} 521}
521 522
522// This function produces sequence of text edits into edit 523// This function produces sequence of text edits into edit
@@ -552,7 +553,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist
552 } 553 }
553 554
554 let hir_path = hir::Path::from_ast(path.clone())?; 555 let hir_path = hir::Path::from_ast(path.clone())?;
555 let segments = collect_hir_path_segments(&hir_path); 556 let segments = collect_hir_path_segments(&hir_path)?;
556 if segments.len() < 2 { 557 if segments.len() < 2 {
557 return None; 558 return None;
558 } 559 }