aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/display/navigation_target.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/display/navigation_target.rs')
-rw-r--r--crates/ide/src/display/navigation_target.rs30
1 files changed, 2 insertions, 28 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 54b33a98e..8410bf5a2 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -1,9 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use either::Either; 3use either::Either;
4use hir::{ 4use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, ModuleSource};
5 AssocItem, Documentation, FieldSource, HasAttrs, HasSource, HirFileId, InFile, ModuleSource,
6};
7use ide_db::base_db::{FileId, SourceDatabase}; 5use ide_db::base_db::{FileId, SourceDatabase};
8use ide_db::{defs::Definition, RootDatabase}; 6use ide_db::{defs::Definition, RootDatabase};
9use syntax::{ 7use syntax::{
@@ -168,7 +166,7 @@ impl ToNav for FileSymbol {
168 focus_range: self.name_range, 166 focus_range: self.name_range,
169 container_name: self.container_name.clone(), 167 container_name: self.container_name.clone(),
170 description: description_from_symbol(db, self), 168 description: description_from_symbol(db, self),
171 docs: docs_from_symbol(db, self), 169 docs: None,
172 } 170 }
173 } 171 }
174} 172}
@@ -394,30 +392,6 @@ impl ToNav for hir::LifetimeParam {
394 } 392 }
395} 393}
396 394
397pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<Documentation> {
398 let parse = db.parse(symbol.file_id);
399 let node = symbol.ptr.to_node(parse.tree().syntax());
400 let file_id = HirFileId::from(symbol.file_id);
401
402 let it = match_ast! {
403 match node {
404 ast::Fn(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
405 ast::Struct(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
406 ast::Enum(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
407 ast::Trait(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
408 ast::Module(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
409 ast::TypeAlias(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
410 ast::Const(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
411 ast::Static(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
412 ast::RecordField(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
413 ast::Variant(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
414 ast::MacroCall(it) => hir::Attrs::from_attrs_owner(db, InFile::new(file_id, &it)),
415 _ => return None,
416 }
417 };
418 it.docs()
419}
420
421/// Get a description of a symbol. 395/// Get a description of a symbol.
422/// 396///
423/// e.g. `struct Name`, `enum Name`, `fn Name` 397/// e.g. `struct Name`, `enum Name`, `fn Name`