aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/hover.rs
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-11-21 00:11:41 +0000
committerSeivan Heidari <[email protected]>2019-11-21 00:11:41 +0000
commit358a1bcd708c622836723e5201b6de77cc9ff327 (patch)
treeaeff9c96a6059fa2b02e7c87ec88753bc7993d8d /crates/ra_ide_api/src/hover.rs
parent1e2d090ab8a9bda18f148b894b7948eb05b976e6 (diff)
parent612a72fc4ea4376920f2a7da7b3c334227c1716c (diff)
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_ide_api/src/hover.rs')
-rw-r--r--crates/ra_ide_api/src/hover.rs24
1 files changed, 10 insertions, 14 deletions
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 787b714b3..9839be985 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -101,11 +101,11 @@ fn hover_text_from_name_kind(
101 return match name_kind { 101 return match name_kind {
102 Macro(it) => { 102 Macro(it) => {
103 let src = it.source(db); 103 let src = it.source(db);
104 hover_text(src.ast.doc_comment_text(), Some(macro_label(&src.ast))) 104 hover_text(src.value.doc_comment_text(), Some(macro_label(&src.value)))
105 } 105 }
106 Field(it) => { 106 Field(it) => {
107 let src = it.source(db); 107 let src = it.source(db);
108 match src.ast { 108 match src.value {
109 hir::FieldSource::Named(it) => hover_text(it.doc_comment_text(), it.short_label()), 109 hir::FieldSource::Named(it) => hover_text(it.doc_comment_text(), it.short_label()),
110 _ => None, 110 _ => None,
111 } 111 }
@@ -116,7 +116,7 @@ fn hover_text_from_name_kind(
116 hir::AssocItem::TypeAlias(it) => from_def_source(db, it), 116 hir::AssocItem::TypeAlias(it) => from_def_source(db, it),
117 }, 117 },
118 Def(it) => match it { 118 Def(it) => match it {
119 hir::ModuleDef::Module(it) => match it.definition_source(db).ast { 119 hir::ModuleDef::Module(it) => match it.definition_source(db).value {
120 hir::ModuleSource::Module(it) => { 120 hir::ModuleSource::Module(it) => {
121 hover_text(it.doc_comment_text(), it.short_label()) 121 hover_text(it.doc_comment_text(), it.short_label())
122 } 122 }
@@ -158,7 +158,7 @@ fn hover_text_from_name_kind(
158 A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel, 158 A: ast::DocCommentsOwner + ast::NameOwner + ShortLabel,
159 { 159 {
160 let src = def.source(db); 160 let src = def.source(db);
161 hover_text(src.ast.doc_comment_text(), src.ast.short_label()) 161 hover_text(src.value.doc_comment_text(), src.value.short_label())
162 } 162 }
163} 163}
164 164
@@ -170,11 +170,11 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
170 let mut res = HoverResult::new(); 170 let mut res = HoverResult::new();
171 171
172 let mut range = match_ast! { 172 let mut range = match_ast! {
173 match (token.ast.parent()) { 173 match (token.value.parent()) {
174 ast::NameRef(name_ref) => { 174 ast::NameRef(name_ref) => {
175 let mut no_fallback = false; 175 let mut no_fallback = false;
176 if let Some(name_kind) = 176 if let Some(name_kind) =
177 classify_name_ref(db, token.with_ast(&name_ref)).map(|d| d.kind) 177 classify_name_ref(db, token.with_value(&name_ref)).map(|d| d.kind)
178 { 178 {
179 res.extend(hover_text_from_name_kind(db, name_kind, &mut no_fallback)) 179 res.extend(hover_text_from_name_kind(db, name_kind, &mut no_fallback))
180 } 180 }
@@ -196,7 +196,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
196 } 196 }
197 }, 197 },
198 ast::Name(name) => { 198 ast::Name(name) => {
199 if let Some(name_kind) = classify_name(db, token.with_ast(&name)).map(|d| d.kind) { 199 if let Some(name_kind) = classify_name(db, token.with_value(&name)).map(|d| d.kind) {
200 res.extend(hover_text_from_name_kind(db, name_kind, &mut true)); 200 res.extend(hover_text_from_name_kind(db, name_kind, &mut true));
201 } 201 }
202 202
@@ -211,7 +211,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
211 }; 211 };
212 212
213 if range.is_none() { 213 if range.is_none() {
214 let node = token.ast.ancestors().find(|n| { 214 let node = token.value.ancestors().find(|n| {
215 ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some() 215 ast::Expr::cast(n.clone()).is_some() || ast::Pat::cast(n.clone()).is_some()
216 })?; 216 })?;
217 let frange = FileRange { file_id: position.file_id, range: node.text_range() }; 217 let frange = FileRange { file_id: position.file_id, range: node.text_range() };
@@ -404,9 +404,7 @@ mod tests {
404 check_hover_result( 404 check_hover_result(
405 r#" 405 r#"
406 //- /main.rs 406 //- /main.rs
407 fn main() { 407 const foo<|>: u32 = 0;
408 const foo<|>: u32 = 0;
409 }
410 "#, 408 "#,
411 &["const foo: u32"], 409 &["const foo: u32"],
412 ); 410 );
@@ -414,9 +412,7 @@ mod tests {
414 check_hover_result( 412 check_hover_result(
415 r#" 413 r#"
416 //- /main.rs 414 //- /main.rs
417 fn main() { 415 static foo<|>: u32 = 0;
418 static foo<|>: u32 = 0;
419 }
420 "#, 416 "#,
421 &["static foo: u32"], 417 &["static foo: u32"],
422 ); 418 );