aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/lib.rs39
1 files changed, 17 insertions, 22 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 12d5716e8..34c2d75fe 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -77,7 +77,7 @@ pub use crate::{
77}; 77};
78 78
79pub use hir::Documentation; 79pub use hir::Documentation;
80pub use ra_assists::{AssistConfig, AssistId}; 80pub use ra_assists::{Assist, AssistConfig, AssistId, ResolvedAssist};
81pub use ra_db::{ 81pub use ra_db::{
82 Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, 82 Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId,
83}; 83};
@@ -142,14 +142,6 @@ pub struct AnalysisHost {
142 db: RootDatabase, 142 db: RootDatabase,
143} 143}
144 144
145#[derive(Debug)]
146pub struct Assist {
147 pub id: AssistId,
148 pub label: String,
149 pub group_label: Option<String>,
150 pub source_change: SourceChange,
151}
152
153impl AnalysisHost { 145impl AnalysisHost {
154 pub fn new(lru_capacity: Option<usize>) -> AnalysisHost { 146 pub fn new(lru_capacity: Option<usize>) -> AnalysisHost {
155 AnalysisHost { db: RootDatabase::new(lru_capacity) } 147 AnalysisHost { db: RootDatabase::new(lru_capacity) }
@@ -470,20 +462,23 @@ impl Analysis {
470 self.with_db(|db| completion::completions(db, config, position).map(Into::into)) 462 self.with_db(|db| completion::completions(db, config, position).map(Into::into))
471 } 463 }
472 464
473 /// Computes assists (aka code actions aka intentions) for the given 465 /// Computes resolved assists with source changes for the given position.
466 pub fn resolved_assists(
467 &self,
468 config: &AssistConfig,
469 frange: FileRange,
470 ) -> Cancelable<Vec<ResolvedAssist>> {
471 self.with_db(|db| ra_assists::Assist::resolved(db, config, frange))
472 }
473
474 /// Computes unresolved assists (aka code actions aka intentions) for the given
474 /// position. 475 /// position.
475 pub fn assists(&self, config: &AssistConfig, frange: FileRange) -> Cancelable<Vec<Assist>> { 476 pub fn unresolved_assists(
476 self.with_db(|db| { 477 &self,
477 ra_assists::Assist::resolved(db, config, frange) 478 config: &AssistConfig,
478 .into_iter() 479 frange: FileRange,
479 .map(|assist| Assist { 480 ) -> Cancelable<Vec<Assist>> {
480 id: assist.assist.id, 481 self.with_db(|db| Assist::unresolved(db, config, frange))
481 label: assist.assist.label,
482 group_label: assist.assist.group.map(|it| it.0),
483 source_change: assist.source_change,
484 })
485 .collect()
486 })
487 } 482 }
488 483
489 /// Computes the set of diagnostics for the given file. 484 /// Computes the set of diagnostics for the given file.