Change docs and description to getter method

This commit is contained in:
Edwin Cheng 2019-06-10 00:03:38 +08:00
parent aacc894134
commit e9848b2e6c
2 changed files with 11 additions and 4 deletions

View file

@ -76,7 +76,7 @@ where
// FIXME: this should not really use navigation target. Rather, approximately // FIXME: this should not really use navigation target. Rather, approximately
// resolved symbol should return a `DefId`. // resolved symbol should return a `DefId`.
pub(crate) fn doc_text_for(nav: NavigationTarget) -> Option<String> { pub(crate) fn doc_text_for(nav: NavigationTarget) -> Option<String> {
match (nav.description, nav.docs) { match (nav.description(), nav.docs()) {
(Some(desc), docs) => Some(rust_code_markup_with_doc(desc, docs)), (Some(desc), docs) => Some(rust_code_markup_with_doc(desc, docs)),
(None, Some(docs)) => Some(docs), (None, Some(docs)) => Some(docs),
_ => None, _ => None,

View file

@ -23,9 +23,8 @@ pub struct NavigationTarget {
full_range: TextRange, full_range: TextRange,
focus_range: Option<TextRange>, focus_range: Option<TextRange>,
container_name: Option<SmolStr>, container_name: Option<SmolStr>,
description: Option<String>,
pub(crate) description: Option<String>, docs: Option<String>,
pub(crate) docs: Option<String>,
} }
impl NavigationTarget { impl NavigationTarget {
@ -55,6 +54,14 @@ impl NavigationTarget {
self.full_range self.full_range
} }
pub fn docs(&self) -> Option<String> {
self.docs.clone()
}
pub fn description(&self) -> Option<String> {
self.description.clone()
}
/// A "most interesting" range withing the `full_range`. /// A "most interesting" range withing the `full_range`.
/// ///
/// Typically, `full_range` is the whole syntax node, /// Typically, `full_range` is the whole syntax node,