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.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index e503bf6a9..2a5ac7821 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -172,7 +172,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
172 } 172 }
173 173
174 if !res.is_empty() { 174 if !res.is_empty() {
175 range = Some(name_ref.syntax().range()) 175 range = Some(name_ref.syntax().text_range())
176 } 176 }
177 } else if let Some(name) = find_node_at_offset::<ast::Name>(file.syntax(), position.offset) { 177 } else if let Some(name) = find_node_at_offset::<ast::Name>(file.syntax(), position.offset) {
178 if let Some(parent) = name.syntax().parent() { 178 if let Some(parent) = name.syntax().parent() {
@@ -210,7 +210,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
210 } 210 }
211 211
212 if !res.is_empty() && range.is_none() { 212 if !res.is_empty() && range.is_none() {
213 range = Some(name.syntax().range()); 213 range = Some(name.syntax().text_range());
214 } 214 }
215 } 215 }
216 216
@@ -218,9 +218,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
218 let node = ancestors_at_offset(file.syntax(), position.offset).find(|n| { 218 let node = ancestors_at_offset(file.syntax(), position.offset).find(|n| {
219 ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some() 219 ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some()
220 })?; 220 })?;
221 let frange = FileRange { file_id: position.file_id, range: node.range() }; 221 let frange = FileRange { file_id: position.file_id, range: node.text_range() };
222 res.extend(type_of(db, frange).map(rust_code_markup)); 222 res.extend(type_of(db, frange).map(rust_code_markup));
223 range = Some(node.range()); 223 range = Some(node.text_range());
224 } 224 }
225 225
226 let range = range?; 226 let range = range?;
@@ -246,7 +246,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
246 // if we picked identifier, expand to pattern/expression 246 // if we picked identifier, expand to pattern/expression
247 let node = leaf_node 247 let node = leaf_node
248 .ancestors() 248 .ancestors()
249 .take_while(|it| it.range() == leaf_node.range()) 249 .take_while(|it| it.text_range() == leaf_node.text_range())
250 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?; 250 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?;
251 let analyzer = hir::SourceAnalyzer::new(db, frange.file_id, &node, None); 251 let analyzer = hir::SourceAnalyzer::new(db, frange.file_id, &node, None);
252 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) 252 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e))