diff options
Diffstat (limited to 'crates/ra_ide_api/src/lib.rs')
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index 0f690fc84..f18eb09ae 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -58,9 +58,11 @@ pub use ra_ide_api_light::{ | |||
58 | LineIndex, LineCol, translate_offset_with_edit, | 58 | LineIndex, LineCol, translate_offset_with_edit, |
59 | }; | 59 | }; |
60 | pub use ra_db::{ | 60 | pub use ra_db::{ |
61 | Cancelable, Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId | 61 | Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId |
62 | }; | 62 | }; |
63 | 63 | ||
64 | pub type Cancelable<T> = Result<T, Canceled>; | ||
65 | |||
64 | #[derive(Default)] | 66 | #[derive(Default)] |
65 | pub struct AnalysisChange { | 67 | pub struct AnalysisChange { |
66 | new_roots: Vec<(SourceRootId, bool)>, | 68 | new_roots: Vec<(SourceRootId, bool)>, |
@@ -393,7 +395,7 @@ impl Analysis { | |||
393 | position: FilePosition, | 395 | position: FilePosition, |
394 | ) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> { | 396 | ) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> { |
395 | self.db | 397 | self.db |
396 | .catch_canceled(|db| goto_definition::goto_definition(db, position))? | 398 | .catch_canceled(|db| goto_definition::goto_definition(db, position)) |
397 | } | 399 | } |
398 | 400 | ||
399 | /// Finds all usages of the reference at point. | 401 | /// Finds all usages of the reference at point. |
@@ -403,18 +405,18 @@ impl Analysis { | |||
403 | 405 | ||
404 | /// Returns a short text descrbing element at position. | 406 | /// Returns a short text descrbing element at position. |
405 | pub fn hover(&self, position: FilePosition) -> Cancelable<Option<RangeInfo<String>>> { | 407 | pub fn hover(&self, position: FilePosition) -> Cancelable<Option<RangeInfo<String>>> { |
406 | self.with_db(|db| hover::hover(db, position))? | 408 | self.with_db(|db| hover::hover(db, position)) |
407 | } | 409 | } |
408 | 410 | ||
409 | /// Computes parameter information for the given call expression. | 411 | /// Computes parameter information for the given call expression. |
410 | pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> { | 412 | pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> { |
411 | self.db | 413 | self.db |
412 | .catch_canceled(|db| call_info::call_info(db, position))? | 414 | .catch_canceled(|db| call_info::call_info(db, position)) |
413 | } | 415 | } |
414 | 416 | ||
415 | /// Returns a `mod name;` declaration which created the current module. | 417 | /// Returns a `mod name;` declaration which created the current module. |
416 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> { | 418 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> { |
417 | self.with_db(|db| parent_module::parent_module(db, position))? | 419 | self.with_db(|db| parent_module::parent_module(db, position)) |
418 | } | 420 | } |
419 | 421 | ||
420 | /// Returns crates this file belongs too. | 422 | /// Returns crates this file belongs too. |
@@ -430,7 +432,7 @@ impl Analysis { | |||
430 | /// Returns the set of possible targets to run for the current file. | 432 | /// Returns the set of possible targets to run for the current file. |
431 | pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> { | 433 | pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> { |
432 | self.db | 434 | self.db |
433 | .catch_canceled(|db| runnables::runnables(db, file_id))? | 435 | .catch_canceled(|db| runnables::runnables(db, file_id)) |
434 | } | 436 | } |
435 | 437 | ||
436 | /// Computes syntax highlighting for the given file. | 438 | /// Computes syntax highlighting for the given file. |
@@ -460,7 +462,7 @@ impl Analysis { | |||
460 | 462 | ||
461 | /// Computes the type of the expression at the given position. | 463 | /// Computes the type of the expression at the given position. |
462 | pub fn type_of(&self, frange: FileRange) -> Cancelable<Option<String>> { | 464 | pub fn type_of(&self, frange: FileRange) -> Cancelable<Option<String>> { |
463 | self.with_db(|db| hover::type_of(db, frange))? | 465 | self.with_db(|db| hover::type_of(db, frange)) |
464 | } | 466 | } |
465 | 467 | ||
466 | /// Returns the edit required to rename reference at the position to the new | 468 | /// Returns the edit required to rename reference at the position to the new |