diff options
Diffstat (limited to 'crates/ra_ide/src/display/navigation_target.rs')
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index f8a466304..8bf2428ed 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -11,7 +11,7 @@ use ra_syntax::{ | |||
11 | TextRange, | 11 | TextRange, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | use crate::{FileRange, FileSymbol}; | 14 | use crate::FileSymbol; |
15 | 15 | ||
16 | use super::short_label::ShortLabel; | 16 | use super::short_label::ShortLabel; |
17 | 17 | ||
@@ -47,6 +47,19 @@ impl NavigationTarget { | |||
47 | pub fn range(&self) -> TextRange { | 47 | pub fn range(&self) -> TextRange { |
48 | self.focus_range.unwrap_or(self.full_range) | 48 | self.focus_range.unwrap_or(self.full_range) |
49 | } | 49 | } |
50 | /// A "most interesting" range withing the `full_range`. | ||
51 | /// | ||
52 | /// Typically, `full_range` is the whole syntax node, | ||
53 | /// including doc comments, and `focus_range` is the range of the identifier. | ||
54 | pub fn focus_range(&self) -> Option<TextRange> { | ||
55 | self.focus_range | ||
56 | } | ||
57 | pub fn full_range(&self) -> TextRange { | ||
58 | self.full_range | ||
59 | } | ||
60 | pub fn file_id(&self) -> FileId { | ||
61 | self.file_id | ||
62 | } | ||
50 | 63 | ||
51 | pub fn name(&self) -> &SmolStr { | 64 | pub fn name(&self) -> &SmolStr { |
52 | &self.name | 65 | &self.name |
@@ -60,19 +73,6 @@ impl NavigationTarget { | |||
60 | self.kind | 73 | self.kind |
61 | } | 74 | } |
62 | 75 | ||
63 | pub fn file_id(&self) -> FileId { | ||
64 | self.file_id | ||
65 | } | ||
66 | |||
67 | // TODO: inconsistent | ||
68 | pub fn file_range(&self) -> FileRange { | ||
69 | FileRange { file_id: self.file_id, range: self.full_range } | ||
70 | } | ||
71 | |||
72 | pub fn full_range(&self) -> TextRange { | ||
73 | self.full_range | ||
74 | } | ||
75 | |||
76 | pub fn docs(&self) -> Option<&str> { | 76 | pub fn docs(&self) -> Option<&str> { |
77 | self.docs.as_deref() | 77 | self.docs.as_deref() |
78 | } | 78 | } |
@@ -81,14 +81,6 @@ impl NavigationTarget { | |||
81 | self.description.as_deref() | 81 | self.description.as_deref() |
82 | } | 82 | } |
83 | 83 | ||
84 | /// A "most interesting" range withing the `full_range`. | ||
85 | /// | ||
86 | /// Typically, `full_range` is the whole syntax node, | ||
87 | /// including doc comments, and `focus_range` is the range of the identifier. | ||
88 | pub fn focus_range(&self) -> Option<TextRange> { | ||
89 | self.focus_range | ||
90 | } | ||
91 | |||
92 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { | 84 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { |
93 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 85 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
94 | if let Some(src) = module.declaration_source(db) { | 86 | if let Some(src) = module.declaration_source(db) { |