diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-12 07:52:38 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-12 07:52:38 +0000 |
commit | 0156a538089828340a823ed02da8970bf4f1175b (patch) | |
tree | 07c4eacaad717ea802ab26972f45223281f2c9c1 /crates/ra_lsp_server | |
parent | f655f993fe6d9faa81b0e776b9b24308d2ea1c68 (diff) | |
parent | 0527e3b283af0153cf13fa64fe73862a5b7655c8 (diff) |
Merge #276
276: Extract and rename AtomEdit and Edit into ra_text_edit r=matklad a=vemoo
As discused in #105
Co-authored-by: Bernardo <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 23 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 3 |
3 files changed, 15 insertions, 12 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 5ee218b6b..133decc52 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -28,6 +28,7 @@ rustc-hash = "1.0" | |||
28 | 28 | ||
29 | ra_syntax = { path = "../ra_syntax" } | 29 | ra_syntax = { path = "../ra_syntax" } |
30 | ra_editor = { path = "../ra_editor" } | 30 | ra_editor = { path = "../ra_editor" } |
31 | ra_text_edit = { path = "../ra_text_edit" } | ||
31 | ra_analysis = { path = "../ra_analysis" } | 32 | ra_analysis = { path = "../ra_analysis" } |
32 | gen_lsp_server = { path = "../gen_lsp_server" } | 33 | gen_lsp_server = { path = "../gen_lsp_server" } |
33 | 34 | ||
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 28368787c..7467f472c 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -1,9 +1,10 @@ | |||
1 | use languageserver_types::{ | 1 | use languageserver_types::{ |
2 | Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, | 2 | self, Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, |
3 | TextDocumentItem, TextDocumentPositionParams, TextEdit, Url, VersionedTextDocumentIdentifier, | 3 | TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, |
4 | }; | 4 | }; |
5 | use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileNodeEdit, FilePosition}; | 5 | use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileNodeEdit, FilePosition}; |
6 | use ra_editor::{AtomEdit, Edit, LineCol, LineIndex}; | 6 | use ra_editor::{LineCol, LineIndex}; |
7 | use ra_text_edit::{AtomTextEdit, TextEdit}; | ||
7 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; | 8 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; |
8 | 9 | ||
9 | use crate::{req, server_world::ServerWorld, Result}; | 10 | use crate::{req, server_world::ServerWorld, Result}; |
@@ -91,11 +92,11 @@ impl ConvWith for Range { | |||
91 | } | 92 | } |
92 | } | 93 | } |
93 | 94 | ||
94 | impl ConvWith for Edit { | 95 | impl ConvWith for TextEdit { |
95 | type Ctx = LineIndex; | 96 | type Ctx = LineIndex; |
96 | type Output = Vec<TextEdit>; | 97 | type Output = Vec<languageserver_types::TextEdit>; |
97 | 98 | ||
98 | fn conv_with(self, line_index: &LineIndex) -> Vec<TextEdit> { | 99 | fn conv_with(self, line_index: &LineIndex) -> Vec<languageserver_types::TextEdit> { |
99 | self.into_atoms() | 100 | self.into_atoms() |
100 | .into_iter() | 101 | .into_iter() |
101 | .map_conv_with(line_index) | 102 | .map_conv_with(line_index) |
@@ -103,12 +104,12 @@ impl ConvWith for Edit { | |||
103 | } | 104 | } |
104 | } | 105 | } |
105 | 106 | ||
106 | impl ConvWith for AtomEdit { | 107 | impl ConvWith for AtomTextEdit { |
107 | type Ctx = LineIndex; | 108 | type Ctx = LineIndex; |
108 | type Output = TextEdit; | 109 | type Output = languageserver_types::TextEdit; |
109 | 110 | ||
110 | fn conv_with(self, line_index: &LineIndex) -> TextEdit { | 111 | fn conv_with(self, line_index: &LineIndex) -> languageserver_types::TextEdit { |
111 | TextEdit { | 112 | languageserver_types::TextEdit { |
112 | range: self.delete.conv_with(line_index), | 113 | range: self.delete.conv_with(line_index), |
113 | new_text: self.insert, | 114 | new_text: self.insert, |
114 | } | 115 | } |
@@ -228,7 +229,7 @@ impl TryConvWith for SourceChange { | |||
228 | fn translate_offset_with_edit( | 229 | fn translate_offset_with_edit( |
229 | pre_edit_index: &LineIndex, | 230 | pre_edit_index: &LineIndex, |
230 | offset: TextUnit, | 231 | offset: TextUnit, |
231 | edits: &[AtomEdit], | 232 | edits: &[AtomTextEdit], |
232 | ) -> LineCol { | 233 | ) -> LineCol { |
233 | let fallback = pre_edit_index.line_col(offset); | 234 | let fallback = pre_edit_index.line_col(offset); |
234 | let edit = match edits.first() { | 235 | let edit = match edits.first() { |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 92e92f836..21ca22c5c 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -9,7 +9,8 @@ use languageserver_types::{ | |||
9 | WorkspaceEdit, ParameterInformation, SignatureInformation, Hover, HoverContents, | 9 | WorkspaceEdit, ParameterInformation, SignatureInformation, Hover, HoverContents, |
10 | }; | 10 | }; |
11 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; | 11 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; |
12 | use ra_syntax::{TextUnit, text_utils::{contains_offset_nonstrict, intersect}}; | 12 | use ra_syntax::{TextUnit, text_utils::intersect}; |
13 | use ra_text_edit::text_utils::contains_offset_nonstrict; | ||
13 | use rustc_hash::FxHashMap; | 14 | use rustc_hash::FxHashMap; |
14 | use serde_json::to_value; | 15 | use serde_json::to_value; |
15 | 16 | ||