diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-19 13:57:03 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-19 13:57:03 +0000 |
commit | 27587f3501168c0522e62bf14923aedbdc08a960 (patch) | |
tree | f323973f087ef0f47ef7015a930b09fefdf723a6 /crates/ra_ide/src/references | |
parent | ff415582960dbd91a18a092271c0848d6c90b0ec (diff) | |
parent | 372439dec88f8ce3350f29aa56801c8f30e59abe (diff) |
Merge #3236
3236: Merge NameDefinition and NameKind r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/references')
-rw-r--r-- | crates/ra_ide/src/references/classify.rs | 25 | ||||
-rw-r--r-- | crates/ra_ide/src/references/search_scope.rs | 4 |
2 files changed, 8 insertions, 21 deletions
diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs index ca5750521..478e18871 100644 --- a/crates/ra_ide/src/references/classify.rs +++ b/crates/ra_ide/src/references/classify.rs | |||
@@ -5,7 +5,7 @@ use ra_prof::profile; | |||
5 | use ra_syntax::{ast, AstNode}; | 5 | use ra_syntax::{ast, AstNode}; |
6 | use test_utils::tested_by; | 6 | use test_utils::tested_by; |
7 | 7 | ||
8 | use super::{NameDefinition, NameKind}; | 8 | use super::NameDefinition; |
9 | use ra_ide_db::RootDatabase; | 9 | use ra_ide_db::RootDatabase; |
10 | 10 | ||
11 | pub use ra_ide_db::defs::{classify_name, from_module_def, from_struct_field}; | 11 | pub use ra_ide_db::defs::{classify_name, from_module_def, from_struct_field}; |
@@ -46,8 +46,7 @@ pub(crate) fn classify_name_ref( | |||
46 | if let Some(macro_def) = | 46 | if let Some(macro_def) = |
47 | analyzer.resolve_macro_call(sb.db, name_ref.with_value(¯o_call)) | 47 | analyzer.resolve_macro_call(sb.db, name_ref.with_value(¯o_call)) |
48 | { | 48 | { |
49 | let kind = NameKind::Macro(macro_def); | 49 | return Some(NameDefinition::Macro(macro_def)); |
50 | return Some(NameDefinition { kind }); | ||
51 | } | 50 | } |
52 | } | 51 | } |
53 | 52 | ||
@@ -63,22 +62,10 @@ pub(crate) fn classify_name_ref( | |||
63 | }; | 62 | }; |
64 | from_module_def(def) | 63 | from_module_def(def) |
65 | } | 64 | } |
66 | PathResolution::Local(local) => { | 65 | PathResolution::Local(local) => NameDefinition::Local(local), |
67 | let kind = NameKind::Local(local); | 66 | PathResolution::TypeParam(par) => NameDefinition::TypeParam(par), |
68 | NameDefinition { kind } | 67 | PathResolution::Macro(def) => NameDefinition::Macro(def), |
69 | } | 68 | PathResolution::SelfType(impl_block) => NameDefinition::SelfType(impl_block), |
70 | PathResolution::TypeParam(par) => { | ||
71 | let kind = NameKind::TypeParam(par); | ||
72 | NameDefinition { kind } | ||
73 | } | ||
74 | PathResolution::Macro(def) => { | ||
75 | let kind = NameKind::Macro(def); | ||
76 | NameDefinition { kind } | ||
77 | } | ||
78 | PathResolution::SelfType(impl_block) => { | ||
79 | let kind = NameKind::SelfType(impl_block); | ||
80 | NameDefinition { kind } | ||
81 | } | ||
82 | }; | 69 | }; |
83 | Some(res) | 70 | Some(res) |
84 | } | 71 | } |
diff --git a/crates/ra_ide/src/references/search_scope.rs b/crates/ra_ide/src/references/search_scope.rs index e5ac12044..27d483233 100644 --- a/crates/ra_ide/src/references/search_scope.rs +++ b/crates/ra_ide/src/references/search_scope.rs | |||
@@ -12,7 +12,7 @@ use rustc_hash::FxHashMap; | |||
12 | 12 | ||
13 | use ra_ide_db::RootDatabase; | 13 | use ra_ide_db::RootDatabase; |
14 | 14 | ||
15 | use super::{NameDefinition, NameKind}; | 15 | use super::NameDefinition; |
16 | 16 | ||
17 | pub struct SearchScope { | 17 | pub struct SearchScope { |
18 | entries: FxHashMap<FileId, Option<TextRange>>, | 18 | entries: FxHashMap<FileId, Option<TextRange>>, |
@@ -32,7 +32,7 @@ impl SearchScope { | |||
32 | let module_src = module.definition_source(db); | 32 | let module_src = module.definition_source(db); |
33 | let file_id = module_src.file_id.original_file(db); | 33 | let file_id = module_src.file_id.original_file(db); |
34 | 34 | ||
35 | if let NameKind::Local(var) = def.kind { | 35 | if let NameDefinition::Local(var) = def { |
36 | let range = match var.parent(db) { | 36 | let range = match var.parent(db) { |
37 | DefWithBody::Function(f) => f.source(db).value.syntax().text_range(), | 37 | DefWithBody::Function(f) => f.source(db).value.syntax().text_range(), |
38 | DefWithBody::Const(c) => c.source(db).value.syntax().text_range(), | 38 | DefWithBody::Const(c) => c.source(db).value.syntax().text_range(), |