diff options
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index b068119d2..4d895b004 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -15,6 +15,7 @@ macro_rules! ctry { | |||
15 | mod db; | 15 | mod db; |
16 | mod imp; | 16 | mod imp; |
17 | mod completion; | 17 | mod completion; |
18 | mod goto_defenition; | ||
18 | mod symbol_index; | 19 | mod symbol_index; |
19 | pub mod mock_analysis; | 20 | pub mod mock_analysis; |
20 | mod runnables; | 21 | mod runnables; |
@@ -273,26 +274,6 @@ impl<T> RangeInfo<T> { | |||
273 | } | 274 | } |
274 | } | 275 | } |
275 | 276 | ||
276 | /// Result of "goto def" query. | ||
277 | #[derive(Debug)] | ||
278 | pub struct ReferenceResolution { | ||
279 | /// The range of the reference itself. Client does not know what constitutes | ||
280 | /// a reference, it handles us only the offset. It's helpful to tell the | ||
281 | /// client where the reference was. | ||
282 | pub reference_range: TextRange, | ||
283 | /// What this reference resolves to. | ||
284 | pub resolves_to: Vec<NavigationTarget>, | ||
285 | } | ||
286 | |||
287 | impl ReferenceResolution { | ||
288 | fn new(reference_range: TextRange) -> ReferenceResolution { | ||
289 | ReferenceResolution { | ||
290 | reference_range, | ||
291 | resolves_to: Vec::new(), | ||
292 | } | ||
293 | } | ||
294 | } | ||
295 | |||
296 | /// `AnalysisHost` stores the current state of the world. | 277 | /// `AnalysisHost` stores the current state of the world. |
297 | #[derive(Debug, Default)] | 278 | #[derive(Debug, Default)] |
298 | pub struct AnalysisHost { | 279 | pub struct AnalysisHost { |
@@ -392,12 +373,11 @@ impl Analysis { | |||
392 | .collect(); | 373 | .collect(); |
393 | Ok(res) | 374 | Ok(res) |
394 | } | 375 | } |
395 | /// Resolves reference to definition, but does not gurantee correctness. | 376 | pub fn goto_defenition( |
396 | pub fn approximately_resolve_symbol( | ||
397 | &self, | 377 | &self, |
398 | position: FilePosition, | 378 | position: FilePosition, |
399 | ) -> Cancelable<Option<ReferenceResolution>> { | 379 | ) -> Cancelable<Option<Vec<NavigationTarget>>> { |
400 | self.db.approximately_resolve_symbol(position) | 380 | goto_defenition::goto_defenition(&*self.db, position) |
401 | } | 381 | } |
402 | /// Finds all usages of the reference at point. | 382 | /// Finds all usages of the reference at point. |
403 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { | 383 | pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { |