aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r--crates/ra_analysis/src/lib.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index ff28271ab..4d8bdb61b 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -244,6 +244,21 @@ impl Query {
244 } 244 }
245} 245}
246 246
247#[derive(Debug)]
248pub struct NavigationTarget {
249 file_id: FileId,
250 symbol: FileSymbol,
251}
252
253impl NavigationTarget {
254 pub fn file_id(&self) -> FileId {
255 self.file_id
256 }
257 pub fn range(&self) -> TextRange {
258 self.symbol.node_range
259 }
260}
261
247/// Result of "goto def" query. 262/// Result of "goto def" query.
248#[derive(Debug)] 263#[derive(Debug)]
249pub struct ReferenceResolution { 264pub struct ReferenceResolution {
@@ -252,7 +267,7 @@ pub struct ReferenceResolution {
252 /// client where the reference was. 267 /// client where the reference was.
253 pub reference_range: TextRange, 268 pub reference_range: TextRange,
254 /// What this reference resolves to. 269 /// What this reference resolves to.
255 pub resolves_to: Vec<(FileId, FileSymbol)>, 270 pub resolves_to: Vec<NavigationTarget>,
256} 271}
257 272
258impl ReferenceResolution { 273impl ReferenceResolution {
@@ -264,7 +279,7 @@ impl ReferenceResolution {
264 } 279 }
265 280
266 fn add_resolution(&mut self, file_id: FileId, symbol: FileSymbol) { 281 fn add_resolution(&mut self, file_id: FileId, symbol: FileSymbol) {
267 self.resolves_to.push((file_id, symbol)) 282 self.resolves_to.push(NavigationTarget { file_id, symbol })
268 } 283 }
269} 284}
270 285
@@ -334,8 +349,8 @@ impl Analysis {
334 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { 349 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> {
335 self.imp.find_all_refs(position) 350 self.imp.find_all_refs(position)
336 } 351 }
337 pub fn doc_text_for(&self, file_id: FileId, symbol: FileSymbol) -> Cancelable<Option<String>> { 352 pub fn doc_text_for(&self, nav: NavigationTarget) -> Cancelable<Option<String>> {
338 self.imp.doc_text_for(file_id, symbol) 353 self.imp.doc_text_for(nav)
339 } 354 }
340 pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { 355 pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> {
341 self.imp.parent_module(position) 356 self.imp.parent_module(position)