use completion context when creating completion
This commit is contained in:
parent
0e90e0436a
commit
3ee7a95315
3 changed files with 8 additions and 8 deletions
|
|
@ -17,7 +17,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
|
|||
let module_scope = module.scope(ctx.db)?;
|
||||
module_scope.entries().for_each(|(name, res)| {
|
||||
CompletionItem::new(CompletionKind::Reference, name.to_string())
|
||||
.from_resolution(ctx.db, res)
|
||||
.from_resolution(ctx, res)
|
||||
.add_to(acc)
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
|
|||
})
|
||||
.for_each(|(name, res)| {
|
||||
CompletionItem::new(CompletionKind::Reference, name.to_string())
|
||||
.from_resolution(ctx.db, res)
|
||||
.from_resolution(ctx, res)
|
||||
.add_to(acc)
|
||||
});
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::db;
|
||||
|
||||
use hir::PerNs;
|
||||
|
||||
use crate::completion::CompletionContext;
|
||||
|
||||
/// `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.
|
||||
|
|
@ -118,12 +118,12 @@ impl Builder {
|
|||
self.kind = Some(kind);
|
||||
self
|
||||
}
|
||||
pub(crate) fn from_resolution(
|
||||
pub(super) fn from_resolution(
|
||||
mut self,
|
||||
db: &db::RootDatabase,
|
||||
ctx: &CompletionContext,
|
||||
resolution: &hir::Resolution,
|
||||
) -> Builder {
|
||||
let resolved = resolution.def_id.and_then(|d| d.resolve(db).ok());
|
||||
let resolved = resolution.def_id.and_then(|d| d.resolve(ctx.db).ok());
|
||||
let kind = match resolved {
|
||||
PerNs {
|
||||
types: Some(hir::Def::Module(..)),
|
||||
|
|
@ -141,7 +141,7 @@ impl Builder {
|
|||
values: Some(hir::Def::Function(function)),
|
||||
..
|
||||
} => {
|
||||
if let Some(sig_info) = function.signature_info(db) {
|
||||
if let Some(sig_info) = function.signature_info(ctx.db) {
|
||||
if sig_info.params.is_empty() {
|
||||
self.snippet = Some(format!("{}()$0", self.label));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue