From 7344d28768c43d8955bf23c183d606be08f27c64 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 10 Dec 2018 22:09:12 +0100 Subject: extract AtomEdit and Edit into new ra_text_edit crate --- crates/ra_lsp_server/src/conv.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/src/conv.rs') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 28368787c..8bf8576be 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -3,7 +3,8 @@ use languageserver_types::{ TextDocumentItem, TextDocumentPositionParams, TextEdit, Url, VersionedTextDocumentIdentifier, }; use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileNodeEdit, FilePosition}; -use ra_editor::{AtomEdit, Edit, LineCol, LineIndex}; +use ra_editor::{LineCol, LineIndex}; +use ra_text_edit::{AtomEdit, Edit}; use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use crate::{req, server_world::ServerWorld, Result}; -- cgit v1.2.3 From 0527e3b283af0153cf13fa64fe73862a5b7655c8 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Tue, 11 Dec 2018 19:07:17 +0100 Subject: rename Edit to TextEdit and AtomEdit to AtomTextEdit --- crates/ra_lsp_server/src/conv.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/ra_lsp_server/src/conv.rs') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 8bf8576be..7467f472c 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -1,10 +1,10 @@ use languageserver_types::{ - Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, - TextDocumentItem, TextDocumentPositionParams, TextEdit, Url, VersionedTextDocumentIdentifier, + self, Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, + TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, }; use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileNodeEdit, FilePosition}; use ra_editor::{LineCol, LineIndex}; -use ra_text_edit::{AtomEdit, Edit}; +use ra_text_edit::{AtomTextEdit, TextEdit}; use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use crate::{req, server_world::ServerWorld, Result}; @@ -92,11 +92,11 @@ impl ConvWith for Range { } } -impl ConvWith for Edit { +impl ConvWith for TextEdit { type Ctx = LineIndex; - type Output = Vec; + type Output = Vec; - fn conv_with(self, line_index: &LineIndex) -> Vec { + fn conv_with(self, line_index: &LineIndex) -> Vec { self.into_atoms() .into_iter() .map_conv_with(line_index) @@ -104,12 +104,12 @@ impl ConvWith for Edit { } } -impl ConvWith for AtomEdit { +impl ConvWith for AtomTextEdit { type Ctx = LineIndex; - type Output = TextEdit; + type Output = languageserver_types::TextEdit; - fn conv_with(self, line_index: &LineIndex) -> TextEdit { - TextEdit { + fn conv_with(self, line_index: &LineIndex) -> languageserver_types::TextEdit { + languageserver_types::TextEdit { range: self.delete.conv_with(line_index), new_text: self.insert, } @@ -229,7 +229,7 @@ impl TryConvWith for SourceChange { fn translate_offset_with_edit( pre_edit_index: &LineIndex, offset: TextUnit, - edits: &[AtomEdit], + edits: &[AtomTextEdit], ) -> LineCol { let fallback = pre_edit_index.line_col(offset); let edit = match edits.first() { -- cgit v1.2.3