From f88e0700e6c4a9b195739154f8683704762df1bd Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Sat, 8 Dec 2018 16:02:23 +0000 Subject: Add a better text for hover and stop duplicating work done in approximatelly_resolve_symbol --- crates/ra_analysis/src/imp.rs | 11 +++++++++++ crates/ra_analysis/src/lib.rs | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/ra_analysis/src') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index e9af98474..07357fc84 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -323,6 +323,17 @@ impl AnalysisImpl { Ok(symbol.docs(&file)) } + pub fn doc_text_for(&self, file_id: FileId, symbol: FileSymbol) -> Cancelable> { + 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> { let syntax = self.db.source_file(file_id); diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 4b8b10816..d33f3e4ca 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -236,7 +236,7 @@ impl Analysis { pub fn approximately_resolve_symbol( &self, position: FilePosition, - ) -> Cancelable> { + ) -> Cancelable)>> { self.imp.approximately_resolve_symbol(position) } pub fn find_all_refs(&self, position: FilePosition) -> Cancelable> { @@ -249,6 +249,9 @@ impl Analysis { ) -> Cancelable> { self.imp.doc_comment_for(file_id, symbol) } + pub fn doc_text_for(&self, file_id: FileId, symbol: FileSymbol) -> Cancelable> { + self.imp.doc_text_for(file_id, symbol) + } pub fn parent_module(&self, position: FilePosition) -> Cancelable> { self.imp.parent_module(position) } -- cgit v1.2.3