This commit is contained in:
Aleksey Kladov 2018-08-30 12:34:31 +03:00
parent 7d95d38ecb
commit 0d6d74e78e
2 changed files with 18 additions and 18 deletions

View file

@ -109,19 +109,3 @@ impl Analysis {
self.imp.diagnostics(file_id)
}
}
impl SourceChange {
pub(crate) fn from_local_edit(file_id: FileId, label: &str, edit: LocalEdit) -> SourceChange {
let file_edit = SourceFileEdit {
file_id,
edits: edit.edit.into_atoms(),
};
SourceChange {
label: label.to_string(),
source_file_edits: vec![file_edit],
file_system_edits: vec![],
cursor_position: edit.cursor_position
.map(|offset| Position { offset, file_id })
}
}
}

View file

@ -16,10 +16,10 @@ use libsyntax2::{
};
use rayon::prelude::*;
use once_cell::sync::OnceCell;
use libeditor::{self, FileSymbol, LineIndex, find_node_at_offset};
use libeditor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit};
use {
FileId, FileResolver, Query, Diagnostic, SourceChange, FileSystemEdit,
FileId, FileResolver, Query, Diagnostic, SourceChange, SourceFileEdit, Position, FileSystemEdit,
module_map::Problem,
symbol_index::FileSymbols,
module_map::ModuleMap,
@ -289,3 +289,19 @@ impl FileData {
.get_or_init(|| FileSymbols::new(&syntax))
}
}
impl SourceChange {
pub(crate) fn from_local_edit(file_id: FileId, label: &str, edit: LocalEdit) -> SourceChange {
let file_edit = SourceFileEdit {
file_id,
edits: edit.edit.into_atoms(),
};
SourceChange {
label: label.to_string(),
source_file_edits: vec![file_edit],
file_system_edits: vec![],
cursor_position: edit.cursor_position
.map(|offset| Position { offset, file_id })
}
}
}