aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-20 17:55:08 +0000
committerAleksey Kladov <[email protected]>2019-01-20 17:55:08 +0000
commitc517696fab33c7829b429f2eed7289c8b785d6be (patch)
treef50c4f942096beae27479a7e403c048e06fe6b86
parent3508ba9bc2c2180a6495238c2fafa493557f36d0 (diff)
use with_db consistently
-rw-r--r--crates/ra_ide_api/src/lib.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 33bef178a..ca6b25516 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -388,8 +388,7 @@ impl Analysis {
388 &self, 388 &self,
389 position: FilePosition, 389 position: FilePosition,
390 ) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> { 390 ) -> Cancelable<Option<RangeInfo<Vec<NavigationTarget>>>> {
391 self.db 391 self.with_db(|db| goto_definition::goto_definition(db, position))
392 .catch_canceled(|db| goto_definition::goto_definition(db, position))
393 } 392 }
394 393
395 /// Finds all usages of the reference at point. 394 /// Finds all usages of the reference at point.
@@ -404,8 +403,7 @@ impl Analysis {
404 403
405 /// Computes parameter information for the given call expression. 404 /// Computes parameter information for the given call expression.
406 pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> { 405 pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> {
407 self.db 406 self.with_db(|db| call_info::call_info(db, position))
408 .catch_canceled(|db| call_info::call_info(db, position))
409 } 407 }
410 408
411 /// Returns a `mod name;` declaration which created the current module. 409 /// Returns a `mod name;` declaration which created the current module.
@@ -420,33 +418,28 @@ impl Analysis {
420 418
421 /// Returns the root file of the given crate. 419 /// Returns the root file of the given crate.
422 pub fn crate_root(&self, crate_id: CrateId) -> Cancelable<FileId> { 420 pub fn crate_root(&self, crate_id: CrateId) -> Cancelable<FileId> {
423 Ok(self.db.crate_graph().crate_root(crate_id)) 421 self.with_db(|db| db.crate_graph().crate_root(crate_id))
424 } 422 }
425 423
426 /// Returns the set of possible targets to run for the current file. 424 /// Returns the set of possible targets to run for the current file.
427 pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> { 425 pub fn runnables(&self, file_id: FileId) -> Cancelable<Vec<Runnable>> {
428 self.db 426 self.with_db(|db| runnables::runnables(db, file_id))
429 .catch_canceled(|db| runnables::runnables(db, file_id))
430 } 427 }
431 428
432 /// Computes syntax highlighting for the given file. 429 /// Computes syntax highlighting for the given file.
433 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> { 430 pub fn highlight(&self, file_id: FileId) -> Cancelable<Vec<HighlightedRange>> {
434 self.db 431 self.with_db(|db| syntax_highlighting::highlight(db, file_id))
435 .catch_canceled(|db| syntax_highlighting::highlight(db, file_id))
436 } 432 }
437 433
438 /// Computes completions at the given position. 434 /// Computes completions at the given position.
439 pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> { 435 pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> {
440 let completions = self 436 self.with_db(|db| completion::completions(db, position).map(Into::into))
441 .db
442 .catch_canceled(|db| completion::completions(db, position))?;
443 Ok(completions.map(|it| it.into()))
444 } 437 }
445 438
446 /// Computes assists (aks code actons aka intentions) for the given 439 /// Computes assists (aks code actons aka intentions) for the given
447 /// position. 440 /// position.
448 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<SourceChange>> { 441 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<SourceChange>> {
449 Ok(self.db.assists(frange)) 442 self.with_db(|db| db.assists(frange))
450 } 443 }
451 444
452 /// Computes the set of diagnostics for the given file. 445 /// Computes the set of diagnostics for the given file.