mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Refactor find_all_refs to return ReferenceSearchResult
This commit is contained in:
parent
edd4c1d8a6
commit
85a6bf3424
6 changed files with 127 additions and 48 deletions
|
@ -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<TextRange> {
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue