| 1 | use serde::{Deserialize, Serialize}; |
| 2 | |
| 3 | use crate::{ |
| 4 | DynamicRegistrationClientCapabilities, PartialResultParams, Range, TextDocumentPositionParams, |
| 5 | WorkDoneProgressParams, |
| 6 | }; |
| 7 | |
| 8 | pub type DocumentHighlightClientCapabilities = DynamicRegistrationClientCapabilities; |
| 9 | |
| 10 | #[derive (Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] |
| 11 | #[serde(rename_all = "camelCase" )] |
| 12 | pub struct DocumentHighlightParams { |
| 13 | #[serde(flatten)] |
| 14 | pub text_document_position_params: TextDocumentPositionParams, |
| 15 | |
| 16 | #[serde(flatten)] |
| 17 | pub work_done_progress_params: WorkDoneProgressParams, |
| 18 | |
| 19 | #[serde(flatten)] |
| 20 | pub partial_result_params: PartialResultParams, |
| 21 | } |
| 22 | |
| 23 | /// A document highlight is a range inside a text document which deserves |
| 24 | /// special attention. Usually a document highlight is visualized by changing |
| 25 | /// the background color of its range. |
| 26 | #[derive (Debug, Eq, PartialEq, Clone, Deserialize, Serialize)] |
| 27 | pub struct DocumentHighlight { |
| 28 | /// The range this highlight applies to. |
| 29 | pub range: Range, |
| 30 | |
| 31 | /// The highlight kind, default is DocumentHighlightKind.Text. |
| 32 | #[serde(skip_serializing_if = "Option::is_none" )] |
| 33 | pub kind: Option<DocumentHighlightKind>, |
| 34 | } |
| 35 | |
| 36 | /// A document highlight kind. |
| 37 | #[derive (Eq, PartialEq, Copy, Clone, Deserialize, Serialize)] |
| 38 | #[serde(transparent)] |
| 39 | pub struct DocumentHighlightKind(i32); |
| 40 | lsp_enum! { |
| 41 | impl DocumentHighlightKind { |
| 42 | /// A textual occurrence. |
| 43 | pub const TEXT: DocumentHighlightKind = DocumentHighlightKind(1); |
| 44 | |
| 45 | /// Read-access of a symbol, like reading a variable. |
| 46 | pub const READ: DocumentHighlightKind = DocumentHighlightKind(2); |
| 47 | |
| 48 | /// Write-access of a symbol, like writing to a variable. |
| 49 | pub const WRITE: DocumentHighlightKind = DocumentHighlightKind(3); |
| 50 | } |
| 51 | } |
| 52 | |