aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/conv.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-25 18:32:17 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-25 18:32:17 +0100
commitceb16591deef2190daaf5eb9a6480f20dc5d169c (patch)
tree47edb8102902df9e291d5d0c8274ef1388546d03 /crates/ra_lsp_server/src/conv.rs
parenta8e37ddbc8fa666105a5eca8e2dc9f261d8934e8 (diff)
parentdbbb0beb3ec9f11a635f43e60f3b3a42ba61338a (diff)
Merge #1591
1591: Make Analysis api cancellable r=matklad a=SomeoneToIgnore Based on the discussion from here: https://github.com/rust-analyzer/rust-analyzer/pull/1549#discussion_r305593236 Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/conv.rs')
-rw-r--r--crates/ra_lsp_server/src/conv.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index 82c7e757f..6b3be444f 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -272,7 +272,7 @@ impl<'a> TryConvWith for &'a TextDocumentPositionParams {
272 type Output = FilePosition; 272 type Output = FilePosition;
273 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FilePosition> { 273 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FilePosition> {
274 let file_id = self.text_document.try_conv_with(world)?; 274 let file_id = self.text_document.try_conv_with(world)?;
275 let line_index = world.analysis().file_line_index(file_id); 275 let line_index = world.analysis().file_line_index(file_id)?;
276 let offset = self.position.conv_with(&line_index); 276 let offset = self.position.conv_with(&line_index);
277 Ok(FilePosition { file_id, offset }) 277 Ok(FilePosition { file_id, offset })
278 } 278 }
@@ -283,7 +283,7 @@ impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) {
283 type Output = FileRange; 283 type Output = FileRange;
284 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileRange> { 284 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileRange> {
285 let file_id = self.0.try_conv_with(world)?; 285 let file_id = self.0.try_conv_with(world)?;
286 let line_index = world.analysis().file_line_index(file_id); 286 let line_index = world.analysis().file_line_index(file_id)?;
287 let range = self.1.conv_with(&line_index); 287 let range = self.1.conv_with(&line_index);
288 Ok(FileRange { file_id, range }) 288 Ok(FileRange { file_id, range })
289 } 289 }
@@ -308,7 +308,7 @@ impl TryConvWith for SourceChange {
308 let cursor_position = match self.cursor_position { 308 let cursor_position = match self.cursor_position {
309 None => None, 309 None => None,
310 Some(pos) => { 310 Some(pos) => {
311 let line_index = world.analysis().file_line_index(pos.file_id); 311 let line_index = world.analysis().file_line_index(pos.file_id)?;
312 let edit = self 312 let edit = self
313 .source_file_edits 313 .source_file_edits
314 .iter() 314 .iter()
@@ -349,7 +349,7 @@ impl TryConvWith for SourceFileEdit {
349 uri: self.file_id.try_conv_with(world)?, 349 uri: self.file_id.try_conv_with(world)?,
350 version: None, 350 version: None,
351 }; 351 };
352 let line_index = world.analysis().file_line_index(self.file_id); 352 let line_index = world.analysis().file_line_index(self.file_id)?;
353 let edits = self.edit.as_atoms().iter().map_conv_with(&line_index).collect(); 353 let edits = self.edit.as_atoms().iter().map_conv_with(&line_index).collect();
354 Ok(TextDocumentEdit { text_document, edits }) 354 Ok(TextDocumentEdit { text_document, edits })
355 } 355 }
@@ -378,7 +378,7 @@ impl TryConvWith for &NavigationTarget {
378 type Ctx = WorldSnapshot; 378 type Ctx = WorldSnapshot;
379 type Output = Location; 379 type Output = Location;
380 fn try_conv_with(self, world: &WorldSnapshot) -> Result<Location> { 380 fn try_conv_with(self, world: &WorldSnapshot) -> Result<Location> {
381 let line_index = world.analysis().file_line_index(self.file_id()); 381 let line_index = world.analysis().file_line_index(self.file_id())?;
382 let range = self.range(); 382 let range = self.range();
383 to_location(self.file_id(), range, &world, &line_index) 383 to_location(self.file_id(), range, &world, &line_index)
384 } 384 }
@@ -391,8 +391,8 @@ impl TryConvWith for (FileId, RangeInfo<NavigationTarget>) {
391 let (src_file_id, target) = self; 391 let (src_file_id, target) = self;
392 392
393 let target_uri = target.info.file_id().try_conv_with(world)?; 393 let target_uri = target.info.file_id().try_conv_with(world)?;
394 let src_line_index = world.analysis().file_line_index(src_file_id); 394 let src_line_index = world.analysis().file_line_index(src_file_id)?;
395 let tgt_line_index = world.analysis().file_line_index(target.info.file_id()); 395 let tgt_line_index = world.analysis().file_line_index(target.info.file_id())?;
396 396
397 let target_range = target.info.full_range().conv_with(&tgt_line_index); 397 let target_range = target.info.full_range().conv_with(&tgt_line_index);
398 398