Move display related things from hover to display
This commit is contained in:
@@ -5,6 +5,7 @@ mod function_signature;
|
||||
mod navigation_target;
|
||||
mod structure;
|
||||
|
||||
use crate::db::RootDatabase;
|
||||
use ra_syntax::{ast::{self, AstNode, TypeParamsOwner}, SyntaxKind::{ATTR, COMMENT}};
|
||||
|
||||
pub use navigation_target::NavigationTarget;
|
||||
@@ -53,3 +54,29 @@ pub(crate) fn where_predicates<N: TypeParamsOwner>(node: &N) -> Vec<String> {
|
||||
}
|
||||
res
|
||||
}
|
||||
|
||||
pub(crate) fn rust_code_markup<CODE: AsRef<str>>(val: CODE) -> String {
|
||||
rust_code_markup_with_doc::<_, &str>(val, None)
|
||||
}
|
||||
|
||||
pub(crate) fn rust_code_markup_with_doc<CODE, DOC>(val: CODE, doc: Option<DOC>) -> String
|
||||
where
|
||||
CODE: AsRef<str>,
|
||||
DOC: AsRef<str>,
|
||||
{
|
||||
if let Some(doc) = doc {
|
||||
format!("```rust\n{}\n```\n\n{}", val.as_ref(), doc.as_ref())
|
||||
} else {
|
||||
format!("```rust\n{}\n```", val.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: this should not really use navigation target. Rather, approximately
|
||||
// resolved symbol should return a `DefId`.
|
||||
pub(crate) fn doc_text_for(db: &RootDatabase, nav: NavigationTarget) -> Option<String> {
|
||||
match (nav.description(db), nav.docs(db)) {
|
||||
(Some(desc), docs) => Some(rust_code_markup_with_doc(desc, docs)),
|
||||
(None, Some(docs)) => Some(docs),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user