aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-10-15 15:15:01 +0100
committerAleksey Kladov <[email protected]>2020-10-15 16:37:36 +0100
commitfa3c449d8f5a67865cab8d4717b3e32dca5b672a (patch)
tree8143b3ee53bbd2b36768fbe085b4ddc6b7b70514
parent7fadc78ebb43b0eb9b6ccf314e29bdd23717542f (diff)
Clarify NameClass names a bit
-rw-r--r--crates/ide/src/doc_links.rs2
-rw-r--r--crates/ide/src/goto_definition.rs2
-rw-r--r--crates/ide/src/hover.rs2
-rw-r--r--crates/ide/src/references.rs2
-rw-r--r--crates/ide_db/src/defs.rs4
-rw-r--r--crates/ide_db/src/imports_locator.rs2
6 files changed, 7 insertions, 7 deletions
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs
index db3f911c8..71382f13e 100644
--- a/crates/ide/src/doc_links.rs
+++ b/crates/ide/src/doc_links.rs
@@ -233,7 +233,7 @@ pub(crate) fn external_docs(
233 let definition = match_ast! { 233 let definition = match_ast! {
234 match node { 234 match node {
235 ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)), 235 ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)),
236 ast::Name(name) => classify_name(&sema, &name).map(|d| d.definition(sema.db)), 236 ast::Name(name) => classify_name(&sema, &name).map(|d| d.definition_or_reference(sema.db)),
237 _ => None, 237 _ => None,
238 } 238 }
239 }; 239 };
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index 582bf4837..79fdb75ed 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/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_or_reference(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 },
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 632eaf0a0..51f03c718 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -108,7 +108,7 @@ pub(crate) fn hover(
108 let definition = match_ast! { 108 let definition = match_ast! {
109 match node { 109 match node {
110 ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)), 110 ast::NameRef(name_ref) => classify_name_ref(&sema, &name_ref).map(|d| d.definition(sema.db)),
111 ast::Name(name) => classify_name(&sema, &name).and_then(|d| d.into_definition(sema.db)), 111 ast::Name(name) => classify_name(&sema, &name).and_then(|d| d.definition(sema.db)),
112 _ => None, 112 _ => None,
113 } 113 }
114 }; 114 };
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index 88e2f2db3..ec64207d2 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -132,7 +132,7 @@ fn find_name(
132 opt_name: Option<ast::Name>, 132 opt_name: Option<ast::Name>,
133) -> Option<RangeInfo<Definition>> { 133) -> Option<RangeInfo<Definition>> {
134 if let Some(name) = opt_name { 134 if let Some(name) = opt_name {
135 let def = classify_name(sema, &name)?.definition(sema.db); 135 let def = classify_name(sema, &name)?.definition_or_reference(sema.db);
136 let range = name.syntax().text_range(); 136 let range = name.syntax().text_range();
137 return Some(RangeInfo::new(range, def)); 137 return Some(RangeInfo::new(range, def));
138 } 138 }
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs
index f8c7aa491..a243dcd15 100644
--- a/crates/ide_db/src/defs.rs
+++ b/crates/ide_db/src/defs.rs
@@ -90,7 +90,7 @@ pub enum NameClass {
90} 90}
91 91
92impl NameClass { 92impl NameClass {
93 pub fn into_definition(self, db: &dyn HirDatabase) -> Option<Definition> { 93 pub fn definition(self, db: &dyn HirDatabase) -> Option<Definition> {
94 Some(match self { 94 Some(match self {
95 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()), 95 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()),
96 NameClass::Definition(it) => it, 96 NameClass::Definition(it) => it,
@@ -99,7 +99,7 @@ impl NameClass {
99 }) 99 })
100 } 100 }
101 101
102 pub fn definition(self, db: &dyn HirDatabase) -> Definition { 102 pub fn definition_or_reference(self, db: &dyn HirDatabase) -> Definition {
103 match self { 103 match self {
104 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()), 104 NameClass::ExternCrate(krate) => Definition::ModuleDef(krate.root_module(db).into()),
105 NameClass::Definition(it) | NameClass::ConstReference(it) => it, 105 NameClass::Definition(it) | NameClass::ConstReference(it) => it,
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs
index ed67e3553..e0d3e7293 100644
--- a/crates/ide_db/src/imports_locator.rs
+++ b/crates/ide_db/src/imports_locator.rs
@@ -60,5 +60,5 @@ fn get_name_definition<'a>(
60 candidate_node 60 candidate_node
61 }; 61 };
62 let name = ast::Name::cast(candidate_name_node)?; 62 let name = ast::Name::cast(candidate_name_node)?;
63 classify_name(sema, &name)?.into_definition(sema.db) 63 classify_name(sema, &name)?.definition(sema.db)
64} 64}