From e85ee60c42db57368e24ad9ac24840c2494d383c Mon Sep 17 00:00:00 2001 From: Marco Groppo Date: Mon, 15 Apr 2019 00:03:54 +0200 Subject: Initial support for lang items. --- crates/ra_ide_api/src/completion/complete_path.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'crates/ra_ide_api/src/completion/complete_path.rs') diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index bc03a7095..c49147b9e 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -38,18 +38,21 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { } hir::ModuleDef::Struct(s) => { let ty = s.ty(ctx.db); - ty.iterate_impl_items(ctx.db, |item| { - match item { - hir::ImplItem::Method(func) => { - let sig = func.signature(ctx.db); - if !sig.has_self_param() { - acc.add_function(ctx, func); + let krate = ctx.module.and_then(|m| m.krate(ctx.db)); + krate.map_or((), |krate| { + ty.iterate_impl_items(ctx.db, krate, |item| { + match item { + hir::ImplItem::Method(func) => { + let sig = func.signature(ctx.db); + if !sig.has_self_param() { + acc.add_function(ctx, func); + } } + hir::ImplItem::Const(ct) => acc.add_const(ctx, ct), + hir::ImplItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty), } - hir::ImplItem::Const(ct) => acc.add_const(ctx, ct), - hir::ImplItem::TypeAlias(ty) => acc.add_type_alias(ctx, ty), - } - None::<()> + None::<()> + }); }); } _ => return, -- cgit v1.2.3 From 8ebb20edce85b74eab0ed78ba5c4969ec733ad12 Mon Sep 17 00:00:00 2001 From: Marco Groppo Date: Wed, 17 Apr 2019 23:40:00 +0200 Subject: New krate() method in Resolver. Renamed Impl to ImplBlock. --- crates/ra_ide_api/src/completion/complete_path.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide_api/src/completion/complete_path.rs') diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index c49147b9e..c41752ae7 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -39,7 +39,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { hir::ModuleDef::Struct(s) => { let ty = s.ty(ctx.db); let krate = ctx.module.and_then(|m| m.krate(ctx.db)); - krate.map_or((), |krate| { + if let Some(krate) = krate { ty.iterate_impl_items(ctx.db, krate, |item| { match item { hir::ImplItem::Method(func) => { @@ -53,7 +53,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { } None::<()> }); - }); + } } _ => return, }; -- cgit v1.2.3