diff options
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r-- | crates/ra_ide/src/lib.rs | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 09f602fe1..737f87109 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -16,7 +16,6 @@ macro_rules! eprintln { | |||
16 | } | 16 | } |
17 | 17 | ||
18 | pub mod mock_analysis; | 18 | pub mod mock_analysis; |
19 | mod source_change; | ||
20 | 19 | ||
21 | mod prime_caches; | 20 | mod prime_caches; |
22 | mod status; | 21 | mod status; |
@@ -32,7 +31,6 @@ mod syntax_highlighting; | |||
32 | mod parent_module; | 31 | mod parent_module; |
33 | mod references; | 32 | mod references; |
34 | mod impls; | 33 | mod impls; |
35 | mod assists; | ||
36 | mod diagnostics; | 34 | mod diagnostics; |
37 | mod syntax_tree; | 35 | mod syntax_tree; |
38 | mod folding_ranges; | 36 | mod folding_ranges; |
@@ -65,7 +63,6 @@ use ra_syntax::{SourceFile, TextRange, TextSize}; | |||
65 | use crate::display::ToNav; | 63 | use crate::display::ToNav; |
66 | 64 | ||
67 | pub use crate::{ | 65 | pub use crate::{ |
68 | assists::{Assist, AssistId}, | ||
69 | call_hierarchy::CallItem, | 66 | call_hierarchy::CallItem, |
70 | completion::{ | 67 | completion::{ |
71 | CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, | 68 | CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, |
@@ -78,7 +75,6 @@ pub use crate::{ | |||
78 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, | 75 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, |
79 | references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, | 76 | references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, |
80 | runnables::{Runnable, RunnableKind, TestId}, | 77 | runnables::{Runnable, RunnableKind, TestId}, |
81 | source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, | ||
82 | ssr::SsrError, | 78 | ssr::SsrError, |
83 | syntax_highlighting::{ | 79 | syntax_highlighting::{ |
84 | Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange, | 80 | Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange, |
@@ -86,6 +82,7 @@ pub use crate::{ | |||
86 | }; | 82 | }; |
87 | 83 | ||
88 | pub use hir::Documentation; | 84 | pub use hir::Documentation; |
85 | pub use ra_assists::AssistId; | ||
89 | pub use ra_db::{ | 86 | pub use ra_db::{ |
90 | Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, | 87 | Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, |
91 | }; | 88 | }; |
@@ -94,6 +91,7 @@ pub use ra_ide_db::{ | |||
94 | line_index::{LineCol, LineIndex}, | 91 | line_index::{LineCol, LineIndex}, |
95 | line_index_utils::translate_offset_with_edit, | 92 | line_index_utils::translate_offset_with_edit, |
96 | search::SearchScope, | 93 | search::SearchScope, |
94 | source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, | ||
97 | symbol_index::Query, | 95 | symbol_index::Query, |
98 | RootDatabase, | 96 | RootDatabase, |
99 | }; | 97 | }; |
@@ -135,10 +133,12 @@ pub struct AnalysisHost { | |||
135 | db: RootDatabase, | 133 | db: RootDatabase, |
136 | } | 134 | } |
137 | 135 | ||
138 | impl Default for AnalysisHost { | 136 | #[derive(Debug)] |
139 | fn default() -> AnalysisHost { | 137 | pub struct Assist { |
140 | AnalysisHost::new(None) | 138 | pub id: AssistId, |
141 | } | 139 | pub label: String, |
140 | pub group_label: Option<String>, | ||
141 | pub source_change: SourceChange, | ||
142 | } | 142 | } |
143 | 143 | ||
144 | impl AnalysisHost { | 144 | impl AnalysisHost { |
@@ -188,6 +188,12 @@ impl AnalysisHost { | |||
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | impl Default for AnalysisHost { | ||
192 | fn default() -> AnalysisHost { | ||
193 | AnalysisHost::new(None) | ||
194 | } | ||
195 | } | ||
196 | |||
191 | /// 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 |
192 | /// 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 |
193 | /// state is advanced using `AnalysisHost::apply_change` method, all existing | 199 | /// state is advanced using `AnalysisHost::apply_change` method, all existing |
@@ -296,7 +302,7 @@ impl Analysis { | |||
296 | file_id: frange.file_id, | 302 | file_id: frange.file_id, |
297 | edit: join_lines::join_lines(&parse.tree(), frange.range), | 303 | edit: join_lines::join_lines(&parse.tree(), frange.range), |
298 | }; | 304 | }; |
299 | SourceChange::source_file_edit("join lines", file_edit) | 305 | SourceChange::source_file_edit("Join lines", file_edit) |
300 | }) | 306 | }) |
301 | } | 307 | } |
302 | 308 | ||
@@ -465,7 +471,17 @@ impl Analysis { | |||
465 | /// Computes assists (aka code actions aka intentions) for the given | 471 | /// Computes assists (aka code actions aka intentions) for the given |
466 | /// position. | 472 | /// position. |
467 | pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> { | 473 | pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> { |
468 | self.with_db(|db| assists::assists(db, frange)) | 474 | self.with_db(|db| { |
475 | ra_assists::resolved_assists(db, frange) | ||
476 | .into_iter() | ||
477 | .map(|assist| Assist { | ||
478 | id: assist.label.id, | ||
479 | label: assist.label.label, | ||
480 | group_label: assist.label.group.map(|it| it.0), | ||
481 | source_change: assist.source_change, | ||
482 | }) | ||
483 | .collect() | ||
484 | }) | ||
469 | } | 485 | } |
470 | 486 | ||
471 | /// Computes the set of diagnostics for the given file. | 487 | /// Computes the set of diagnostics for the given file. |
@@ -490,7 +506,7 @@ impl Analysis { | |||
490 | ) -> Cancelable<Result<SourceChange, SsrError>> { | 506 | ) -> Cancelable<Result<SourceChange, SsrError>> { |
491 | self.with_db(|db| { | 507 | self.with_db(|db| { |
492 | let edits = ssr::parse_search_replace(query, parse_only, db)?; | 508 | let edits = ssr::parse_search_replace(query, parse_only, db)?; |
493 | Ok(SourceChange::source_file_edits("ssr", edits)) | 509 | Ok(SourceChange::source_file_edits("Structural Search Replace", edits)) |
494 | }) | 510 | }) |
495 | } | 511 | } |
496 | 512 | ||