| 541 | } |
| 542 | |
| 543 | async fn goto_definition( |
| 544 | &self, |
| 545 | params: GotoDefinitionParams, |
| 546 | ) -> Result<Option<GotoDefinitionResponse>> { |
| 547 | let uri = params |
| 548 | .text_document_position_params |
| 549 | .text_document |
| 550 | .uri |
| 551 | .to_string(); |
| 552 | let position = params.text_document_position_params.position; |
| 553 | |
| 554 | let backend = self.clone_for_blocking(); |
| 555 | let uri_clone = uri.clone(); |
| 556 | tokio::task::spawn_blocking(move || { |
| 557 | backend.handle_with_position("goto_definition", &uri_clone, position, |content, pos| { |
| 558 | let locs = backend.resolve_definition(&uri_clone, content, pos); |
| 559 | if locs.is_empty() { |
| 560 | None |
| 561 | } else if locs.len() == 1 { |
| 562 | Some(GotoDefinitionResponse::Scalar( |
| 563 | backend.translate_location(locs[0].clone()), |
| 564 | )) |
| 565 | } else { |
| 566 | Some(GotoDefinitionResponse::Array( |
| 567 | locs.into_iter() |
| 568 | .map(|l| backend.translate_location(l)) |
| 569 | .collect(), |
| 570 | )) |
| 571 | } |
| 572 | }) |
| 573 | }) |
| 574 | .await |
| 575 | .unwrap_or(Ok(None)) |
| 576 | } |
| 577 | |
| 578 | async fn goto_implementation( |
| 579 | &self, |