From 05ba45c667454028c3e65769d6f63fb0f27c1ca8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jan 2019 21:02:42 +0300 Subject: remove Canceled from API impl --- crates/ra_ide_api/src/lib.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide_api/src/lib.rs') 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::{ LineIndex, LineCol, translate_offset_with_edit, }; pub use ra_db::{ - Cancelable, Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId + Canceled, CrateGraph, CrateId, FileId, FilePosition, FileRange, SourceRootId }; +pub type Cancelable = Result; + #[derive(Default)] pub struct AnalysisChange { new_roots: Vec<(SourceRootId, bool)>, @@ -393,7 +395,7 @@ impl Analysis { position: FilePosition, ) -> Cancelable>>> { self.db - .catch_canceled(|db| goto_definition::goto_definition(db, position))? + .catch_canceled(|db| goto_definition::goto_definition(db, position)) } /// Finds all usages of the reference at point. @@ -403,18 +405,18 @@ impl Analysis { /// Returns a short text descrbing element at position. pub fn hover(&self, position: FilePosition) -> Cancelable>> { - self.with_db(|db| hover::hover(db, position))? + self.with_db(|db| hover::hover(db, position)) } /// Computes parameter information for the given call expression. pub fn call_info(&self, position: FilePosition) -> Cancelable> { self.db - .catch_canceled(|db| call_info::call_info(db, position))? + .catch_canceled(|db| call_info::call_info(db, position)) } /// Returns a `mod name;` declaration which created the current module. pub fn parent_module(&self, position: FilePosition) -> Cancelable> { - self.with_db(|db| parent_module::parent_module(db, position))? + self.with_db(|db| parent_module::parent_module(db, position)) } /// Returns crates this file belongs too. @@ -430,7 +432,7 @@ impl Analysis { /// Returns the set of possible targets to run for the current file. pub fn runnables(&self, file_id: FileId) -> Cancelable> { self.db - .catch_canceled(|db| runnables::runnables(db, file_id))? + .catch_canceled(|db| runnables::runnables(db, file_id)) } /// Computes syntax highlighting for the given file. @@ -460,7 +462,7 @@ impl Analysis { /// Computes the type of the expression at the given position. pub fn type_of(&self, frange: FileRange) -> Cancelable> { - self.with_db(|db| hover::type_of(db, frange))? + self.with_db(|db| hover::type_of(db, frange)) } /// Returns the edit required to rename reference at the position to the new -- cgit v1.2.3 From 0bb170a277582f5f17c21cddd27a11f19750fa36 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 15 Jan 2019 21:09:51 +0300 Subject: remove Canceled from impl of ra_ide_api --- crates/ra_ide_api/src/lib.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'crates/ra_ide_api/src/lib.rs') diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index f18eb09ae..ea5267ad9 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs @@ -9,15 +9,6 @@ //! //! The sibling `ra_ide_api_light` handles thouse bits of IDE functionality //! which are restricted to a single file and need only syntax. -macro_rules! ctry { - ($expr:expr) => { - match $expr { - None => return Ok(None), - Some(it) => it, - } - }; -} - mod db; mod imp; pub mod mock_analysis; @@ -400,7 +391,7 @@ impl Analysis { /// Finds all usages of the reference at point. pub fn find_all_refs(&self, position: FilePosition) -> Cancelable> { - self.with_db(|db| db.find_all_refs(position))? + self.with_db(|db| db.find_all_refs(position)) } /// Returns a short text descrbing element at position. @@ -445,7 +436,7 @@ impl Analysis { pub fn completions(&self, position: FilePosition) -> Cancelable>> { let completions = self .db - .catch_canceled(|db| completion::completions(db, position))??; + .catch_canceled(|db| completion::completions(db, position))?; Ok(completions.map(|it| it.into())) } @@ -472,7 +463,7 @@ impl Analysis { position: FilePosition, new_name: &str, ) -> Cancelable> { - self.with_db(|db| db.rename(position, new_name))? + self.with_db(|db| db.rename(position, new_name)) } fn with_db T + std::panic::UnwindSafe, T>( -- cgit v1.2.3