mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
show imported trait on autocompletion of associated items
This commit is contained in:
parent
e5c1c8cf2f
commit
486bffc23e
8 changed files with 74 additions and 36 deletions
|
@ -1,6 +1,6 @@
|
|||
//! Renderer for function calls.
|
||||
|
||||
use hir::{HasSource, HirDisplay};
|
||||
use hir::{AsAssocItem, HasSource, HirDisplay, ModuleDef};
|
||||
use ide_db::SymbolKind;
|
||||
use itertools::Itertools;
|
||||
use syntax::ast::Fn;
|
||||
|
@ -73,9 +73,25 @@ impl<'a> FunctionRender<'a> {
|
|||
self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func),
|
||||
)
|
||||
.detail(self.detail())
|
||||
.add_call_parens(self.ctx.completion, call.clone(), params)
|
||||
.add_import(import_to_add)
|
||||
.lookup_by(self.name);
|
||||
.add_call_parens(self.ctx.completion, call.clone(), params);
|
||||
|
||||
if import_to_add.is_none() {
|
||||
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.add_import(import_to_add).lookup_by(self.name);
|
||||
|
||||
let ret_type = self.func.ret_type(self.ctx.db());
|
||||
item.set_relevance(CompletionRelevance {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue