From 85a6bf342490f2a8be34ea53af9eb8fcdcad2b38 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 17 Feb 2019 13:38:32 +0200 Subject: Refactor find_all_refs to return ReferenceSearchResult --- crates/ra_ide_api/src/navigation_target.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide_api/src/navigation_target.rs') 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 { } impl NavigationTarget { + /// When `focus_range` is specified, returns it. otherwise + /// returns `full_range` + pub fn range(&self) -> TextRange { + self.focus_range.unwrap_or(self.full_range) + } + pub fn name(&self) -> &SmolStr { &self.name } @@ -43,14 +49,18 @@ impl NavigationTarget { self.full_range } - /// A "most interesting" range withing the `range_full`. + /// A "most interesting" range withing the `full_range`. /// - /// Typically, `range` is the whole syntax node, including doc comments, and - /// `focus_range` is the range of the identifier. + /// Typically, `full_range` is the whole syntax node, + /// including doc comments, and `focus_range` is the range of the identifier. pub fn focus_range(&self) -> Option { self.focus_range } + pub(crate) fn from_bind_pat(file_id: FileId, pat: &ast::BindPat) -> NavigationTarget { + NavigationTarget::from_named(file_id, pat) + } + pub(crate) fn from_symbol(symbol: FileSymbol) -> NavigationTarget { NavigationTarget { file_id: symbol.file_id, -- cgit v1.2.3