diff options
author | Aleksey Kladov <[email protected]> | 2019-09-19 16:23:12 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-09-19 16:27:47 +0100 |
commit | 36732a42bd24b6138b2c7bbc91495adfe558ec0f (patch) | |
tree | 0c6ebb20a62994768558c822ae7279b73bc4f43c /crates/ra_lsp_server/src/conv.rs | |
parent | 184e80007b1d549ebabb6c7a86103648470a8c9f (diff) |
move fold conversino to conv.rs
Diffstat (limited to 'crates/ra_lsp_server/src/conv.rs')
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 5fa52ec1b..d78f77925 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -6,8 +6,8 @@ use lsp_types::{ | |||
6 | }; | 6 | }; |
7 | use ra_ide_api::{ | 7 | use ra_ide_api::{ |
8 | translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, | 8 | translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, |
9 | FileRange, FileSystemEdit, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo, | 9 | FileRange, FileSystemEdit, Fold, FoldKind, InsertTextFormat, LineCol, LineIndex, |
10 | Severity, SourceChange, SourceFileEdit, | 10 | NavigationTarget, RangeInfo, Severity, SourceChange, SourceFileEdit, |
11 | }; | 11 | }; |
12 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; | 12 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; |
13 | use ra_text_edit::{AtomTextEdit, TextEdit}; | 13 | use ra_text_edit::{AtomTextEdit, TextEdit}; |
@@ -225,6 +225,26 @@ impl ConvWith<(&LineIndex, LineEndings)> for &AtomTextEdit { | |||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | impl ConvWith<&LineIndex> for Fold { | ||
229 | type Output = lsp_types::FoldingRange; | ||
230 | |||
231 | fn conv_with(self, line_index: &LineIndex) -> lsp_types::FoldingRange { | ||
232 | let range = self.range.conv_with(&line_index); | ||
233 | lsp_types::FoldingRange { | ||
234 | start_line: range.start.line, | ||
235 | start_character: Some(range.start.character), | ||
236 | end_line: range.end.line, | ||
237 | end_character: Some(range.end.character), | ||
238 | kind: match self.kind { | ||
239 | FoldKind::Comment => Some(lsp_types::FoldingRangeKind::Comment), | ||
240 | FoldKind::Imports => Some(lsp_types::FoldingRangeKind::Imports), | ||
241 | FoldKind::Mods => None, | ||
242 | FoldKind::Block => None, | ||
243 | }, | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | |||
228 | impl<T: ConvWith<CTX>, CTX> ConvWith<CTX> for Option<T> { | 248 | impl<T: ConvWith<CTX>, CTX> ConvWith<CTX> for Option<T> { |
229 | type Output = Option<T::Output>; | 249 | type Output = Option<T::Output>; |
230 | 250 | ||