diff options
author | Aleksey Kladov <[email protected]> | 2019-04-13 07:31:03 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-13 07:31:03 +0100 |
commit | 3aae223d938e5a36d997c45a0f86cfcabf83b570 (patch) | |
tree | 354c1e3c3a5e07b233c4e8490225f9be720a3315 /crates/ra_ide_api/src | |
parent | 58fe5598e70eef6edf109865cb87b806b22536fb (diff) |
hide some scopes
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index 3e30e047c..ee2c1d0f0 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs | |||
@@ -61,12 +61,11 @@ pub(crate) fn find_all_refs( | |||
61 | position: FilePosition, | 61 | position: FilePosition, |
62 | ) -> Option<ReferenceSearchResult> { | 62 | ) -> Option<ReferenceSearchResult> { |
63 | let file = db.parse(position.file_id); | 63 | let file = db.parse(position.file_id); |
64 | let (binding, descr) = find_binding(db, &file, position)?; | 64 | let (binding, analyzer) = find_binding(db, &file, position)?; |
65 | let declaration = NavigationTarget::from_bind_pat(position.file_id, binding); | 65 | let declaration = NavigationTarget::from_bind_pat(position.file_id, binding); |
66 | 66 | ||
67 | let references = descr | 67 | let references = analyzer |
68 | .scopes(db) | 68 | .find_all_refs(binding)? |
69 | .find_all_refs(binding) | ||
70 | .into_iter() | 69 | .into_iter() |
71 | .map(move |ref_desc| FileRange { file_id: position.file_id, range: ref_desc.range }) | 70 | .map(move |ref_desc| FileRange { file_id: position.file_id, range: ref_desc.range }) |
72 | .collect::<Vec<_>>(); | 71 | .collect::<Vec<_>>(); |
@@ -77,21 +76,18 @@ pub(crate) fn find_all_refs( | |||
77 | db: &RootDatabase, | 76 | db: &RootDatabase, |
78 | source_file: &'a SourceFile, | 77 | source_file: &'a SourceFile, |
79 | position: FilePosition, | 78 | position: FilePosition, |
80 | ) -> Option<(&'a ast::BindPat, hir::Function)> { | 79 | ) -> Option<(&'a ast::BindPat, hir::SourceAnalyzer)> { |
81 | let syntax = source_file.syntax(); | 80 | let syntax = source_file.syntax(); |
82 | if let Some(binding) = find_node_at_offset::<ast::BindPat>(syntax, position.offset) { | 81 | if let Some(binding) = find_node_at_offset::<ast::BindPat>(syntax, position.offset) { |
83 | let descr = | 82 | let analyzer = hir::SourceAnalyzer::new(db, position.file_id, binding.syntax(), None); |
84 | source_binder::function_from_child_node(db, position.file_id, binding.syntax())?; | 83 | return Some((binding, analyzer)); |
85 | return Some((binding, descr)); | ||
86 | }; | 84 | }; |
87 | let name_ref = find_node_at_offset::<ast::NameRef>(syntax, position.offset)?; | 85 | let name_ref = find_node_at_offset::<ast::NameRef>(syntax, position.offset)?; |
88 | let descr = | 86 | let analyzer = hir::SourceAnalyzer::new(db, position.file_id, name_ref.syntax(), None); |
89 | source_binder::function_from_child_node(db, position.file_id, name_ref.syntax())?; | 87 | let resolved = analyzer.resolve_local_name(name_ref)?; |
90 | let scope = descr.scopes(db); | ||
91 | let resolved = scope.resolve_local_name(name_ref)?; | ||
92 | if let Either::A(ptr) = resolved.ptr() { | 88 | if let Either::A(ptr) = resolved.ptr() { |
93 | if let ast::PatKind::BindPat(binding) = ptr.to_node(source_file).kind() { | 89 | if let ast::PatKind::BindPat(binding) = ptr.to_node(source_file).kind() { |
94 | return Some((binding, descr)); | 90 | return Some((binding, analyzer)); |
95 | } | 91 | } |
96 | } | 92 | } |
97 | None | 93 | None |