From 1baba9a2e29b72b0d61b86605f9e63f4ca57799c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 29 Aug 2018 18:07:56 +0300 Subject: Minor --- crates/libanalysis/src/api.rs | 88 ++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 47 deletions(-) (limited to 'crates/libanalysis/src') diff --git a/crates/libanalysis/src/api.rs b/crates/libanalysis/src/api.rs index bb4fee398..2872d01e9 100644 --- a/crates/libanalysis/src/api.rs +++ b/crates/libanalysis/src/api.rs @@ -8,6 +8,45 @@ pub use libeditor::{ Runnable, RunnableKind, HighlightedRange, CompletionItem }; +#[derive(Debug)] +pub struct SourceChange { + pub label: String, + pub source_file_edits: Vec, + pub file_system_edits: Vec, + pub cursor_position: Option, +} + +#[derive(Debug)] +pub struct Position { + pub file_id: FileId, + pub offset: TextUnit, +} + +#[derive(Debug)] +pub struct SourceFileEdit { + pub file_id: FileId, + pub edits: Vec, +} + +#[derive(Debug)] +pub enum FileSystemEdit { + CreateFile { + anchor: FileId, + path: RelativePathBuf, + }, + MoveFile { + file: FileId, + path: RelativePathBuf, + } +} + +#[derive(Debug)] +pub struct Diagnostic { + pub message: String, + pub range: TextRange, + pub fix: Option, +} + #[derive(Clone, Debug)] pub struct Analysis { pub(crate) imp: World @@ -34,17 +73,11 @@ impl Analysis { } pub fn join_lines(&self, file_id: FileId, range: TextRange) -> SourceChange { let file = self.file_syntax(file_id); - SourceChange::from_local_edit( - file_id, "join lines", - libeditor::join_lines(&file, range), - ) + SourceChange::from_local_edit(file_id, "join lines", libeditor::join_lines(&file, range)) } pub fn on_eq_typed(&self, file_id: FileId, offset: TextUnit) -> Option { let file = self.file_syntax(file_id); - Some(SourceChange::from_local_edit( - file_id, "add semicolon", - libeditor::on_eq_typed(&file, offset)?, - )) + Some(SourceChange::from_local_edit(file_id, "add semicolon", libeditor::on_eq_typed(&file, offset)?)) } pub fn file_structure(&self, file_id: FileId) -> Vec { let file = self.file_syntax(file_id); @@ -80,45 +113,6 @@ impl Analysis { } } -#[derive(Debug)] -pub struct SourceChange { - pub label: String, - pub source_file_edits: Vec, - pub file_system_edits: Vec, - pub cursor_position: Option, -} - -#[derive(Debug)] -pub struct Position { - pub file_id: FileId, - pub offset: TextUnit, -} - -#[derive(Debug)] -pub struct SourceFileEdit { - pub file_id: FileId, - pub edits: Vec, -} - -#[derive(Debug)] -pub enum FileSystemEdit { - CreateFile { - anchor: FileId, - path: RelativePathBuf, - }, - MoveFile { - file: FileId, - path: RelativePathBuf, - } -} - -#[derive(Debug)] -pub struct Diagnostic { - pub message: String, - pub range: TextRange, - pub fix: Option, -} - impl SourceChange { pub(crate) fn from_local_edit(file_id: FileId, label: &str, edit: LocalEdit) -> SourceChange { let file_edit = SourceFileEdit { -- cgit v1.2.3