eliminate find_use_path and show 'as' and 'use'

This commit is contained in:
mahdi-frms 2021-07-04 20:57:45 +04:30
parent 486bffc23e
commit 02d33c9856
4 changed files with 16 additions and 21 deletions

View file

@ -1,6 +1,6 @@
//! Renderer for `const` fields.
use hir::{AsAssocItem, HasSource, ModuleDef};
use hir::{AsAssocItem, HasSource};
use ide_db::SymbolKind;
use syntax::{
ast::{Const, NameOwner},
@ -49,11 +49,8 @@ impl<'a> ConstRender<'a> {
let db = self.ctx.db();
if let Some(actm) = self.const_.as_assoc_item(db) {
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
let module = self.ctx.completion.scope.module().unwrap();
if let Some(path) = module.find_use_path(db, ModuleDef::Trait(trt)) {
item.label(format!("{} ({})", name.clone(), path));
item.insert_text(name.clone());
}
item.trait_name(trt.name(db).to_string());
item.insert_text(name.clone());
}
}

View file

@ -1,6 +1,6 @@
//! Renderer for function calls.
use hir::{AsAssocItem, HasSource, HirDisplay, ModuleDef};
use hir::{AsAssocItem, HasSource, HirDisplay};
use ide_db::SymbolKind;
use itertools::Itertools;
use syntax::ast::Fn;
@ -79,14 +79,7 @@ impl<'a> FunctionRender<'a> {
let db = self.ctx.db();
if let Some(actm) = self.func.as_assoc_item(db) {
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
let module = self.ctx.completion.scope.module().unwrap();
if let Some(path) = module.find_use_path(db, ModuleDef::Trait(trt)) {
item.label(format!(
"{} ({})",
item.clone().build().label().to_owned(),
path
));
}
item.trait_name(trt.name(db).to_string());
}
}
}

View file

@ -1,6 +1,6 @@
//! Renderer for type aliases.
use hir::{AsAssocItem, HasSource, ModuleDef};
use hir::{AsAssocItem, HasSource};
use ide_db::SymbolKind;
use syntax::{
ast::{NameOwner, TypeAlias},
@ -62,11 +62,8 @@ impl<'a> TypeAliasRender<'a> {
let db = self.ctx.db();
if let Some(actm) = self.type_alias.as_assoc_item(db) {
if let Some(trt) = actm.containing_trait_or_trait_impl(db) {
let module = self.ctx.completion.scope.module().unwrap();
if let Some(path) = module.find_use_path(db, ModuleDef::Trait(trt)) {
item.label(format!("{} ({})", name.clone(), path));
item.insert_text(name.clone());
}
item.trait_name(trt.name(db).to_string());
item.insert_text(name.clone());
}
}