mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Add DeclarationDescriptor and ReferenceDescriptor
Fixes #142 Fixes #146
This commit is contained in:
parent
55ebe6380a
commit
406f366ccc
3 changed files with 77 additions and 4 deletions
|
@ -22,7 +22,7 @@ use crate::{
|
|||
},
|
||||
input::{SourceRootId, FilesDatabase, SourceRoot, WORKSPACE},
|
||||
descriptors::{
|
||||
DescriptorDatabase,
|
||||
DescriptorDatabase, DeclarationDescriptor,
|
||||
module::{ModuleTree, Problem},
|
||||
function::{FnDescriptor, FnId},
|
||||
},
|
||||
|
@ -327,6 +327,17 @@ impl AnalysisImpl {
|
|||
|
||||
let mut ret = vec![];
|
||||
|
||||
if let Some(binding) = find_node_at_offset::<ast::BindPat>(syntax, offset) {
|
||||
let decl = DeclarationDescriptor::new(binding);
|
||||
|
||||
ret.push((file_id, decl.range));
|
||||
|
||||
ret.extend(decl.find_all_refs().into_iter()
|
||||
.map(|ref_desc| (file_id, ref_desc.range )));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Find the symbol we are looking for
|
||||
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue