diff options
author | Jeremy A. Kolb <[email protected]> | 2018-10-24 19:24:32 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-31 20:30:57 +0000 |
commit | 406f366ccc8b903f457cc694dc1214794c0cfc88 (patch) | |
tree | 73fded51f2b3f41a0f08683291cda25b0cfef59a /crates/ra_analysis/src/imp.rs | |
parent | 55ebe6380aef233fff86b7e6cead361787bf1f65 (diff) |
Add DeclarationDescriptor and ReferenceDescriptor
Fixes #142
Fixes #146
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index b3c094041..f950a7995 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -22,7 +22,7 @@ use crate::{ | |||
22 | }, | 22 | }, |
23 | input::{SourceRootId, FilesDatabase, SourceRoot, WORKSPACE}, | 23 | input::{SourceRootId, FilesDatabase, SourceRoot, WORKSPACE}, |
24 | descriptors::{ | 24 | descriptors::{ |
25 | DescriptorDatabase, | 25 | DescriptorDatabase, DeclarationDescriptor, |
26 | module::{ModuleTree, Problem}, | 26 | module::{ModuleTree, Problem}, |
27 | function::{FnDescriptor, FnId}, | 27 | function::{FnDescriptor, FnId}, |
28 | }, | 28 | }, |
@@ -327,6 +327,17 @@ impl AnalysisImpl { | |||
327 | 327 | ||
328 | let mut ret = vec![]; | 328 | let mut ret = vec![]; |
329 | 329 | ||
330 | if let Some(binding) = find_node_at_offset::<ast::BindPat>(syntax, offset) { | ||
331 | let decl = DeclarationDescriptor::new(binding); | ||
332 | |||
333 | ret.push((file_id, decl.range)); | ||
334 | |||
335 | ret.extend(decl.find_all_refs().into_iter() | ||
336 | .map(|ref_desc| (file_id, ref_desc.range ))); | ||
337 | |||
338 | return ret; | ||
339 | } | ||
340 | |||
330 | // Find the symbol we are looking for | 341 | // Find the symbol we are looking for |
331 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { | 342 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { |
332 | 343 | ||