diff options
Diffstat (limited to 'crates/rust-analyzer/src/to_proto.rs')
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 81a347247..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, |
@@ -274,6 +286,7 @@ fn semantic_token_type_and_modifiers( | |||
274 | HighlightTag::TypeAlias => semantic_tokens::TYPE_ALIAS, | 286 | HighlightTag::TypeAlias => semantic_tokens::TYPE_ALIAS, |
275 | HighlightTag::Trait => lsp_types::SemanticTokenType::INTERFACE, | 287 | HighlightTag::Trait => lsp_types::SemanticTokenType::INTERFACE, |
276 | HighlightTag::BuiltinType => semantic_tokens::BUILTIN_TYPE, | 288 | HighlightTag::BuiltinType => semantic_tokens::BUILTIN_TYPE, |
289 | HighlightTag::SelfKeyword => semantic_tokens::SELF_KEYWORD, | ||
277 | HighlightTag::SelfType => lsp_types::SemanticTokenType::TYPE, | 290 | HighlightTag::SelfType => lsp_types::SemanticTokenType::TYPE, |
278 | HighlightTag::Field => lsp_types::SemanticTokenType::PROPERTY, | 291 | HighlightTag::Field => lsp_types::SemanticTokenType::PROPERTY, |
279 | HighlightTag::Function => lsp_types::SemanticTokenType::FUNCTION, | 292 | HighlightTag::Function => lsp_types::SemanticTokenType::FUNCTION, |
@@ -391,13 +404,20 @@ pub(crate) fn location(world: &WorldSnapshot, frange: FileRange) -> Result<lsp_t | |||
391 | 404 | ||
392 | pub(crate) fn location_link( | 405 | pub(crate) fn location_link( |
393 | world: &WorldSnapshot, | 406 | world: &WorldSnapshot, |
394 | src: FileRange, | 407 | src: Option<FileRange>, |
395 | target: NavigationTarget, | 408 | target: NavigationTarget, |
396 | ) -> Result<lsp_types::LocationLink> { | 409 | ) -> Result<lsp_types::LocationLink> { |
397 | 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 | }; | ||
398 | 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)?; |
399 | let res = lsp_types::LocationLink { | 419 | let res = lsp_types::LocationLink { |
400 | origin_selection_range: Some(src_location.range), | 420 | origin_selection_range, |
401 | target_uri, | 421 | target_uri, |
402 | target_range, | 422 | target_range, |
403 | target_selection_range, | 423 | target_selection_range, |
@@ -420,7 +440,7 @@ fn location_info( | |||
420 | 440 | ||
421 | pub(crate) fn goto_definition_response( | 441 | pub(crate) fn goto_definition_response( |
422 | world: &WorldSnapshot, | 442 | world: &WorldSnapshot, |
423 | src: FileRange, | 443 | src: Option<FileRange>, |
424 | targets: Vec<NavigationTarget>, | 444 | targets: Vec<NavigationTarget>, |
425 | ) -> Result<lsp_types::GotoDefinitionResponse> { | 445 | ) -> Result<lsp_types::GotoDefinitionResponse> { |
426 | if world.config.client_caps.location_link { | 446 | if world.config.client_caps.location_link { |