move hover implementation to ra_analysis

This commit is contained in:
Aleksey Kladov 2019-01-05 17:22:41 +03:00
parent 2560a9e807
commit 3ad0037f90
4 changed files with 83 additions and 67 deletions

View file

@ -21,6 +21,7 @@ mod runnables;
mod extend_selection;
mod syntax_highlighting;
mod hover;
use std::{fmt, sync::Arc};
@ -260,6 +261,18 @@ impl NavigationTarget {
}
}
#[derive(Debug)]
pub struct RangeInfo<T> {
pub range: TextRange,
pub info: T,
}
impl<T> RangeInfo<T> {
fn new(range: TextRange, info: T) -> RangeInfo<T> {
RangeInfo { range, info }
}
}
/// Result of "goto def" query.
#[derive(Debug)]
pub struct ReferenceResolution {
@ -394,6 +407,10 @@ impl Analysis {
pub fn doc_text_for(&self, nav: NavigationTarget) -> Cancelable<Option<String>> {
self.db.doc_text_for(nav)
}
/// Returns a short text descrbing element at position.
pub fn hover(&self, position: FilePosition) -> Cancelable<Option<RangeInfo<String>>> {
hover::hover(&*self.db, position)
}
/// Returns a `mod name;` declaration which created the current module.
pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> {
self.db.parent_module(position)