aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/navigation_target.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/navigation_target.rs')
-rw-r--r--crates/ra_ide_api/src/navigation_target.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs
index 004921863..fd001179a 100644
--- a/crates/ra_ide_api/src/navigation_target.rs
+++ b/crates/ra_ide_api/src/navigation_target.rs
@@ -23,6 +23,12 @@ pub struct NavigationTarget {
23} 23}
24 24
25impl NavigationTarget { 25impl NavigationTarget {
26 /// When `focus_range` is specified, returns it. otherwise
27 /// returns `full_range`
28 pub fn range(&self) -> TextRange {
29 self.focus_range.unwrap_or(self.full_range)
30 }
31
26 pub fn name(&self) -> &SmolStr { 32 pub fn name(&self) -> &SmolStr {
27 &self.name 33 &self.name
28 } 34 }
@@ -43,14 +49,18 @@ impl NavigationTarget {
43 self.full_range 49 self.full_range
44 } 50 }
45 51
46 /// A "most interesting" range withing the `range_full`. 52 /// A "most interesting" range withing the `full_range`.
47 /// 53 ///
48 /// Typically, `range` is the whole syntax node, including doc comments, and 54 /// Typically, `full_range` is the whole syntax node,
49 /// `focus_range` is the range of the identifier. 55 /// including doc comments, and `focus_range` is the range of the identifier.
50 pub fn focus_range(&self) -> Option<TextRange> { 56 pub fn focus_range(&self) -> Option<TextRange> {
51 self.focus_range 57 self.focus_range
52 } 58 }
53 59
60 pub(crate) fn from_bind_pat(file_id: FileId, pat: &ast::BindPat) -> NavigationTarget {
61 NavigationTarget::from_named(file_id, pat)
62 }
63
54 pub(crate) fn from_symbol(symbol: FileSymbol) -> NavigationTarget { 64 pub(crate) fn from_symbol(symbol: FileSymbol) -> NavigationTarget {
55 NavigationTarget { 65 NavigationTarget {
56 file_id: symbol.file_id, 66 file_id: symbol.file_id,