From 36732a42bd24b6138b2c7bbc91495adfe558ec0f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 19 Sep 2019 18:23:12 +0300 Subject: move fold conversino to conv.rs --- crates/ra_lsp_server/src/conv.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 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 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::{ }; use ra_ide_api::{ translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition, - FileRange, FileSystemEdit, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo, - Severity, SourceChange, SourceFileEdit, + FileRange, FileSystemEdit, Fold, FoldKind, InsertTextFormat, LineCol, LineIndex, + NavigationTarget, RangeInfo, Severity, SourceChange, SourceFileEdit, }; use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use ra_text_edit::{AtomTextEdit, TextEdit}; @@ -225,6 +225,26 @@ impl ConvWith<(&LineIndex, LineEndings)> for &AtomTextEdit { } } +impl ConvWith<&LineIndex> for Fold { + type Output = lsp_types::FoldingRange; + + fn conv_with(self, line_index: &LineIndex) -> lsp_types::FoldingRange { + let range = self.range.conv_with(&line_index); + lsp_types::FoldingRange { + start_line: range.start.line, + start_character: Some(range.start.character), + end_line: range.end.line, + end_character: Some(range.end.character), + kind: match self.kind { + FoldKind::Comment => Some(lsp_types::FoldingRangeKind::Comment), + FoldKind::Imports => Some(lsp_types::FoldingRangeKind::Imports), + FoldKind::Mods => None, + FoldKind::Block => None, + }, + } + } +} + impl, CTX> ConvWith for Option { type Output = Option; -- cgit v1.2.3