Add a better text for hover and stop duplicating work done in approximatelly_resolve_symbol

This commit is contained in:
DJMcNab 2018-12-08 16:02:23 +00:00 committed by Aleksey Kladov
parent 6d548d944f
commit f88e0700e6
7 changed files with 98 additions and 30 deletions

View file

@ -323,6 +323,17 @@ impl AnalysisImpl {
Ok(symbol.docs(&file))
}
pub fn doc_text_for(&self, file_id: FileId, symbol: FileSymbol) -> Cancelable<Option<String>> {
let file = self.db.source_file(file_id);
let result = match (symbol.description(&file), symbol.docs(&file)) {
(Some(desc), Some(docs)) => Some("```rust\n".to_string() + &*desc + "\n```\n\n" + &*docs),
(Some(desc), None) => Some("```rust\n".to_string() + &*desc + "\n```"),
(None, Some(docs)) => Some(docs),
_ => None,
};
Ok(result)
}
pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> {
let syntax = self.db.source_file(file_id);