aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/lib.rs
diff options
context:
space:
mode:
authorvsrs <[email protected]>2020-05-08 17:34:34 +0100
committervsrs <[email protected]>2020-05-08 17:34:34 +0100
commit0ef17ef1ee9fb0ce7149176d12f4d225f6d01401 (patch)
treefa2f168120f36f8dbef5dc1e85fea0c0071639c2 /crates/ra_ide/src/lib.rs
parent1be6320ea6cf7830195f80681fa0f43cc340da7e (diff)
parentd3eb9d8eafbebca7da95fa8a4813b92eb5080500 (diff)
Merge remote-tracking branch 'upstream/master' into uniformed_debug_lens
# Conflicts: # editors/code/src/commands/runnables.ts
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r--crates/ra_ide/src/lib.rs31
1 files changed, 24 insertions, 7 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 4ed02f60e..915199bd8 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -31,7 +31,6 @@ mod syntax_highlighting;
31mod parent_module; 31mod parent_module;
32mod references; 32mod references;
33mod impls; 33mod impls;
34mod assists;
35mod diagnostics; 34mod diagnostics;
36mod syntax_tree; 35mod syntax_tree;
37mod folding_ranges; 36mod folding_ranges;
@@ -64,7 +63,6 @@ use ra_syntax::{SourceFile, TextRange, TextSize};
64use crate::display::ToNav; 63use crate::display::ToNav;
65 64
66pub use crate::{ 65pub use crate::{
67 assists::{Assist, AssistId},
68 call_hierarchy::CallItem, 66 call_hierarchy::CallItem,
69 completion::{ 67 completion::{
70 CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, 68 CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
@@ -84,6 +82,7 @@ pub use crate::{
84}; 82};
85 83
86pub use hir::Documentation; 84pub use hir::Documentation;
85pub use ra_assists::AssistId;
87pub use ra_db::{ 86pub use ra_db::{
88 Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, 87 Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId,
89}; 88};
@@ -134,10 +133,12 @@ pub struct AnalysisHost {
134 db: RootDatabase, 133 db: RootDatabase,
135} 134}
136 135
137impl Default for AnalysisHost { 136#[derive(Debug)]
138 fn default() -> AnalysisHost { 137pub struct Assist {
139 AnalysisHost::new(None) 138 pub id: AssistId,
140 } 139 pub label: String,
140 pub group_label: Option<String>,
141 pub source_change: SourceChange,
141} 142}
142 143
143impl AnalysisHost { 144impl AnalysisHost {
@@ -187,6 +188,12 @@ impl AnalysisHost {
187 } 188 }
188} 189}
189 190
191impl Default for AnalysisHost {
192 fn default() -> AnalysisHost {
193 AnalysisHost::new(None)
194 }
195}
196
190/// Analysis is a snapshot of a world state at a moment in time. It is the main 197/// Analysis is a snapshot of a world state at a moment in time. It is the main
191/// entry point for asking semantic information about the world. When the world 198/// entry point for asking semantic information about the world. When the world
192/// state is advanced using `AnalysisHost::apply_change` method, all existing 199/// state is advanced using `AnalysisHost::apply_change` method, all existing
@@ -464,7 +471,17 @@ impl Analysis {
464 /// Computes assists (aka code actions aka intentions) for the given 471 /// Computes assists (aka code actions aka intentions) for the given
465 /// position. 472 /// position.
466 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> { 473 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> {
467 self.with_db(|db| assists::assists(db, frange)) 474 self.with_db(|db| {
475 ra_assists::Assist::resolved(db, frange)
476 .into_iter()
477 .map(|assist| Assist {
478 id: assist.assist.id,
479 label: assist.assist.label,
480 group_label: assist.assist.group.map(|it| it.0),
481 source_change: assist.source_change,
482 })
483 .collect()
484 })
468 } 485 }
469 486
470 /// Computes the set of diagnostics for the given file. 487 /// Computes the set of diagnostics for the given file.