mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Use the new Resolver API in completion
This commit is contained in:
parent
6b076f1931
commit
33ff7b56ff
11 changed files with 190 additions and 106 deletions
|
@ -7,13 +7,13 @@ use crate::{
|
|||
use hir::Docs;
|
||||
|
||||
pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
let (path, module) = match (&ctx.path_prefix, &ctx.module) {
|
||||
(Some(path), Some(module)) => (path.clone(), module),
|
||||
let path = match &ctx.path_prefix {
|
||||
Some(path) => path.clone(),
|
||||
_ => return,
|
||||
};
|
||||
let def_id = match module.resolve_path(ctx.db, &path).take_types() {
|
||||
Some(it) => it,
|
||||
None => return,
|
||||
let def = match ctx.resolver.resolve_path(ctx.db, &path).take_types() {
|
||||
Some(Resolution::Def { def }) => def,
|
||||
_ => return,
|
||||
};
|
||||
match def_id {
|
||||
hir::ModuleDef::Module(module) => {
|
||||
|
@ -24,7 +24,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
ctx.source_range(),
|
||||
name.to_string(),
|
||||
)
|
||||
.from_resolution(ctx, res)
|
||||
.from_resolution(ctx, &res.def.map(|def| hir::Resolution::Def { def }))
|
||||
.add_to(acc);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue