aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs4
-rw-r--r--crates/ra_ide_api/src/completion/completion_item.rs28
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs6
3 files changed, 17 insertions, 21 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 5b89c64ad..8e0f6a79e 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -12,7 +12,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
12 _ => return, 12 _ => return,
13 }; 13 };
14 let def = match ctx.resolver.resolve_path(ctx.db, &path).take_types() { 14 let def = match ctx.resolver.resolve_path(ctx.db, &path).take_types() {
15 Some(Resolution::Def { def }) => def, 15 Some(Resolution::Def(def)) => def,
16 _ => return, 16 _ => return,
17 }; 17 };
18 match def { 18 match def {
@@ -24,7 +24,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
24 ctx.source_range(), 24 ctx.source_range(),
25 name.to_string(), 25 name.to_string(),
26 ) 26 )
27 .from_resolution(ctx, &res.def.map(|def| hir::Resolution::Def { def })) 27 .from_resolution(ctx, &res.def.map(hir::Resolution::Def))
28 .add_to(acc); 28 .add_to(acc);
29 } 29 }
30 } 30 }
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
index 4101ce88a..bada6a33b 100644
--- a/crates/ra_ide_api/src/completion/completion_item.rs
+++ b/crates/ra_ide_api/src/completion/completion_item.rs
@@ -223,22 +223,18 @@ impl Builder {
223 Some(it) => it, 223 Some(it) => it,
224 }; 224 };
225 let (kind, docs) = match def { 225 let (kind, docs) = match def {
226 Resolution::Def { def: Module(it) } => (CompletionItemKind::Module, it.docs(ctx.db)), 226 Resolution::Def(Module(it)) => (CompletionItemKind::Module, it.docs(ctx.db)),
227 Resolution::Def { 227 Resolution::Def(Function(func)) => return self.from_function(ctx, *func),
228 def: Function(func), 228 Resolution::Def(Struct(it)) => (CompletionItemKind::Struct, it.docs(ctx.db)),
229 } => return self.from_function(ctx, *func), 229 Resolution::Def(Enum(it)) => (CompletionItemKind::Enum, it.docs(ctx.db)),
230 Resolution::Def { def: Struct(it) } => (CompletionItemKind::Struct, it.docs(ctx.db)), 230 Resolution::Def(EnumVariant(it)) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)),
231 Resolution::Def { def: Enum(it) } => (CompletionItemKind::Enum, it.docs(ctx.db)), 231 Resolution::Def(Const(it)) => (CompletionItemKind::Const, it.docs(ctx.db)),
232 Resolution::Def { 232 Resolution::Def(Static(it)) => (CompletionItemKind::Static, it.docs(ctx.db)),
233 def: EnumVariant(it), 233 Resolution::Def(Trait(it)) => (CompletionItemKind::Trait, it.docs(ctx.db)),
234 } => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), 234 Resolution::Def(Type(it)) => (CompletionItemKind::TypeAlias, it.docs(ctx.db)),
235 Resolution::Def { def: Const(it) } => (CompletionItemKind::Const, it.docs(ctx.db)), 235 Resolution::GenericParam(..) => (CompletionItemKind::TypeParam, None),
236 Resolution::Def { def: Static(it) } => (CompletionItemKind::Static, it.docs(ctx.db)), 236 Resolution::LocalBinding(..) => (CompletionItemKind::Binding, None),
237 Resolution::Def { def: Trait(it) } => (CompletionItemKind::Trait, it.docs(ctx.db)), 237 Resolution::SelfType(..) => (
238 Resolution::Def { def: Type(it) } => (CompletionItemKind::TypeAlias, it.docs(ctx.db)),
239 Resolution::GenericParam { .. } => (CompletionItemKind::TypeParam, None),
240 Resolution::LocalBinding { .. } => (CompletionItemKind::Binding, None),
241 Resolution::SelfType { .. } => (
242 CompletionItemKind::TypeParam, // (does this need its own kind?) 238 CompletionItemKind::TypeParam, // (does this need its own kind?)
243 None, 239 None,
244 ), 240 ),
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 48080b6e1..88efcea2a 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -90,8 +90,8 @@ pub(crate) fn reference_definition(
90 { 90 {
91 let resolved = resolver.resolve_path(db, &path); 91 let resolved = resolver.resolve_path(db, &path);
92 match resolved.clone().take_types().or(resolved.take_values()) { 92 match resolved.clone().take_types().or(resolved.take_values()) {
93 Some(Resolution::Def { def }) => return Exact(NavigationTarget::from_def(db, def)), 93 Some(Resolution::Def(def)) => return Exact(NavigationTarget::from_def(db, def)),
94 Some(Resolution::LocalBinding { pat }) => { 94 Some(Resolution::LocalBinding(pat)) => {
95 let body = resolver.body().expect("no body for local binding"); 95 let body = resolver.body().expect("no body for local binding");
96 let syntax_mapping = body.syntax_mapping(db); 96 let syntax_mapping = body.syntax_mapping(db);
97 let ptr = syntax_mapping 97 let ptr = syntax_mapping
@@ -104,7 +104,7 @@ pub(crate) fn reference_definition(
104 let nav = NavigationTarget::from_scope_entry(file_id, name, ptr); 104 let nav = NavigationTarget::from_scope_entry(file_id, name, ptr);
105 return Exact(nav); 105 return Exact(nav);
106 } 106 }
107 Some(Resolution::GenericParam { .. }) => { 107 Some(Resolution::GenericParam(..)) => {
108 // TODO go to the generic param def 108 // TODO go to the generic param def
109 } 109 }
110 Some(Resolution::SelfType(_impl_block)) => { 110 Some(Resolution::SelfType(_impl_block)) => {