aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r--crates/ra_analysis/src/lib.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index 1e26a2889..b068119d2 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -21,6 +21,7 @@ mod runnables;
21 21
22mod extend_selection; 22mod extend_selection;
23mod syntax_highlighting; 23mod syntax_highlighting;
24mod hover;
24 25
25use std::{fmt, sync::Arc}; 26use std::{fmt, sync::Arc};
26 27
@@ -260,6 +261,18 @@ impl NavigationTarget {
260 } 261 }
261} 262}
262 263
264#[derive(Debug)]
265pub struct RangeInfo<T> {
266 pub range: TextRange,
267 pub info: T,
268}
269
270impl<T> RangeInfo<T> {
271 fn new(range: TextRange, info: T) -> RangeInfo<T> {
272 RangeInfo { range, info }
273 }
274}
275
263/// Result of "goto def" query. 276/// Result of "goto def" query.
264#[derive(Debug)] 277#[derive(Debug)]
265pub struct ReferenceResolution { 278pub struct ReferenceResolution {
@@ -390,9 +403,9 @@ impl Analysis {
390 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { 403 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> {
391 self.db.find_all_refs(position) 404 self.db.find_all_refs(position)
392 } 405 }
393 /// Returns documentation string for a given target. 406 /// Returns a short text descrbing element at position.
394 pub fn doc_text_for(&self, nav: NavigationTarget) -> Cancelable<Option<String>> { 407 pub fn hover(&self, position: FilePosition) -> Cancelable<Option<RangeInfo<String>>> {
395 self.db.doc_text_for(nav) 408 hover::hover(&*self.db, position)
396 } 409 }
397 /// Returns a `mod name;` declaration which created the current module. 410 /// Returns a `mod name;` declaration which created the current module.
398 pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> { 411 pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> {
@@ -437,7 +450,7 @@ impl Analysis {
437 } 450 }
438 /// Computes the type of the expression at the given position. 451 /// Computes the type of the expression at the given position.
439 pub fn type_of(&self, frange: FileRange) -> Cancelable<Option<String>> { 452 pub fn type_of(&self, frange: FileRange) -> Cancelable<Option<String>> {
440 self.db.type_of(frange) 453 hover::type_of(&*self.db, frange)
441 } 454 }
442 /// Returns the edit required to rename reference at the position to the new 455 /// Returns the edit required to rename reference at the position to the new
443 /// name. 456 /// name.