mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
type-safer source-map for bindings
This commit is contained in:
parent
1cd184d653
commit
10726fdb65
7 changed files with 45 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
|||
use relative_path::{RelativePath, RelativePathBuf};
|
||||
use hir::{ModuleSource, source_binder};
|
||||
use hir::{ModuleSource, source_binder, Either};
|
||||
use ra_db::{SourceDatabase};
|
||||
use ra_syntax::{
|
||||
AstNode, SyntaxNode, SourceFile,
|
||||
|
@ -89,9 +89,12 @@ pub(crate) fn find_all_refs(
|
|||
source_binder::function_from_child_node(db, position.file_id, name_ref.syntax())?;
|
||||
let scope = descr.scopes(db);
|
||||
let resolved = scope.resolve_local_name(name_ref)?;
|
||||
let resolved = resolved.ptr().to_node(source_file);
|
||||
let binding = find_node_at_offset::<ast::BindPat>(syntax, resolved.range().end())?;
|
||||
Some((binding, descr))
|
||||
if let Either::A(ptr) = resolved.ptr() {
|
||||
if let ast::PatKind::BindPat(binding) = ptr.to_node(source_file).kind() {
|
||||
return Some((binding, descr));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue