aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/goto_definition.rs5
-rw-r--r--crates/ra_ide/src/hover.rs4
-rw-r--r--crates/ra_ide/src/references.rs4
3 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index b44b6fe22..45389fd23 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -40,7 +40,7 @@ pub(crate) fn goto_definition(
40 reference_definition(&sema, &name_ref).to_vec() 40 reference_definition(&sema, &name_ref).to_vec()
41 }, 41 },
42 ast::Name(name) => { 42 ast::Name(name) => {
43 let def = classify_name(&sema, &name)?.definition(sema.db)?; 43 let def = classify_name(&sema, &name)?.definition(sema.db);
44 let nav = def.try_to_nav(sema.db)?; 44 let nav = def.try_to_nav(sema.db)?;
45 vec![nav] 45 vec![nav]
46 }, 46 },
@@ -82,7 +82,8 @@ pub(crate) fn reference_definition(
82 name_ref: &ast::NameRef, 82 name_ref: &ast::NameRef,
83) -> ReferenceResult { 83) -> ReferenceResult {
84 let name_kind = classify_name_ref(sema, name_ref); 84 let name_kind = classify_name_ref(sema, name_ref);
85 if let Some(def) = name_kind.and_then(|def| def.definition(sema.db)) { 85 if let Some(def) = name_kind {
86 let def = def.definition(sema.db);
86 return match def.try_to_nav(sema.db) { 87 return match def.try_to_nav(sema.db) {
87 Some(nav) => ReferenceResult::Exact(nav), 88 Some(nav) => ReferenceResult::Exact(nav),
88 None => ReferenceResult::Approximate(Vec::new()), 89 None => ReferenceResult::Approximate(Vec::new()),
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index a632ea6a2..f6e493817 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -85,8 +85,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
85 let node = token.parent(); 85 let node = token.parent();
86 let definition = match_ast! { 86 let definition = match_ast! {
87 match node { 87 match node {
88 ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).and_then(|d| d.definition(sema.db)), 88 ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)),
89 ast::Name(name) => classify_name(&sema, &name).and_then(|d| d.definition(sema.db)), 89 ast::Name(name) => classify_name(&sema, &name).map(|d| d.definition(sema.db)),
90 _ => None, 90 _ => None,
91 } 91 }
92 }; 92 };
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index 9dd228b9c..453985de3 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -130,13 +130,13 @@ fn find_name(
130 opt_name: Option<ast::Name>, 130 opt_name: Option<ast::Name>,
131) -> Option<RangeInfo<Definition>> { 131) -> Option<RangeInfo<Definition>> {
132 if let Some(name) = opt_name { 132 if let Some(name) = opt_name {
133 let def = classify_name(sema, &name)?.definition(sema.db)?; 133 let def = classify_name(sema, &name)?.definition(sema.db);
134 let range = name.syntax().text_range(); 134 let range = name.syntax().text_range();
135 return Some(RangeInfo::new(range, def)); 135 return Some(RangeInfo::new(range, def));
136 } 136 }
137 let name_ref = 137 let name_ref =
138 sema.find_node_at_offset_with_descend::<ast::NameRef>(&syntax, position.offset)?; 138 sema.find_node_at_offset_with_descend::<ast::NameRef>(&syntax, position.offset)?;
139 let def = classify_name_ref(sema, &name_ref)?.definition(sema.db)?; 139 let def = classify_name_ref(sema, &name_ref)?.definition(sema.db);
140 let range = name_ref.syntax().text_range(); 140 let range = name_ref.syntax().text_range();
141 Some(RangeInfo::new(range, def)) 141 Some(RangeInfo::new(range, def))
142} 142}