From ccca427ce45d18d80b1876a7c5b05cf3205b86e5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:25:27 +0300 Subject: minor --- crates/ra_lsp_server/src/conv.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index df8ea6e0d..236fdb972 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -217,7 +217,7 @@ impl ConvWith for TextEdit { } } -impl<'a> ConvWith for &'a AtomTextEdit { +impl ConvWith for &'_ AtomTextEdit { type Ctx = LineIndex; type Output = lsp_types::TextEdit; -- cgit v1.2.3 From de3f2948ea2416d65640c07d2c69df75a4273d50 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:26:07 +0300 Subject: add tests for crlf --- crates/ra_lsp_server/tests/heavy_tests/main.rs | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index de3bd5bc5..ec075a2fd 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -414,3 +414,49 @@ fn main() {{}} let elapsed = start.elapsed(); assert!(elapsed.as_millis() < 2000, "typing enter took {:?}", elapsed); } + +#[test] +fn preserves_dos_line_endings() { + let server = Project::with_fixture( + &r#" +//- Cargo.toml +[package] +name = "foo" +version = "0.0.0" + +//- src/main.rs +/// Some Docs\r\nfn main() {} +"#, + ) + .server(); + + server.request::( + TextDocumentPositionParams { + text_document: server.doc_id("src/main.rs"), + position: Position { line: 0, character: 8 }, + }, + json!({ + "cursorPosition": { + "position": { "line": 1, "character": 4 }, + "textDocument": { "uri": "file:///[..]src/main.rs" } + }, + "label": "on enter", + "workspaceEdit": { + "documentChanges": [ + { + "edits": [ + { + "newText": "\r\n/// ", + "range": { + "end": { "line": 0, "character": 8 }, + "start": { "line": 0, "character": 8 } + } + } + ], + "textDocument": { "uri": "file:///[..]src/main.rs", "version": null } + } + ] + } + }), + ); +} -- cgit v1.2.3 From 80a6e614465d8b16cae50f3626c15e912ad3c6f2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:33:23 +0300 Subject: make CTX type param instead of assoc type that way, we can implement ConvWith<&'_ CTX> for different lifetimes --- crates/ra_lsp_server/src/conv.rs | 59 +++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 34 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 236fdb972..bbe140b7a 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -19,10 +19,9 @@ pub trait Conv { fn conv(self) -> Self::Output; } -pub trait ConvWith { - type Ctx; +pub trait ConvWith { type Output; - fn conv_with(self, ctx: &Self::Ctx) -> Self::Output; + fn conv_with(self, ctx: CTX) -> Self::Output; } pub trait TryConvWith { @@ -89,8 +88,7 @@ impl Conv for Severity { } } -impl ConvWith for CompletionItem { - type Ctx = LineIndex; +impl ConvWith<&'_ LineIndex> for CompletionItem { type Output = ::lsp_types::CompletionItem; fn conv_with(self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { @@ -138,8 +136,7 @@ impl ConvWith for CompletionItem { } } -impl ConvWith for Position { - type Ctx = LineIndex; +impl ConvWith<&'_ LineIndex> for Position { type Output = TextUnit; fn conv_with(self, line_index: &LineIndex) -> TextUnit { @@ -148,8 +145,7 @@ impl ConvWith for Position { } } -impl ConvWith for TextUnit { - type Ctx = LineIndex; +impl ConvWith<&'_ LineIndex> for TextUnit { type Output = Position; fn conv_with(self, line_index: &LineIndex) -> Position { @@ -158,8 +154,7 @@ impl ConvWith for TextUnit { } } -impl ConvWith for TextRange { - type Ctx = LineIndex; +impl ConvWith<&'_ LineIndex> for TextRange { type Output = Range; fn conv_with(self, line_index: &LineIndex) -> Range { @@ -167,8 +162,7 @@ impl ConvWith for TextRange { } } -impl ConvWith for Range { - type Ctx = LineIndex; +impl ConvWith<&'_ LineIndex> for Range { type Output = TextRange; fn conv_with(self, line_index: &LineIndex) -> TextRange { @@ -208,8 +202,7 @@ impl Conv for ra_ide_api::FunctionSignature { } } -impl ConvWith for TextEdit { - type Ctx = LineIndex; +impl ConvWith<&'_ LineIndex> for TextEdit { type Output = Vec; fn conv_with(self, line_index: &LineIndex) -> Vec { @@ -217,8 +210,7 @@ impl ConvWith for TextEdit { } } -impl ConvWith for &'_ AtomTextEdit { - type Ctx = LineIndex; +impl ConvWith<&'_ LineIndex> for &'_ AtomTextEdit { type Output = lsp_types::TextEdit; fn conv_with(self, line_index: &LineIndex) -> lsp_types::TextEdit { @@ -229,10 +221,10 @@ impl ConvWith for &'_ AtomTextEdit { } } -impl ConvWith for Option { - type Ctx = ::Ctx; - type Output = Option<::Output>; - fn conv_with(self, ctx: &Self::Ctx) -> Self::Output { +impl, CTX> ConvWith for Option { + type Output = Option; + + fn conv_with(self, ctx: CTX) -> Self::Output { self.map(|x| ConvWith::conv_with(x, ctx)) } } @@ -454,35 +446,34 @@ pub fn to_location( Ok(loc) } -pub trait MapConvWith<'a>: Sized + 'a { - type Ctx; +pub trait MapConvWith: Sized { type Output; - fn map_conv_with(self, ctx: &'a Self::Ctx) -> ConvWithIter<'a, Self, Self::Ctx> { + fn map_conv_with(self, ctx: CTX) -> ConvWithIter { ConvWithIter { iter: self, ctx } } } -impl<'a, I> MapConvWith<'a> for I +impl MapConvWith for I where - I: Iterator + 'a, - I::Item: ConvWith, + I: Iterator, + I::Item: ConvWith, { - type Ctx = ::Ctx; - type Output = ::Output; + type Output = >::Output; } -pub struct ConvWithIter<'a, I, Ctx: 'a> { +pub struct ConvWithIter { iter: I, - ctx: &'a Ctx, + ctx: CTX, } -impl<'a, I, Ctx> Iterator for ConvWithIter<'a, I, Ctx> +impl Iterator for ConvWithIter where I: Iterator, - I::Item: ConvWith, + I::Item: ConvWith, + CTX: Copy, { - type Item = ::Output; + type Item = >::Output; fn next(&mut self) -> Option { self.iter.next().map(|item| item.conv_with(self.ctx)) -- cgit v1.2.3 From 6ea4184fd107e5cc155b95a3cf058200c38d544d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:53:59 +0300 Subject: translate \n -> \r\n on the way out --- crates/ra_lsp_server/src/conv.rs | 30 ++++++++++++++++---------- crates/ra_lsp_server/src/main_loop/handlers.rs | 6 ++++-- crates/ra_lsp_server/src/world.rs | 6 +++++- crates/ra_lsp_server/tests/heavy_tests/main.rs | 10 ++++----- 4 files changed, 33 insertions(+), 19 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index bbe140b7a..bd1ffd8f5 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -11,6 +11,7 @@ use ra_ide_api::{ }; use ra_syntax::{SyntaxKind, TextRange, TextUnit}; use ra_text_edit::{AtomTextEdit, TextEdit}; +use ra_vfs::LineEndings; use crate::{req, world::WorldSnapshot, Result}; @@ -88,10 +89,10 @@ impl Conv for Severity { } } -impl ConvWith<&'_ LineIndex> for CompletionItem { +impl ConvWith<(&'_ LineIndex, LineEndings)> for CompletionItem { type Output = ::lsp_types::CompletionItem; - fn conv_with(self, ctx: &LineIndex) -> ::lsp_types::CompletionItem { + fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> ::lsp_types::CompletionItem { let mut additional_text_edits = Vec::new(); let mut text_edit = None; // LSP does not allow arbitrary edits in completion, so we have to do a @@ -202,22 +203,27 @@ impl Conv for ra_ide_api::FunctionSignature { } } -impl ConvWith<&'_ LineIndex> for TextEdit { +impl ConvWith<(&'_ LineIndex, LineEndings)> for TextEdit { type Output = Vec; - fn conv_with(self, line_index: &LineIndex) -> Vec { - self.as_atoms().iter().map_conv_with(line_index).collect() + fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> Vec { + self.as_atoms().iter().map_conv_with(ctx).collect() } } -impl ConvWith<&'_ LineIndex> for &'_ AtomTextEdit { +impl ConvWith<(&'_ LineIndex, LineEndings)> for &'_ AtomTextEdit { type Output = lsp_types::TextEdit; - fn conv_with(self, line_index: &LineIndex) -> lsp_types::TextEdit { - lsp_types::TextEdit { - range: self.delete.conv_with(line_index), - new_text: self.insert.clone(), + fn conv_with( + self, + (line_index, line_endings): (&LineIndex, LineEndings), + ) -> lsp_types::TextEdit { + eprintln!("line_endings = {:?}", line_endings); + let mut new_text = self.insert.clone(); + if line_endings == LineEndings::Dos { + new_text = new_text.replace('\n', "\r\n"); } + lsp_types::TextEdit { range: self.delete.conv_with(line_index), new_text } } } @@ -352,7 +358,9 @@ impl TryConvWith for SourceFileEdit { version: None, }; let line_index = world.analysis().file_line_index(self.file_id)?; - let edits = self.edit.as_atoms().iter().map_conv_with(&line_index).collect(); + let line_endings = world.file_line_endings(self.file_id); + let edits = + self.edit.as_atoms().iter().map_conv_with((&line_index, line_endings)).collect(); Ok(TextDocumentEdit { text_document, edits }) } } diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index b465707f8..3a559e845 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -138,6 +138,7 @@ pub fn handle_on_type_formatting( let _p = profile("handle_on_type_formatting"); let mut position = params.text_document_position.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(position.file_id)?; + let line_endings = world.file_line_endings(position.file_id); // in `ra_ide_api`, the `on_type` invariant is that // `text.char_at(position) == typed_char`. @@ -156,7 +157,7 @@ pub fn handle_on_type_formatting( // This should be a single-file edit let edit = edit.source_file_edits.pop().unwrap(); - let change: Vec = edit.edit.conv_with(&line_index); + let change: Vec = edit.edit.conv_with((&line_index, line_endings)); Ok(Some(change)) } @@ -370,8 +371,9 @@ pub fn handle_completion( Some(items) => items, }; let line_index = world.analysis().file_line_index(position.file_id)?; + let line_endings = world.file_line_endings(position.file_id); let items: Vec = - items.into_iter().map(|item| item.conv_with(&line_index)).collect(); + items.into_iter().map(|item| item.conv_with((&line_index, line_endings))).collect(); Ok(Some(items.into())) } diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 9990ef62e..10f96812f 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -9,7 +9,7 @@ use parking_lot::RwLock; use ra_ide_api::{ Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, LibraryData, SourceRootId, }; -use ra_vfs::{RootEntry, Vfs, VfsChange, VfsFile, VfsRoot}; +use ra_vfs::{LineEndings, RootEntry, Vfs, VfsChange, VfsFile, VfsRoot}; use ra_vfs_glob::{Glob, RustPackageFilterBuilder}; use relative_path::RelativePathBuf; @@ -210,6 +210,10 @@ impl WorldSnapshot { Ok(url) } + pub fn file_line_endings(&self, id: FileId) -> LineEndings { + self.vfs.read().file_line_endings(VfsFile(id.0)) + } + pub fn path_to_uri(&self, root: SourceRootId, path: &RelativePathBuf) -> Result { let base = self.vfs.read().root2path(VfsRoot(root.0)); let path = path.to_path(base); diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index ec075a2fd..152681062 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs @@ -208,7 +208,7 @@ pub use std::collections::HashMap; "range": { "end": { "character": 0, - "line": 6 + "line": 7 }, "start": { "character": 0, @@ -418,15 +418,15 @@ fn main() {{}} #[test] fn preserves_dos_line_endings() { let server = Project::with_fixture( - &r#" + &" //- Cargo.toml [package] -name = "foo" -version = "0.0.0" +name = \"foo\" +version = \"0.0.0\" //- src/main.rs /// Some Docs\r\nfn main() {} -"#, +", ) .server(); -- cgit v1.2.3 From 4753409f86bf21b8d0ba7bd83918aa951921c97c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 19:05:44 +0300 Subject: refactor TryConvWith similar to ConvWith --- crates/ra_lsp_server/src/conv.rs | 68 +++++++++++++++------------------------- 1 file changed, 26 insertions(+), 42 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index bd1ffd8f5..1a70ec3a2 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -25,10 +25,9 @@ pub trait ConvWith { fn conv_with(self, ctx: CTX) -> Self::Output; } -pub trait TryConvWith { - type Ctx; +pub trait TryConvWith { type Output; - fn try_conv_with(self, ctx: &Self::Ctx) -> Result; + fn try_conv_with(self, ctx: CTX) -> Result; } impl Conv for SyntaxKind { @@ -235,48 +234,42 @@ impl, CTX> ConvWith for Option { } } -impl<'a> TryConvWith for &'a Url { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for &'_ Url { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { world.uri_to_file_id(self) } } -impl TryConvWith for FileId { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for FileId { type Output = Url; fn try_conv_with(self, world: &WorldSnapshot) -> Result { world.file_id_to_uri(self) } } -impl<'a> TryConvWith for &'a TextDocumentItem { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for &'_ TextDocumentItem { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { self.uri.try_conv_with(world) } } -impl<'a> TryConvWith for &'a VersionedTextDocumentIdentifier { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for &'_ VersionedTextDocumentIdentifier { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { self.uri.try_conv_with(world) } } -impl<'a> TryConvWith for &'a TextDocumentIdentifier { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for &'_ TextDocumentIdentifier { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { world.uri_to_file_id(&self.uri) } } -impl<'a> TryConvWith for &'a TextDocumentPositionParams { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for &'_ TextDocumentPositionParams { type Output = FilePosition; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let file_id = self.text_document.try_conv_with(world)?; @@ -286,8 +279,7 @@ impl<'a> TryConvWith for &'a TextDocumentPositionParams { } } -impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for (&'_ TextDocumentIdentifier, Range) { type Output = FileRange; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let file_id = self.0.try_conv_with(world)?; @@ -297,10 +289,9 @@ impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) { } } -impl TryConvWith for Vec { - type Ctx = ::Ctx; - type Output = Vec<::Output>; - fn try_conv_with(self, ctx: &Self::Ctx) -> Result { +impl, CTX: Copy> TryConvWith for Vec { + type Output = Vec<>::Output>; + fn try_conv_with(self, ctx: CTX) -> Result { let mut res = Vec::with_capacity(self.len()); for item in self { res.push(item.try_conv_with(ctx)?); @@ -309,8 +300,7 @@ impl TryConvWith for Vec { } } -impl TryConvWith for SourceChange { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for SourceChange { type Output = req::SourceChange; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let cursor_position = match self.cursor_position { @@ -349,8 +339,7 @@ impl TryConvWith for SourceChange { } } -impl TryConvWith for SourceFileEdit { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for SourceFileEdit { type Output = TextDocumentEdit; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let text_document = VersionedTextDocumentIdentifier { @@ -365,8 +354,7 @@ impl TryConvWith for SourceFileEdit { } } -impl TryConvWith for FileSystemEdit { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for FileSystemEdit { type Output = ResourceOp; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let res = match self { @@ -384,8 +372,7 @@ impl TryConvWith for FileSystemEdit { } } -impl TryConvWith for &NavigationTarget { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for &NavigationTarget { type Output = Location; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let line_index = world.analysis().file_line_index(self.file_id())?; @@ -394,8 +381,7 @@ impl TryConvWith for &NavigationTarget { } } -impl TryConvWith for (FileId, RangeInfo) { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for (FileId, RangeInfo) { type Output = LocationLink; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let (src_file_id, target) = self; @@ -422,8 +408,7 @@ impl TryConvWith for (FileId, RangeInfo) { } } -impl TryConvWith for (FileId, RangeInfo>) { - type Ctx = WorldSnapshot; +impl TryConvWith<&'_ WorldSnapshot> for (FileId, RangeInfo>) { type Output = req::GotoDefinitionResponse; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let (file_id, RangeInfo { range, info: navs }) = self; @@ -488,22 +473,21 @@ where } } -pub trait TryConvWithToVec<'a>: Sized + 'a { - type Ctx; +pub trait TryConvWithToVec: Sized { type Output; - fn try_conv_with_to_vec(self, ctx: &'a Self::Ctx) -> Result>; + fn try_conv_with_to_vec(self, ctx: CTX) -> Result>; } -impl<'a, I> TryConvWithToVec<'a> for I +impl TryConvWithToVec for I where - I: Iterator + 'a, - I::Item: TryConvWith, + I: Iterator, + I::Item: TryConvWith, + CTX: Copy, { - type Ctx = ::Ctx; - type Output = ::Output; + type Output = >::Output; - fn try_conv_with_to_vec(self, ctx: &'a Self::Ctx) -> Result> { + fn try_conv_with_to_vec(self, ctx: CTX) -> Result> { self.map(|it| it.try_conv_with(ctx)).collect() } } -- cgit v1.2.3 From 188c9967c0d0b6ab9acef5e879b5bbaf1a5035ed Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 19:06:22 +0300 Subject: Drop unnecessary `&'_` from impls --- crates/ra_lsp_server/src/conv.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 1a70ec3a2..818fa6d61 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -88,7 +88,7 @@ impl Conv for Severity { } } -impl ConvWith<(&'_ LineIndex, LineEndings)> for CompletionItem { +impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem { type Output = ::lsp_types::CompletionItem; fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> ::lsp_types::CompletionItem { @@ -136,7 +136,7 @@ impl ConvWith<(&'_ LineIndex, LineEndings)> for CompletionItem { } } -impl ConvWith<&'_ LineIndex> for Position { +impl ConvWith<&LineIndex> for Position { type Output = TextUnit; fn conv_with(self, line_index: &LineIndex) -> TextUnit { @@ -145,7 +145,7 @@ impl ConvWith<&'_ LineIndex> for Position { } } -impl ConvWith<&'_ LineIndex> for TextUnit { +impl ConvWith<&LineIndex> for TextUnit { type Output = Position; fn conv_with(self, line_index: &LineIndex) -> Position { @@ -154,7 +154,7 @@ impl ConvWith<&'_ LineIndex> for TextUnit { } } -impl ConvWith<&'_ LineIndex> for TextRange { +impl ConvWith<&LineIndex> for TextRange { type Output = Range; fn conv_with(self, line_index: &LineIndex) -> Range { @@ -162,7 +162,7 @@ impl ConvWith<&'_ LineIndex> for TextRange { } } -impl ConvWith<&'_ LineIndex> for Range { +impl ConvWith<&LineIndex> for Range { type Output = TextRange; fn conv_with(self, line_index: &LineIndex) -> TextRange { @@ -202,7 +202,7 @@ impl Conv for ra_ide_api::FunctionSignature { } } -impl ConvWith<(&'_ LineIndex, LineEndings)> for TextEdit { +impl ConvWith<(&LineIndex, LineEndings)> for TextEdit { type Output = Vec; fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> Vec { @@ -210,7 +210,7 @@ impl ConvWith<(&'_ LineIndex, LineEndings)> for TextEdit { } } -impl ConvWith<(&'_ LineIndex, LineEndings)> for &'_ AtomTextEdit { +impl ConvWith<(&LineIndex, LineEndings)> for &AtomTextEdit { type Output = lsp_types::TextEdit; fn conv_with( @@ -234,42 +234,42 @@ impl, CTX> ConvWith for Option { } } -impl TryConvWith<&'_ WorldSnapshot> for &'_ Url { +impl TryConvWith<&WorldSnapshot> for &Url { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { world.uri_to_file_id(self) } } -impl TryConvWith<&'_ WorldSnapshot> for FileId { +impl TryConvWith<&WorldSnapshot> for FileId { type Output = Url; fn try_conv_with(self, world: &WorldSnapshot) -> Result { world.file_id_to_uri(self) } } -impl TryConvWith<&'_ WorldSnapshot> for &'_ TextDocumentItem { +impl TryConvWith<&WorldSnapshot> for &TextDocumentItem { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { self.uri.try_conv_with(world) } } -impl TryConvWith<&'_ WorldSnapshot> for &'_ VersionedTextDocumentIdentifier { +impl TryConvWith<&WorldSnapshot> for &VersionedTextDocumentIdentifier { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { self.uri.try_conv_with(world) } } -impl TryConvWith<&'_ WorldSnapshot> for &'_ TextDocumentIdentifier { +impl TryConvWith<&WorldSnapshot> for &TextDocumentIdentifier { type Output = FileId; fn try_conv_with(self, world: &WorldSnapshot) -> Result { world.uri_to_file_id(&self.uri) } } -impl TryConvWith<&'_ WorldSnapshot> for &'_ TextDocumentPositionParams { +impl TryConvWith<&WorldSnapshot> for &TextDocumentPositionParams { type Output = FilePosition; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let file_id = self.text_document.try_conv_with(world)?; @@ -279,7 +279,7 @@ impl TryConvWith<&'_ WorldSnapshot> for &'_ TextDocumentPositionParams { } } -impl TryConvWith<&'_ WorldSnapshot> for (&'_ TextDocumentIdentifier, Range) { +impl TryConvWith<&WorldSnapshot> for (&TextDocumentIdentifier, Range) { type Output = FileRange; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let file_id = self.0.try_conv_with(world)?; @@ -300,7 +300,7 @@ impl, CTX: Copy> TryConvWith for Vec { } } -impl TryConvWith<&'_ WorldSnapshot> for SourceChange { +impl TryConvWith<&WorldSnapshot> for SourceChange { type Output = req::SourceChange; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let cursor_position = match self.cursor_position { @@ -339,7 +339,7 @@ impl TryConvWith<&'_ WorldSnapshot> for SourceChange { } } -impl TryConvWith<&'_ WorldSnapshot> for SourceFileEdit { +impl TryConvWith<&WorldSnapshot> for SourceFileEdit { type Output = TextDocumentEdit; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let text_document = VersionedTextDocumentIdentifier { @@ -354,7 +354,7 @@ impl TryConvWith<&'_ WorldSnapshot> for SourceFileEdit { } } -impl TryConvWith<&'_ WorldSnapshot> for FileSystemEdit { +impl TryConvWith<&WorldSnapshot> for FileSystemEdit { type Output = ResourceOp; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let res = match self { @@ -372,7 +372,7 @@ impl TryConvWith<&'_ WorldSnapshot> for FileSystemEdit { } } -impl TryConvWith<&'_ WorldSnapshot> for &NavigationTarget { +impl TryConvWith<&WorldSnapshot> for &NavigationTarget { type Output = Location; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let line_index = world.analysis().file_line_index(self.file_id())?; @@ -381,7 +381,7 @@ impl TryConvWith<&'_ WorldSnapshot> for &NavigationTarget { } } -impl TryConvWith<&'_ WorldSnapshot> for (FileId, RangeInfo) { +impl TryConvWith<&WorldSnapshot> for (FileId, RangeInfo) { type Output = LocationLink; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let (src_file_id, target) = self; @@ -408,7 +408,7 @@ impl TryConvWith<&'_ WorldSnapshot> for (FileId, RangeInfo) { } } -impl TryConvWith<&'_ WorldSnapshot> for (FileId, RangeInfo>) { +impl TryConvWith<&WorldSnapshot> for (FileId, RangeInfo>) { type Output = req::GotoDefinitionResponse; fn try_conv_with(self, world: &WorldSnapshot) -> Result { let (file_id, RangeInfo { range, info: navs }) = self; -- cgit v1.2.3 From bbeb07e5ca9f0c22e2e6f6ab33f350f24e8fff3f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 19:08:13 +0300 Subject: switch to upstream ra_vfs --- crates/ra_lsp_server/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 2c69a6993..afeac0d8a 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml @@ -16,7 +16,7 @@ lsp-types = { version = "0.60.0", features = ["proposed"] } rustc-hash = "1.0" parking_lot = "0.9.0" -ra_vfs = "0.2.0" +ra_vfs = "0.2.7" thread_worker = { path = "../thread_worker" } ra_syntax = { path = "../ra_syntax" } ra_text_edit = { path = "../ra_text_edit" } -- cgit v1.2.3 From 77751cfe01311d9e4fbb61c8dca352289499b3b7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 19:55:34 +0300 Subject: remove debug-print --- crates/ra_lsp_server/src/conv.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 818fa6d61..0ad2ea10f 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -217,7 +217,6 @@ impl ConvWith<(&LineIndex, LineEndings)> for &AtomTextEdit { self, (line_index, line_endings): (&LineIndex, LineEndings), ) -> lsp_types::TextEdit { - eprintln!("line_endings = {:?}", line_endings); let mut new_text = self.insert.clone(); if line_endings == LineEndings::Dos { new_text = new_text.replace('\n', "\r\n"); -- cgit v1.2.3