diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 3 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 32 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 12 |
3 files changed, 11 insertions, 36 deletions
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index e9ae20225..8c4d7127b 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -126,12 +126,11 @@ impl Completions { | |||
126 | } | 126 | } |
127 | 127 | ||
128 | pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) { | 128 | pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) { |
129 | let (_file_id, ast_node) = constant.source(ctx.db); | 129 | let ast_node = constant.source(ctx.db).ast; |
130 | let name = match ast_node.name() { | 130 | let name = match ast_node.name() { |
131 | Some(name) => name, | 131 | Some(name) => name, |
132 | _ => return, | 132 | _ => return, |
133 | }; | 133 | }; |
134 | let (_, ast_node) = constant.source(ctx.db); | ||
135 | let detail = const_label(&ast_node); | 134 | let detail = const_label(&ast_node); |
136 | 135 | ||
137 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) | 136 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) |
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 3333771ab..a036a3b36 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -212,24 +212,8 @@ impl NavigationTarget { | |||
212 | hir::ModuleDef::Struct(it) => NavigationTarget::from_adt_def(db, it.into()), | 212 | hir::ModuleDef::Struct(it) => NavigationTarget::from_adt_def(db, it.into()), |
213 | hir::ModuleDef::Enum(it) => NavigationTarget::from_adt_def(db, it.into()), | 213 | hir::ModuleDef::Enum(it) => NavigationTarget::from_adt_def(db, it.into()), |
214 | hir::ModuleDef::Union(it) => NavigationTarget::from_adt_def(db, it.into()), | 214 | hir::ModuleDef::Union(it) => NavigationTarget::from_adt_def(db, it.into()), |
215 | hir::ModuleDef::Const(s) => { | 215 | hir::ModuleDef::Const(it) => NavigationTarget::from_def_source(db, it), |
216 | let (file_id, node) = s.source(db); | 216 | hir::ModuleDef::Static(it) => NavigationTarget::from_def_source(db, it), |
217 | NavigationTarget::from_named( | ||
218 | file_id.original_file(db), | ||
219 | &*node, | ||
220 | node.doc_comment_text(), | ||
221 | node.short_label(), | ||
222 | ) | ||
223 | } | ||
224 | hir::ModuleDef::Static(s) => { | ||
225 | let (file_id, node) = s.source(db); | ||
226 | NavigationTarget::from_named( | ||
227 | file_id.original_file(db), | ||
228 | &*node, | ||
229 | node.doc_comment_text(), | ||
230 | node.short_label(), | ||
231 | ) | ||
232 | } | ||
233 | hir::ModuleDef::EnumVariant(var) => { | 217 | hir::ModuleDef::EnumVariant(var) => { |
234 | let src = var.source(db); | 218 | let src = var.source(db); |
235 | NavigationTarget::from_named( | 219 | NavigationTarget::from_named( |
@@ -281,16 +265,8 @@ impl NavigationTarget { | |||
281 | 265 | ||
282 | pub(crate) fn from_impl_item(db: &RootDatabase, impl_item: hir::ImplItem) -> NavigationTarget { | 266 | pub(crate) fn from_impl_item(db: &RootDatabase, impl_item: hir::ImplItem) -> NavigationTarget { |
283 | match impl_item { | 267 | match impl_item { |
284 | ImplItem::Method(f) => NavigationTarget::from_function(db, f), | 268 | ImplItem::Method(it) => NavigationTarget::from_function(db, it), |
285 | ImplItem::Const(c) => { | 269 | ImplItem::Const(it) => NavigationTarget::from_def_source(db, it), |
286 | let (file_id, node) = c.source(db); | ||
287 | NavigationTarget::from_named( | ||
288 | file_id.original_file(db), | ||
289 | &*node, | ||
290 | node.doc_comment_text(), | ||
291 | node.short_label(), | ||
292 | ) | ||
293 | } | ||
294 | ImplItem::TypeAlias(a) => { | 270 | ImplItem::TypeAlias(a) => { |
295 | let (file_id, node) = a.source(db); | 271 | let (file_id, node) = a.source(db); |
296 | NavigationTarget::from_named( | 272 | NavigationTarget::from_named( |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 4dd3c1b9f..fe108a589 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -115,8 +115,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
115 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) | 115 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) |
116 | } | 116 | } |
117 | hir::ImplItem::Const(it) => { | 117 | hir::ImplItem::Const(it) => { |
118 | let it = it.source(db).1; | 118 | let src = it.source(db); |
119 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 119 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) |
120 | } | 120 | } |
121 | hir::ImplItem::TypeAlias(it) => { | 121 | hir::ImplItem::TypeAlias(it) => { |
122 | let it = it.source(db).1; | 122 | let it = it.source(db).1; |
@@ -152,12 +152,12 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
152 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) | 152 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) |
153 | } | 153 | } |
154 | hir::ModuleDef::Const(it) => { | 154 | hir::ModuleDef::Const(it) => { |
155 | let it = it.source(db).1; | 155 | let src = it.source(db); |
156 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 156 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) |
157 | } | 157 | } |
158 | hir::ModuleDef::Static(it) => { | 158 | hir::ModuleDef::Static(it) => { |
159 | let it = it.source(db).1; | 159 | let src = it.source(db); |
160 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 160 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) |
161 | } | 161 | } |
162 | hir::ModuleDef::Trait(it) => { | 162 | hir::ModuleDef::Trait(it) => { |
163 | let it = it.source(db).1; | 163 | let it = it.source(db).1; |