diff options
author | Aleksey Kladov <[email protected]> | 2019-04-10 08:46:43 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-10 08:48:15 +0100 |
commit | 10726fdb65fda9144a5f9201272d065a268fc1b7 (patch) | |
tree | f5640991cbf0db2bfdad29b911435827cadfb4a8 /crates/ra_ide_api/src/references.rs | |
parent | 1cd184d6539478c7e54c92835902921976dce5d1 (diff) |
type-safer source-map for bindings
Diffstat (limited to 'crates/ra_ide_api/src/references.rs')
-rw-r--r-- | crates/ra_ide_api/src/references.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs index 20bbf11a3..3e30e047c 100644 --- a/crates/ra_ide_api/src/references.rs +++ b/crates/ra_ide_api/src/references.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use relative_path::{RelativePath, RelativePathBuf}; | 1 | use relative_path::{RelativePath, RelativePathBuf}; |
2 | use hir::{ModuleSource, source_binder}; | 2 | use hir::{ModuleSource, source_binder, Either}; |
3 | use ra_db::{SourceDatabase}; | 3 | use ra_db::{SourceDatabase}; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | AstNode, SyntaxNode, SourceFile, | 5 | AstNode, SyntaxNode, SourceFile, |
@@ -89,9 +89,12 @@ pub(crate) fn find_all_refs( | |||
89 | source_binder::function_from_child_node(db, position.file_id, name_ref.syntax())?; | 89 | source_binder::function_from_child_node(db, position.file_id, name_ref.syntax())?; |
90 | let scope = descr.scopes(db); | 90 | let scope = descr.scopes(db); |
91 | let resolved = scope.resolve_local_name(name_ref)?; | 91 | let resolved = scope.resolve_local_name(name_ref)?; |
92 | let resolved = resolved.ptr().to_node(source_file); | 92 | if let Either::A(ptr) = resolved.ptr() { |
93 | let binding = find_node_at_offset::<ast::BindPat>(syntax, resolved.range().end())?; | 93 | if let ast::PatKind::BindPat(binding) = ptr.to_node(source_file).kind() { |
94 | Some((binding, descr)) | 94 | return Some((binding, descr)); |
95 | } | ||
96 | } | ||
97 | None | ||
95 | } | 98 | } |
96 | } | 99 | } |
97 | 100 | ||