aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/conv.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-28 16:17:19 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-28 16:17:19 +0000
commit7a268b9b9635425176f93d3c893fb5345e84e9ce (patch)
tree6ea69024cb22d3fc48a3b392a0185163fa452014 /crates/ra_lsp_server/src/conv.rs
parent9d6740a9c9ad2ca47c4885bd994f849e90bbef86 (diff)
parentb911ee542b2f4d1cd62a655f24197856cd9b9097 (diff)
Merge #350
350: Super simple macro support r=matklad a=matklad Super simple support for macros, mostly for figuring out how to fit them into the current architecture. Expansion is hard-coded and string based (mid-term, we should try to copy-paste macro-by-example expander from rustc). Ideally, we should handle * highlighting inside the macro (done) * extend selection inside the macro * completion inside the macro * indexing structs, produced by the macro Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/conv.rs')
-rw-r--r--crates/ra_lsp_server/src/conv.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index d3670104e..3d56ccd97 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -2,7 +2,7 @@ use languageserver_types::{
2 self, Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier, 2 self, Location, Position, Range, SymbolKind, TextDocumentEdit, TextDocumentIdentifier,
3 TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, InsertTextFormat, 3 TextDocumentItem, TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, InsertTextFormat,
4}; 4};
5use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition, CompletionItem, CompletionItemKind, InsertText}; 5use ra_analysis::{FileId, FileSystemEdit, SourceChange, SourceFileEdit, FilePosition,FileRange, CompletionItem, CompletionItemKind, InsertText};
6use ra_editor::{LineCol, LineIndex, translate_offset_with_edit}; 6use ra_editor::{LineCol, LineIndex, translate_offset_with_edit};
7use ra_text_edit::{AtomTextEdit, TextEdit}; 7use ra_text_edit::{AtomTextEdit, TextEdit};
8use ra_syntax::{SyntaxKind, TextRange, TextUnit}; 8use ra_syntax::{SyntaxKind, TextRange, TextUnit};
@@ -218,6 +218,17 @@ impl<'a> TryConvWith for &'a TextDocumentPositionParams {
218 } 218 }
219} 219}
220 220
221impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) {
222 type Ctx = ServerWorld;
223 type Output = FileRange;
224 fn try_conv_with(self, world: &ServerWorld) -> Result<FileRange> {
225 let file_id = self.0.try_conv_with(world)?;
226 let line_index = world.analysis().file_line_index(file_id);
227 let range = self.1.conv_with(&line_index);
228 Ok(FileRange { file_id, range })
229 }
230}
231
221impl<T: TryConvWith> TryConvWith for Vec<T> { 232impl<T: TryConvWith> TryConvWith for Vec<T> {
222 type Ctx = <T as TryConvWith>::Ctx; 233 type Ctx = <T as TryConvWith>::Ctx;
223 type Output = Vec<<T as TryConvWith>::Output>; 234 type Output = Vec<<T as TryConvWith>::Output>;