diff options
Diffstat (limited to 'crates/libanalysis/src/imp.rs')
-rw-r--r-- | crates/libanalysis/src/imp.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/libanalysis/src/imp.rs b/crates/libanalysis/src/imp.rs index 76f0c0c87..5f451f53f 100644 --- a/crates/libanalysis/src/imp.rs +++ b/crates/libanalysis/src/imp.rs | |||
@@ -16,10 +16,10 @@ use libsyntax2::{ | |||
16 | }; | 16 | }; |
17 | use rayon::prelude::*; | 17 | use rayon::prelude::*; |
18 | use once_cell::sync::OnceCell; | 18 | use once_cell::sync::OnceCell; |
19 | use libeditor::{self, FileSymbol, LineIndex, find_node_at_offset}; | 19 | use libeditor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit}; |
20 | 20 | ||
21 | use { | 21 | use { |
22 | FileId, FileResolver, Query, Diagnostic, SourceChange, FileSystemEdit, | 22 | FileId, FileResolver, Query, Diagnostic, SourceChange, SourceFileEdit, Position, FileSystemEdit, |
23 | module_map::Problem, | 23 | module_map::Problem, |
24 | symbol_index::FileSymbols, | 24 | symbol_index::FileSymbols, |
25 | module_map::ModuleMap, | 25 | module_map::ModuleMap, |
@@ -289,3 +289,19 @@ impl FileData { | |||
289 | .get_or_init(|| FileSymbols::new(&syntax)) | 289 | .get_or_init(|| FileSymbols::new(&syntax)) |
290 | } | 290 | } |
291 | } | 291 | } |
292 | |||
293 | impl SourceChange { | ||
294 | pub(crate) fn from_local_edit(file_id: FileId, label: &str, edit: LocalEdit) -> SourceChange { | ||
295 | let file_edit = SourceFileEdit { | ||
296 | file_id, | ||
297 | edits: edit.edit.into_atoms(), | ||
298 | }; | ||
299 | SourceChange { | ||
300 | label: label.to_string(), | ||
301 | source_file_edits: vec![file_edit], | ||
302 | file_system_edits: vec![], | ||
303 | cursor_position: edit.cursor_position | ||
304 | .map(|offset| Position { offset, file_id }) | ||
305 | } | ||
306 | } | ||
307 | } | ||