Fix compilation

This commit is contained in:
Aleksey Kladov 2020-05-05 20:44:13 +02:00
parent aee22c73c3
commit df00da15c4
2 changed files with 8 additions and 13 deletions

View file

@ -17,13 +17,13 @@ mod doc_tests;
pub mod utils; pub mod utils;
pub mod ast_transform; pub mod ast_transform;
use hir::Semantics;
use ra_db::{FileId, FileRange}; use ra_db::{FileId, FileRange};
use ra_ide_db::RootDatabase; use ra_ide_db::RootDatabase;
use ra_syntax::{TextRange, TextSize}; use ra_syntax::{TextRange, TextSize};
use ra_text_edit::TextEdit; use ra_text_edit::TextEdit;
pub(crate) use crate::assist_ctx::{Assist, AssistCtx, AssistHandler}; pub(crate) use crate::assist_ctx::{Assist, AssistCtx, AssistHandler};
use hir::Semantics;
/// Unique identifier of the assist, should not be shown to the user /// Unique identifier of the assist, should not be shown to the user
/// directly. /// directly.

View file

@ -1,6 +1,6 @@
//! FIXME: write short doc here //! FIXME: write short doc here
use ra_assists::{resolved_assists, AssistAction, AssistLabel}; use ra_assists::{resolved_assists, AssistAction};
use ra_db::{FilePosition, FileRange}; use ra_db::{FilePosition, FileRange};
use ra_ide_db::RootDatabase; use ra_ide_db::RootDatabase;
@ -21,27 +21,22 @@ pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
.into_iter() .into_iter()
.map(|assist| { .map(|assist| {
let file_id = frange.file_id; let file_id = frange.file_id;
let assist_label = &assist.label;
Assist { Assist {
id: assist_label.id, id: assist.label.id,
label: assist_label.label.clone(), label: assist.label.label.clone(),
group_label: assist.group_label.map(|it| it.0), group_label: assist.label.group.map(|it| it.0),
source_change: action_to_edit(assist.action, file_id, assist_label), source_change: action_to_edit(assist.action, file_id, assist.label.label.clone()),
} }
}) })
.collect() .collect()
} }
fn action_to_edit( fn action_to_edit(action: AssistAction, file_id: FileId, label: String) -> SourceChange {
action: AssistAction,
file_id: FileId,
assist_label: &AssistLabel,
) -> SourceChange {
let file_id = match action.file { let file_id = match action.file {
ra_assists::AssistFile::TargetFile(it) => it, ra_assists::AssistFile::TargetFile(it) => it,
_ => file_id, _ => file_id,
}; };
let file_edit = SourceFileEdit { file_id, edit: action.edit }; let file_edit = SourceFileEdit { file_id, edit: action.edit };
SourceChange::source_file_edit(assist_label.label.clone(), file_edit) SourceChange::source_file_edit(label, file_edit)
.with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id }))
} }