aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/conv.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/conv.rs')
-rw-r--r--crates/ra_lsp_server/src/conv.rs50
1 files changed, 25 insertions, 25 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs
index 1b349d02a..88d29b256 100644
--- a/crates/ra_lsp_server/src/conv.rs
+++ b/crates/ra_lsp_server/src/conv.rs
@@ -12,7 +12,7 @@ use ra_ide_api::{
12use ra_syntax::{SyntaxKind, TextRange, TextUnit}; 12use ra_syntax::{SyntaxKind, TextRange, TextUnit};
13use ra_text_edit::{AtomTextEdit, TextEdit}; 13use ra_text_edit::{AtomTextEdit, TextEdit};
14 14
15use crate::{req, server_world::ServerWorld, Result}; 15use crate::{req, world::WorldSnapshot, Result};
16 16
17pub trait Conv { 17pub trait Conv {
18 type Output; 18 type Output;
@@ -228,49 +228,49 @@ impl<T: ConvWith> ConvWith for Option<T> {
228} 228}
229 229
230impl<'a> TryConvWith for &'a Url { 230impl<'a> TryConvWith for &'a Url {
231 type Ctx = ServerWorld; 231 type Ctx = WorldSnapshot;
232 type Output = FileId; 232 type Output = FileId;
233 fn try_conv_with(self, world: &ServerWorld) -> Result<FileId> { 233 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileId> {
234 world.uri_to_file_id(self) 234 world.uri_to_file_id(self)
235 } 235 }
236} 236}
237 237
238impl TryConvWith for FileId { 238impl TryConvWith for FileId {
239 type Ctx = ServerWorld; 239 type Ctx = WorldSnapshot;
240 type Output = Url; 240 type Output = Url;
241 fn try_conv_with(self, world: &ServerWorld) -> Result<Url> { 241 fn try_conv_with(self, world: &WorldSnapshot) -> Result<Url> {
242 world.file_id_to_uri(self) 242 world.file_id_to_uri(self)
243 } 243 }
244} 244}
245 245
246impl<'a> TryConvWith for &'a TextDocumentItem { 246impl<'a> TryConvWith for &'a TextDocumentItem {
247 type Ctx = ServerWorld; 247 type Ctx = WorldSnapshot;
248 type Output = FileId; 248 type Output = FileId;
249 fn try_conv_with(self, world: &ServerWorld) -> Result<FileId> { 249 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileId> {
250 self.uri.try_conv_with(world) 250 self.uri.try_conv_with(world)
251 } 251 }
252} 252}
253 253
254impl<'a> TryConvWith for &'a VersionedTextDocumentIdentifier { 254impl<'a> TryConvWith for &'a VersionedTextDocumentIdentifier {
255 type Ctx = ServerWorld; 255 type Ctx = WorldSnapshot;
256 type Output = FileId; 256 type Output = FileId;
257 fn try_conv_with(self, world: &ServerWorld) -> Result<FileId> { 257 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileId> {
258 self.uri.try_conv_with(world) 258 self.uri.try_conv_with(world)
259 } 259 }
260} 260}
261 261
262impl<'a> TryConvWith for &'a TextDocumentIdentifier { 262impl<'a> TryConvWith for &'a TextDocumentIdentifier {
263 type Ctx = ServerWorld; 263 type Ctx = WorldSnapshot;
264 type Output = FileId; 264 type Output = FileId;
265 fn try_conv_with(self, world: &ServerWorld) -> Result<FileId> { 265 fn try_conv_with(self, world: &WorldSnapshot) -> Result<FileId> {
266 world.uri_to_file_id(&self.uri) 266 world.uri_to_file_id(&self.uri)
267 } 267 }
268} 268}
269 269
270impl<'a> TryConvWith for &'a TextDocumentPositionParams { 270impl<'a> TryConvWith for &'a TextDocumentPositionParams {
271 type Ctx = ServerWorld; 271 type Ctx = WorldSnapshot;
272 type Output = FilePosition; 272 type Output = FilePosition;
273 fn try_conv_with(self, world: &ServerWorld) -> 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);
@@ -279,9 +279,9 @@ impl<'a> TryConvWith for &'a TextDocumentPositionParams {
279} 279}
280 280
281impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) { 281impl<'a> TryConvWith for (&'a TextDocumentIdentifier, Range) {
282 type Ctx = ServerWorld; 282 type Ctx = WorldSnapshot;
283 type Output = FileRange; 283 type Output = FileRange;
284 fn try_conv_with(self, world: &ServerWorld) -> 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);
@@ -302,9 +302,9 @@ impl<T: TryConvWith> TryConvWith for Vec<T> {
302} 302}
303 303
304impl TryConvWith for SourceChange { 304impl TryConvWith for SourceChange {
305 type Ctx = ServerWorld; 305 type Ctx = WorldSnapshot;
306 type Output = req::SourceChange; 306 type Output = req::SourceChange;
307 fn try_conv_with(self, world: &ServerWorld) -> Result<req::SourceChange> { 307 fn try_conv_with(self, world: &WorldSnapshot) -> Result<req::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) => {
@@ -342,9 +342,9 @@ impl TryConvWith for SourceChange {
342} 342}
343 343
344impl TryConvWith for SourceFileEdit { 344impl TryConvWith for SourceFileEdit {
345 type Ctx = ServerWorld; 345 type Ctx = WorldSnapshot;
346 type Output = TextDocumentEdit; 346 type Output = TextDocumentEdit;
347 fn try_conv_with(self, world: &ServerWorld) -> Result<TextDocumentEdit> { 347 fn try_conv_with(self, world: &WorldSnapshot) -> Result<TextDocumentEdit> {
348 let text_document = VersionedTextDocumentIdentifier { 348 let text_document = VersionedTextDocumentIdentifier {
349 uri: self.file_id.try_conv_with(world)?, 349 uri: self.file_id.try_conv_with(world)?,
350 version: None, 350 version: None,
@@ -356,9 +356,9 @@ impl TryConvWith for SourceFileEdit {
356} 356}
357 357
358impl TryConvWith for FileSystemEdit { 358impl TryConvWith for FileSystemEdit {
359 type Ctx = ServerWorld; 359 type Ctx = WorldSnapshot;
360 type Output = ResourceOp; 360 type Output = ResourceOp;
361 fn try_conv_with(self, world: &ServerWorld) -> Result<ResourceOp> { 361 fn try_conv_with(self, world: &WorldSnapshot) -> Result<ResourceOp> {
362 let res = match self { 362 let res = match self {
363 FileSystemEdit::CreateFile { source_root, path } => { 363 FileSystemEdit::CreateFile { source_root, path } => {
364 let uri = world.path_to_uri(source_root, &path)?; 364 let uri = world.path_to_uri(source_root, &path)?;
@@ -375,9 +375,9 @@ impl TryConvWith for FileSystemEdit {
375} 375}
376 376
377impl TryConvWith for &NavigationTarget { 377impl TryConvWith for &NavigationTarget {
378 type Ctx = ServerWorld; 378 type Ctx = WorldSnapshot;
379 type Output = Location; 379 type Output = Location;
380 fn try_conv_with(self, world: &ServerWorld) -> 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)
@@ -386,7 +386,7 @@ impl TryConvWith for &NavigationTarget {
386 386
387pub fn to_location_link( 387pub fn to_location_link(
388 target: &RangeInfo<NavigationTarget>, 388 target: &RangeInfo<NavigationTarget>,
389 world: &ServerWorld, 389 world: &WorldSnapshot,
390 // line index for original range file 390 // line index for original range file
391 line_index: &LineIndex, 391 line_index: &LineIndex,
392) -> Result<LocationLink> { 392) -> Result<LocationLink> {
@@ -410,7 +410,7 @@ pub fn to_location_link(
410pub fn to_location( 410pub fn to_location(
411 file_id: FileId, 411 file_id: FileId,
412 range: TextRange, 412 range: TextRange,
413 world: &ServerWorld, 413 world: &WorldSnapshot,
414 line_index: &LineIndex, 414 line_index: &LineIndex,
415) -> Result<Location> { 415) -> Result<Location> {
416 let url = file_id.try_conv_with(world)?; 416 let url = file_id.try_conv_with(world)?;