diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 50 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 15 |
2 files changed, 22 insertions, 43 deletions
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index c02bc005b..7c68bb41c 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -207,12 +207,12 @@ impl NavigationTarget { | |||
207 | ) | 207 | ) |
208 | } | 208 | } |
209 | hir::AdtDef::Enum(s) => { | 209 | hir::AdtDef::Enum(s) => { |
210 | let (file_id, node) = s.source(db); | 210 | let src = s.source(db); |
211 | NavigationTarget::from_named( | 211 | NavigationTarget::from_named( |
212 | file_id.original_file(db), | 212 | src.file_id.original_file(db), |
213 | &*node, | 213 | &*src.ast, |
214 | node.doc_comment_text(), | 214 | src.ast.doc_comment_text(), |
215 | node.short_label(), | 215 | src.ast.short_label(), |
216 | ) | 216 | ) |
217 | } | 217 | } |
218 | } | 218 | } |
@@ -225,24 +225,9 @@ impl NavigationTarget { | |||
225 | let nav = match module_def { | 225 | let nav = match module_def { |
226 | hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module), | 226 | hir::ModuleDef::Module(module) => NavigationTarget::from_module(db, module), |
227 | hir::ModuleDef::Function(func) => NavigationTarget::from_function(db, func), | 227 | hir::ModuleDef::Function(func) => NavigationTarget::from_function(db, func), |
228 | hir::ModuleDef::Struct(s) => { | 228 | hir::ModuleDef::Struct(it) => NavigationTarget::from_adt_def(db, it.into()), |
229 | let src = s.source(db); | 229 | hir::ModuleDef::Enum(it) => NavigationTarget::from_adt_def(db, it.into()), |
230 | NavigationTarget::from_named( | 230 | hir::ModuleDef::Union(it) => NavigationTarget::from_adt_def(db, it.into()), |
231 | src.file_id.original_file(db), | ||
232 | &*src.ast, | ||
233 | src.ast.doc_comment_text(), | ||
234 | src.ast.short_label(), | ||
235 | ) | ||
236 | } | ||
237 | hir::ModuleDef::Union(s) => { | ||
238 | let (file_id, node) = s.source(db); | ||
239 | NavigationTarget::from_named( | ||
240 | file_id.original_file(db), | ||
241 | &*node, | ||
242 | node.doc_comment_text(), | ||
243 | node.short_label(), | ||
244 | ) | ||
245 | } | ||
246 | hir::ModuleDef::Const(s) => { | 231 | hir::ModuleDef::Const(s) => { |
247 | let (file_id, node) = s.source(db); | 232 | let (file_id, node) = s.source(db); |
248 | NavigationTarget::from_named( | 233 | NavigationTarget::from_named( |
@@ -261,22 +246,13 @@ impl NavigationTarget { | |||
261 | node.short_label(), | 246 | node.short_label(), |
262 | ) | 247 | ) |
263 | } | 248 | } |
264 | hir::ModuleDef::Enum(e) => { | ||
265 | let (file_id, node) = e.source(db); | ||
266 | NavigationTarget::from_named( | ||
267 | file_id.original_file(db), | ||
268 | &*node, | ||
269 | node.doc_comment_text(), | ||
270 | node.short_label(), | ||
271 | ) | ||
272 | } | ||
273 | hir::ModuleDef::EnumVariant(var) => { | 249 | hir::ModuleDef::EnumVariant(var) => { |
274 | let (file_id, node) = var.source(db); | 250 | let src = var.source(db); |
275 | NavigationTarget::from_named( | 251 | NavigationTarget::from_named( |
276 | file_id.original_file(db), | 252 | src.file_id.original_file(db), |
277 | &*node, | 253 | &*src.ast, |
278 | node.doc_comment_text(), | 254 | src.ast.doc_comment_text(), |
279 | node.short_label(), | 255 | src.ast.short_label(), |
280 | ) | 256 | ) |
281 | } | 257 | } |
282 | hir::ModuleDef::Trait(e) => { | 258 | hir::ModuleDef::Trait(e) => { |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 80445761c..ee0f2dde8 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -144,12 +144,12 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
144 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 144 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) |
145 | } | 145 | } |
146 | hir::ModuleDef::Enum(it) => { | 146 | hir::ModuleDef::Enum(it) => { |
147 | let it = it.source(db).1; | 147 | let src = it.source(db); |
148 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 148 | res.extend(hover_text(src.ast.doc_comment_text(), src.ast.short_label())) |
149 | } | 149 | } |
150 | hir::ModuleDef::EnumVariant(it) => { | 150 | hir::ModuleDef::EnumVariant(it) => { |
151 | let it = it.source(db).1; | 151 | let src = it.source(db); |
152 | res.extend(hover_text(it.doc_comment_text(), it.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 it = it.source(db).1; |
@@ -187,8 +187,11 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
187 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 187 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) |
188 | } | 188 | } |
189 | hir::AdtDef::Enum(it) => { | 189 | hir::AdtDef::Enum(it) => { |
190 | let it = it.source(db).1; | 190 | let src = it.source(db); |
191 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 191 | res.extend(hover_text( |
192 | src.ast.doc_comment_text(), | ||
193 | src.ast.short_label(), | ||
194 | )) | ||
192 | } | 195 | } |
193 | } | 196 | } |
194 | } | 197 | } |