aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs6
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs8
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs6
-rw-r--r--crates/ra_ide_api/src/completion/completion_item.rs2
4 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index 37985b398..cb86ba9a3 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -10,7 +10,7 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) -> Ca
10 _ => return Ok(()), 10 _ => return Ok(()),
11 }; 11 };
12 let infer_result = function.infer(ctx.db)?; 12 let infer_result = function.infer(ctx.db)?;
13 let syntax_mapping = function.body_syntax_mapping(ctx.db)?; 13 let syntax_mapping = function.body_syntax_mapping(ctx.db);
14 let expr = match syntax_mapping.node_expr(receiver) { 14 let expr = match syntax_mapping.node_expr(receiver) {
15 Some(expr) => expr, 15 Some(expr) => expr,
16 None => return Ok(()), 16 None => return Ok(()),
@@ -27,9 +27,9 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
27 for receiver in receiver.autoderef(ctx.db) { 27 for receiver in receiver.autoderef(ctx.db) {
28 match receiver { 28 match receiver {
29 Ty::Adt { def_id, .. } => { 29 Ty::Adt { def_id, .. } => {
30 match def_id.resolve(ctx.db)? { 30 match def_id.resolve(ctx.db) {
31 Def::Struct(s) => { 31 Def::Struct(s) => {
32 for field in s.fields(ctx.db)? { 32 for field in s.fields(ctx.db) {
33 CompletionItem::new( 33 CompletionItem::new(
34 CompletionKind::Reference, 34 CompletionKind::Reference,
35 field.name().to_string(), 35 field.name().to_string(),
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index a25ad3f13..42468681a 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -8,13 +8,13 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
8 (Some(path), Some(module)) => (path.clone(), module), 8 (Some(path), Some(module)) => (path.clone(), module),
9 _ => return Ok(()), 9 _ => return Ok(()),
10 }; 10 };
11 let def_id = match module.resolve_path(ctx.db, &path)?.take_types() { 11 let def_id = match module.resolve_path(ctx.db, &path).take_types() {
12 Some(it) => it, 12 Some(it) => it,
13 None => return Ok(()), 13 None => return Ok(()),
14 }; 14 };
15 match def_id.resolve(ctx.db)? { 15 match def_id.resolve(ctx.db) {
16 hir::Def::Module(module) => { 16 hir::Def::Module(module) => {
17 let module_scope = module.scope(ctx.db)?; 17 let module_scope = module.scope(ctx.db);
18 for (name, res) in module_scope.entries() { 18 for (name, res) in module_scope.entries() {
19 CompletionItem::new(CompletionKind::Reference, name.to_string()) 19 CompletionItem::new(CompletionKind::Reference, name.to_string())
20 .from_resolution(ctx, res) 20 .from_resolution(ctx, res)
@@ -22,7 +22,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
22 } 22 }
23 } 23 }
24 hir::Def::Enum(e) => { 24 hir::Def::Enum(e) => {
25 e.variants(ctx.db)? 25 e.variants(ctx.db)
26 .into_iter() 26 .into_iter()
27 .for_each(|(variant_name, _variant)| { 27 .for_each(|(variant_name, _variant)| {
28 CompletionItem::new(CompletionKind::Reference, variant_name.to_string()) 28 CompletionItem::new(CompletionKind::Reference, variant_name.to_string())
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 770a0fdf2..660c7d16e 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -15,12 +15,12 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
15 None => return Ok(()), 15 None => return Ok(()),
16 }; 16 };
17 if let Some(function) = &ctx.function { 17 if let Some(function) = &ctx.function {
18 let scopes = function.scopes(ctx.db)?; 18 let scopes = function.scopes(ctx.db);
19 complete_fn(acc, &scopes, ctx.offset); 19 complete_fn(acc, &scopes, ctx.offset);
20 } 20 }
21 21
22 let module_scope = module.scope(ctx.db)?; 22 let module_scope = module.scope(ctx.db);
23 let (file_id, _) = module.definition_source(ctx.db)?; 23 let (file_id, _) = module.definition_source(ctx.db);
24 module_scope 24 module_scope
25 .entries() 25 .entries()
26 .filter(|(_name, res)| { 26 .filter(|(_name, res)| {
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
index b75d65de3..11d00f78c 100644
--- a/crates/ra_ide_api/src/completion/completion_item.rs
+++ b/crates/ra_ide_api/src/completion/completion_item.rs
@@ -144,7 +144,7 @@ impl Builder {
144 ctx: &CompletionContext, 144 ctx: &CompletionContext,
145 resolution: &hir::Resolution, 145 resolution: &hir::Resolution,
146 ) -> Builder { 146 ) -> Builder {
147 let resolved = resolution.def_id.and_then(|d| d.resolve(ctx.db).ok()); 147 let resolved = resolution.def_id.map(|d| d.resolve(ctx.db));
148 let kind = match resolved { 148 let kind = match resolved {
149 PerNs { 149 PerNs {
150 types: Some(hir::Def::Module(..)), 150 types: Some(hir::Def::Module(..)),