aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src/handlers/qualify_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src/handlers/qualify_path.rs')
-rw-r--r--crates/ide_assists/src/handlers/qualify_path.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/crates/ide_assists/src/handlers/qualify_path.rs b/crates/ide_assists/src/handlers/qualify_path.rs
index 272874ae3..30b23da6c 100644
--- a/crates/ide_assists/src/handlers/qualify_path.rs
+++ b/crates/ide_assists/src/handlers/qualify_path.rs
@@ -3,7 +3,7 @@ use std::iter;
3use hir::AsAssocItem; 3use hir::AsAssocItem;
4use ide_db::helpers::{ 4use ide_db::helpers::{
5 import_assets::{ImportCandidate, LocatedImport}, 5 import_assets::{ImportCandidate, LocatedImport},
6 item_name, mod_path_to_ast, 6 mod_path_to_ast,
7}; 7};
8use ide_db::RootDatabase; 8use ide_db::RootDatabase;
9use syntax::{ 9use syntax::{
@@ -78,7 +78,7 @@ pub(crate) fn qualify_path(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
78 acc.add_group( 78 acc.add_group(
79 &group_label, 79 &group_label,
80 AssistId("qualify_path", AssistKind::QuickFix), 80 AssistId("qualify_path", AssistKind::QuickFix),
81 label(ctx.db(), candidate, &import), 81 label(candidate, &import),
82 range, 82 range,
83 |builder| { 83 |builder| {
84 qualify_candidate.qualify( 84 qualify_candidate.qualify(
@@ -199,21 +199,17 @@ fn group_label(candidate: &ImportCandidate) -> GroupLabel {
199 GroupLabel(format!("Qualify {}", name)) 199 GroupLabel(format!("Qualify {}", name))
200} 200}
201 201
202fn label(db: &RootDatabase, candidate: &ImportCandidate, import: &LocatedImport) -> String { 202fn label(candidate: &ImportCandidate, import: &LocatedImport) -> String {
203 let display_path = match item_name(db, import.original_item) {
204 Some(display_path) => display_path.to_string(),
205 None => "{unknown}".to_string(),
206 };
207 match candidate { 203 match candidate {
208 ImportCandidate::Path(candidate) => { 204 ImportCandidate::Path(candidate) => {
209 if candidate.qualifier.is_some() { 205 if candidate.qualifier.is_some() {
210 format!("Qualify with `{}`", display_path) 206 format!("Qualify with `{}`", import.import_path)
211 } else { 207 } else {
212 format!("Qualify as `{}`", display_path) 208 format!("Qualify as `{}`", import.import_path)
213 } 209 }
214 } 210 }
215 ImportCandidate::TraitAssocItem(_) => format!("Qualify `{}`", display_path), 211 ImportCandidate::TraitAssocItem(_) => format!("Qualify `{}`", import.import_path),
216 ImportCandidate::TraitMethod(_) => format!("Qualify with cast as `{}`", display_path), 212 ImportCandidate::TraitMethod(_) => format!("Qualify with cast as `{}`", import.import_path),
217 } 213 }
218} 214}
219 215