aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-30 12:27:13 +0100
committerAleksey Kladov <[email protected]>2020-06-30 12:29:53 +0100
commitaf7e300041b1af68e671446fe22d2b9e5d30f83d (patch)
tree18b444a0d447465a7de75ec5a0153c90b8566a7f /crates/ra_ide
parent34072d53b683805f449bf106d16788f171ca3522 (diff)
Remove confusing API
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs36
-rw-r--r--crates/ra_ide/src/goto_implementation.rs2
2 files changed, 15 insertions, 23 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
14use crate::{FileRange, FileSymbol}; 14use crate::FileSymbol;
15 15
16use super::short_label::ShortLabel; 16use 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) {
diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs
index 1882789c4..99a7022a4 100644
--- a/crates/ra_ide/src/goto_implementation.rs
+++ b/crates/ra_ide/src/goto_implementation.rs
@@ -76,7 +76,7 @@ fn impls_for_trait(
76mod tests { 76mod tests {
77 use ra_db::FileRange; 77 use ra_db::FileRange;
78 78
79 use crate::mock_analysis::{analysis_and_position, MockAnalysis}; 79 use crate::mock_analysis::MockAnalysis;
80 80
81 fn check(ra_fixture: &str) { 81 fn check(ra_fixture: &str) {
82 let (mock, position) = MockAnalysis::with_files_and_position(ra_fixture); 82 let (mock, position) = MockAnalysis::with_files_and_position(ra_fixture);