aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r--crates/ra_ide/src/lib.rs25
1 files changed, 8 insertions, 17 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 78149ddfc..97ff67ee8 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -42,11 +42,6 @@ mod inlay_hints;
42mod expand_macro; 42mod expand_macro;
43mod ssr; 43mod ssr;
44 44
45#[cfg(test)]
46mod marks;
47#[cfg(test)]
48mod test_utils;
49
50use std::sync::Arc; 45use std::sync::Arc;
51 46
52use ra_cfg::CfgOptions; 47use ra_cfg::CfgOptions;
@@ -82,19 +77,19 @@ pub use crate::{
82}; 77};
83 78
84pub use hir::Documentation; 79pub use hir::Documentation;
85pub use ra_assists::AssistId; 80pub use ra_assists::{AssistConfig, AssistId};
86pub use ra_db::{ 81pub use ra_db::{
87 Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, 82 Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId,
88}; 83};
89pub use ra_ide_db::{ 84pub use ra_ide_db::{
90 change::{AnalysisChange, LibraryData}, 85 change::{AnalysisChange, LibraryData},
91 line_index::{LineCol, LineIndex}, 86 line_index::{LineCol, LineIndex},
92 line_index_utils::translate_offset_with_edit,
93 search::SearchScope, 87 search::SearchScope,
94 source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, 88 source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
95 symbol_index::Query, 89 symbol_index::Query,
96 RootDatabase, 90 RootDatabase,
97}; 91};
92pub use ra_text_edit::{Indel, TextEdit};
98 93
99pub type Cancelable<T> = Result<T, Canceled>; 94pub type Cancelable<T> = Result<T, Canceled>;
100 95
@@ -291,14 +286,10 @@ impl Analysis {
291 286
292 /// Returns an edit to remove all newlines in the range, cleaning up minor 287 /// Returns an edit to remove all newlines in the range, cleaning up minor
293 /// stuff like trailing commas. 288 /// stuff like trailing commas.
294 pub fn join_lines(&self, frange: FileRange) -> Cancelable<SourceChange> { 289 pub fn join_lines(&self, frange: FileRange) -> Cancelable<TextEdit> {
295 self.with_db(|db| { 290 self.with_db(|db| {
296 let parse = db.parse(frange.file_id); 291 let parse = db.parse(frange.file_id);
297 let file_edit = SourceFileEdit { 292 join_lines::join_lines(&parse.tree(), frange.range)
298 file_id: frange.file_id,
299 edit: join_lines::join_lines(&parse.tree(), frange.range),
300 };
301 SourceChange::source_file_edit("Join lines", file_edit)
302 }) 293 })
303 } 294 }
304 295
@@ -458,17 +449,17 @@ impl Analysis {
458 /// Computes completions at the given position. 449 /// Computes completions at the given position.
459 pub fn completions( 450 pub fn completions(
460 &self, 451 &self,
461 position: FilePosition,
462 config: &CompletionConfig, 452 config: &CompletionConfig,
453 position: FilePosition,
463 ) -> Cancelable<Option<Vec<CompletionItem>>> { 454 ) -> Cancelable<Option<Vec<CompletionItem>>> {
464 self.with_db(|db| completion::completions(db, position, config).map(Into::into)) 455 self.with_db(|db| completion::completions(db, config, position).map(Into::into))
465 } 456 }
466 457
467 /// Computes assists (aka code actions aka intentions) for the given 458 /// Computes assists (aka code actions aka intentions) for the given
468 /// position. 459 /// position.
469 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> { 460 pub fn assists(&self, config: &AssistConfig, frange: FileRange) -> Cancelable<Vec<Assist>> {
470 self.with_db(|db| { 461 self.with_db(|db| {
471 ra_assists::Assist::resolved(db, frange) 462 ra_assists::Assist::resolved(db, config, frange)
472 .into_iter() 463 .into_iter()
473 .map(|assist| Assist { 464 .map(|assist| Assist {
474 id: assist.assist.id, 465 id: assist.assist.id,