mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
moar icons
This commit is contained in:
parent
238b52358d
commit
97cb463c9b
7 changed files with 34 additions and 7 deletions
|
@ -17,8 +17,10 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
|
|||
_ => return Ok(()),
|
||||
};
|
||||
let module_scope = target_module.scope(ctx.db)?;
|
||||
module_scope.entries().for_each(|(name, _res)| {
|
||||
CompletionItem::new(CompletionKind::Reference, name.to_string()).add_to(acc)
|
||||
module_scope.entries().for_each(|(name, res)| {
|
||||
CompletionItem::new(CompletionKind::Reference, name.to_string())
|
||||
.from_resolution(ctx.db, res)
|
||||
.add_to(acc)
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -29,8 +29,10 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
|
|||
}
|
||||
}
|
||||
})
|
||||
.for_each(|(name, _res)| {
|
||||
CompletionItem::new(CompletionKind::Reference, name.to_string()).add_to(acc)
|
||||
.for_each(|(name, res)| {
|
||||
CompletionItem::new(CompletionKind::Reference, name.to_string())
|
||||
.from_resolution(ctx.db, res)
|
||||
.add_to(acc)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use crate::db;
|
||||
|
||||
/// `CompletionItem` describes a single completion variant in the editor pop-up.
|
||||
/// It is basically a POD with various properties. To construct a
|
||||
/// `CompletionItem`, use `new` method and the `Builder` struct.
|
||||
|
@ -21,6 +23,8 @@ pub enum InsertText {
|
|||
pub enum CompletionItemKind {
|
||||
Snippet,
|
||||
Keyword,
|
||||
Module,
|
||||
Function,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
|
@ -107,6 +111,23 @@ impl Builder {
|
|||
self.kind = Some(kind);
|
||||
self
|
||||
}
|
||||
pub(crate) fn from_resolution(
|
||||
mut self,
|
||||
db: &db::RootDatabase,
|
||||
resolution: &hir::Resolution,
|
||||
) -> Builder {
|
||||
if let Some(def_id) = resolution.def_id {
|
||||
if let Ok(def) = def_id.resolve(db) {
|
||||
let kind = match def {
|
||||
hir::Def::Module(..) => CompletionItemKind::Module,
|
||||
hir::Def::Function(..) => CompletionItemKind::Function,
|
||||
_ => return self,
|
||||
};
|
||||
self.kind = Some(kind);
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<CompletionItem> for Builder {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue