aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/hover.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/hover.rs')
-rw-r--r--crates/ra_ide_api/src/hover.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 07d511fb3..cc25f4c37 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{Adt, HasSource, HirDisplay}; 3use hir::{Adt, HasSource, HirDisplay, Source};
4use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
5use ra_syntax::{ 5use ra_syntax::{
6 algo::{ancestors_at_offset, find_covering_element, find_node_at_offset}, 6 algo::{ancestors_at_offset, find_covering_element, find_node_at_offset},
@@ -171,7 +171,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
171 find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) 171 find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset)
172 { 172 {
173 let mut no_fallback = false; 173 let mut no_fallback = false;
174 if let Some(name_kind) = classify_name_ref(db, position.file_id, &name_ref).map(|d| d.kind) 174 if let Some(name_kind) =
175 classify_name_ref(db, Source::new(position.file_id.into(), &name_ref)).map(|d| d.kind)
175 { 176 {
176 res.extend(hover_text_from_name_kind(db, name_kind, &mut no_fallback)) 177 res.extend(hover_text_from_name_kind(db, name_kind, &mut no_fallback))
177 } 178 }
@@ -230,7 +231,8 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
230 .ancestors() 231 .ancestors()
231 .take_while(|it| it.text_range() == leaf_node.text_range()) 232 .take_while(|it| it.text_range() == leaf_node.text_range())
232 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?; 233 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?;
233 let analyzer = hir::SourceAnalyzer::new(db, frange.file_id, &node, None); 234 let analyzer =
235 hir::SourceAnalyzer::new(db, hir::Source::new(frange.file_id.into(), &node), None);
234 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) 236 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e))
235 { 237 {
236 ty 238 ty