From fdd4df97ba5ce1f59abf9e945052fc6f3e077c3a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 6 May 2020 15:26:40 +0200 Subject: Use SourceChange for assists --- crates/ra_ide/src/lib.rs | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide/src/lib.rs') diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 4ed02f60e..614029de4 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -31,7 +31,6 @@ mod syntax_highlighting; mod parent_module; mod references; mod impls; -mod assists; mod diagnostics; mod syntax_tree; mod folding_ranges; @@ -64,7 +63,6 @@ use ra_syntax::{SourceFile, TextRange, TextSize}; use crate::display::ToNav; pub use crate::{ - assists::{Assist, AssistId}, call_hierarchy::CallItem, completion::{ CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, @@ -84,6 +82,7 @@ pub use crate::{ }; pub use hir::Documentation; +pub use ra_assists::AssistId; pub use ra_db::{ Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, }; @@ -134,10 +133,12 @@ pub struct AnalysisHost { db: RootDatabase, } -impl Default for AnalysisHost { - fn default() -> AnalysisHost { - AnalysisHost::new(None) - } +#[derive(Debug)] +pub struct Assist { + pub id: AssistId, + pub label: String, + pub group_label: Option, + pub source_change: SourceChange, } impl AnalysisHost { @@ -187,6 +188,12 @@ impl AnalysisHost { } } +impl Default for AnalysisHost { + fn default() -> AnalysisHost { + AnalysisHost::new(None) + } +} + /// Analysis is a snapshot of a world state at a moment in time. It is the main /// entry point for asking semantic information about the world. When the world /// state is advanced using `AnalysisHost::apply_change` method, all existing @@ -464,7 +471,17 @@ impl Analysis { /// Computes assists (aka code actions aka intentions) for the given /// position. pub fn assists(&self, frange: FileRange) -> Cancelable> { - self.with_db(|db| assists::assists(db, frange)) + self.with_db(|db| { + ra_assists::resolved_assists(db, frange) + .into_iter() + .map(|assist| Assist { + id: assist.label.id, + label: assist.label.label, + group_label: assist.label.group.map(|it| it.0), + source_change: assist.action, + }) + .collect() + }) } /// Computes the set of diagnostics for the given file. -- cgit v1.2.3 From 0970c3454baa0164df81a9ff665430d486687331 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 6 May 2020 16:01:47 +0200 Subject: Rename --- crates/ra_ide/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/lib.rs') diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 614029de4..737f87109 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -478,7 +478,7 @@ impl Analysis { id: assist.label.id, label: assist.label.label, group_label: assist.label.group.map(|it| it.0), - source_change: assist.action, + source_change: assist.source_change, }) .collect() }) -- cgit v1.2.3 From c6b81bc013b5278b917d109b723405e0df413323 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 7 May 2020 17:09:59 +0200 Subject: Rename AssitLabel -> Assist --- crates/ra_ide/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide/src/lib.rs') diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 737f87109..0e15f1ccd 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -475,9 +475,9 @@ impl Analysis { ra_assists::resolved_assists(db, frange) .into_iter() .map(|assist| Assist { - id: assist.label.id, - label: assist.label.label, - group_label: assist.label.group.map(|it| it.0), + id: assist.assist.id, + label: assist.assist.label, + group_label: assist.assist.group.map(|it| it.0), source_change: assist.source_change, }) .collect() -- cgit v1.2.3 From 28fcff125a73ab2fc4aeaa100fc472af5178db20 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 7 May 2020 17:29:23 +0200 Subject: Nicer API --- crates/ra_ide/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide/src/lib.rs') diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 0e15f1ccd..915199bd8 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -472,7 +472,7 @@ impl Analysis { /// position. pub fn assists(&self, frange: FileRange) -> Cancelable> { self.with_db(|db| { - ra_assists::resolved_assists(db, frange) + ra_assists::Assist::resolved(db, frange) .into_iter() .map(|assist| Assist { id: assist.assist.id, -- cgit v1.2.3