diff options
Diffstat (limited to 'crates/rust-analyzer/src/to_proto.rs')
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index ebaad4d19..8e8e7033d 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -135,6 +135,18 @@ pub(crate) fn text_edit_vec( | |||
135 | text_edit.into_iter().map(|indel| self::text_edit(line_index, line_endings, indel)).collect() | 135 | text_edit.into_iter().map(|indel| self::text_edit(line_index, line_endings, indel)).collect() |
136 | } | 136 | } |
137 | 137 | ||
138 | pub(crate) fn snippet_text_edit_vec( | ||
139 | line_index: &LineIndex, | ||
140 | line_endings: LineEndings, | ||
141 | is_snippet: bool, | ||
142 | text_edit: TextEdit, | ||
143 | ) -> Vec<lsp_ext::SnippetTextEdit> { | ||
144 | text_edit | ||
145 | .into_iter() | ||
146 | .map(|indel| self::snippet_text_edit(line_index, line_endings, is_snippet, indel)) | ||
147 | .collect() | ||
148 | } | ||
149 | |||
138 | pub(crate) fn completion_item( | 150 | pub(crate) fn completion_item( |
139 | line_index: &LineIndex, | 151 | line_index: &LineIndex, |
140 | line_endings: LineEndings, | 152 | line_endings: LineEndings, |
@@ -392,13 +404,20 @@ pub(crate) fn location(world: &WorldSnapshot, frange: FileRange) -> Result<lsp_t | |||
392 | 404 | ||
393 | pub(crate) fn location_link( | 405 | pub(crate) fn location_link( |
394 | world: &WorldSnapshot, | 406 | world: &WorldSnapshot, |
395 | src: FileRange, | 407 | src: Option<FileRange>, |
396 | target: NavigationTarget, | 408 | target: NavigationTarget, |
397 | ) -> Result<lsp_types::LocationLink> { | 409 | ) -> Result<lsp_types::LocationLink> { |
398 | let src_location = location(world, src)?; | 410 | let origin_selection_range = match src { |
411 | Some(src) => { | ||
412 | let line_index = world.analysis().file_line_index(src.file_id)?; | ||
413 | let range = range(&line_index, src.range); | ||
414 | Some(range) | ||
415 | } | ||
416 | None => None, | ||
417 | }; | ||
399 | let (target_uri, target_range, target_selection_range) = location_info(world, target)?; | 418 | let (target_uri, target_range, target_selection_range) = location_info(world, target)?; |
400 | let res = lsp_types::LocationLink { | 419 | let res = lsp_types::LocationLink { |
401 | origin_selection_range: Some(src_location.range), | 420 | origin_selection_range, |
402 | target_uri, | 421 | target_uri, |
403 | target_range, | 422 | target_range, |
404 | target_selection_range, | 423 | target_selection_range, |
@@ -421,7 +440,7 @@ fn location_info( | |||
421 | 440 | ||
422 | pub(crate) fn goto_definition_response( | 441 | pub(crate) fn goto_definition_response( |
423 | world: &WorldSnapshot, | 442 | world: &WorldSnapshot, |
424 | src: FileRange, | 443 | src: Option<FileRange>, |
425 | targets: Vec<NavigationTarget>, | 444 | targets: Vec<NavigationTarget>, |
426 | ) -> Result<lsp_types::GotoDefinitionResponse> { | 445 | ) -> Result<lsp_types::GotoDefinitionResponse> { |
427 | if world.config.client_caps.location_link { | 446 | if world.config.client_caps.location_link { |