diff options
author | Aleksey Kladov <[email protected]> | 2019-01-05 13:40:50 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-05 13:40:50 +0000 |
commit | 2560a9e8076d0b83f606af3029ea1a0c7bc48514 (patch) | |
tree | d6cb71632cefcd710fafdeb655904ab80022f47a /crates | |
parent | 8d51b02362109d71355aed63d48b5e7ccd0e51f4 (diff) |
wip
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 26 |
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 | ||