diff options
author | DJMcNab <[email protected]> | 2018-12-31 11:08:44 +0000 |
---|---|---|
committer | DJMcNab <[email protected]> | 2018-12-31 11:08:44 +0000 |
commit | 79941a9e701c6be849d40cb43744f1e2fee56354 (patch) | |
tree | 9b2d5cad4d9284fdf949e5fb5a97559685b4de62 /crates/ra_lsp_server/src/main_loop/handlers.rs | |
parent | f9b58454a43274d3b1d4d0e74cdef597b75f9a97 (diff) |
Implement DocumentHighlight
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index a2c12a4c1..60441e8ea 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -6,9 +6,8 @@ use languageserver_types::{ | |||
6 | DiagnosticSeverity, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, | 6 | DiagnosticSeverity, DocumentSymbol, Documentation, FoldingRange, FoldingRangeKind, |
7 | FoldingRangeParams, Location, MarkupContent, MarkupKind, MarkedString, Position, | 7 | FoldingRangeParams, Location, MarkupContent, MarkupKind, MarkedString, Position, |
8 | PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, | 8 | PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, |
9 | Range, | 9 | Range, WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, |
10 | WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, | 10 | HoverContents, DocumentFormattingParams, DocumentHighlight, |
11 | DocumentFormattingParams, | ||
12 | }; | 11 | }; |
13 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FileRange, FilePosition, Severity}; | 12 | use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FileRange, FilePosition, Severity}; |
14 | use ra_syntax::{TextUnit, text_utils::intersect}; | 13 | use ra_syntax::{TextUnit, text_utils::intersect}; |
@@ -673,6 +672,28 @@ pub fn handle_code_action( | |||
673 | Ok(Some(CodeActionResponse::Commands(res))) | 672 | Ok(Some(CodeActionResponse::Commands(res))) |
674 | } | 673 | } |
675 | 674 | ||
675 | pub fn handle_document_highlight( | ||
676 | world: ServerWorld, | ||
677 | params: req::TextDocumentPositionParams, | ||
678 | ) -> Result<Option<Vec<DocumentHighlight>>> { | ||
679 | let file_id = params.text_document.try_conv_with(&world)?; | ||
680 | let line_index = world.analysis().file_line_index(file_id); | ||
681 | let offset = params.position.conv_with(&line_index); | ||
682 | |||
683 | let refs = world | ||
684 | .analysis() | ||
685 | .find_all_refs(FilePosition { file_id, offset })?; | ||
686 | |||
687 | Ok(Some( | ||
688 | refs.into_iter() | ||
689 | .map(|r| DocumentHighlight { | ||
690 | range: r.1.conv_with(&line_index), | ||
691 | kind: None, | ||
692 | }) | ||
693 | .collect(), | ||
694 | )) | ||
695 | } | ||
696 | |||
676 | pub fn publish_diagnostics( | 697 | pub fn publish_diagnostics( |
677 | world: &ServerWorld, | 698 | world: &ServerWorld, |
678 | file_id: FileId, | 699 | file_id: FileId, |