aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r--crates/ra_analysis/src/imp.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index eae73c2c4..10248013c 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -269,6 +269,32 @@ impl db::RootDatabase {
269 Ok(result) 269 Ok(result)
270 } 270 }
271 271
272 pub(crate) fn hover(&self, position: FilePosition) -> Cancelable<Option<(TextRange, String)>> {
273 let mut res = Vec::new();
274 let range = if let Some(rr) = self.approximately_resolve_symbol(position)? {
275 for nav in rr.resolves_to {
276 res.extend(self.doc_text_for(nav)?)
277 }
278 rr.reference_range
279 } else {
280 let file = self.source_file(position.file_id);
281 let expr: ast::Expr = ctry!(ra_editor::find_node_at_offset(
282 file.syntax(),
283 position.offset
284 ));
285 let frange = FileRange {
286 file_id: position.file_id,
287 range: expr.syntax().range(),
288 };
289 res.extend(self.type_of(frange)?);
290 expr.syntax().range()
291 };
292 if res.is_empty() {
293 return Ok(None);
294 }
295 Ok(Some((range, res.join("\n\n---\n"))))
296 }
297
272 pub(crate) fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { 298 pub(crate) fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> {
273 let syntax = self.source_file(file_id); 299 let syntax = self.source_file(file_id);
274 300