1use serde::{Deserialize, Serialize};
2
3use crate::{
4 PartialResultParams, Position, Range, StaticTextDocumentRegistrationOptions,
5 TextDocumentIdentifier, WorkDoneProgressOptions, WorkDoneProgressParams,
6};
7#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
8#[serde(rename_all = "camelCase")]
9pub struct SelectionRangeClientCapabilities {
10 /// Whether implementation supports dynamic registration for selection range
11 /// providers. If this is set to `true` the client supports the new
12 /// `SelectionRangeRegistrationOptions` return value for the corresponding
13 /// server capability as well.
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub dynamic_registration: Option<bool>,
16}
17
18#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
19pub struct SelectionRangeOptions {
20 #[serde(flatten)]
21 pub work_done_progress_options: WorkDoneProgressOptions,
22}
23
24#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
25pub struct SelectionRangeRegistrationOptions {
26 #[serde(flatten)]
27 pub selection_range_options: SelectionRangeOptions,
28
29 #[serde(flatten)]
30 pub registration_options: StaticTextDocumentRegistrationOptions,
31}
32
33#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
34#[serde(untagged)]
35pub enum SelectionRangeProviderCapability {
36 Simple(bool),
37 Options(SelectionRangeOptions),
38 RegistrationOptions(SelectionRangeRegistrationOptions),
39}
40
41impl From<SelectionRangeRegistrationOptions> for SelectionRangeProviderCapability {
42 fn from(from: SelectionRangeRegistrationOptions) -> Self {
43 Self::RegistrationOptions(from)
44 }
45}
46
47impl From<SelectionRangeOptions> for SelectionRangeProviderCapability {
48 fn from(from: SelectionRangeOptions) -> Self {
49 Self::Options(from)
50 }
51}
52
53impl From<bool> for SelectionRangeProviderCapability {
54 fn from(from: bool) -> Self {
55 Self::Simple(from)
56 }
57}
58
59/// A parameter literal used in selection range requests.
60#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
61#[serde(rename_all = "camelCase")]
62pub struct SelectionRangeParams {
63 /// The text document.
64 pub text_document: TextDocumentIdentifier,
65
66 /// The positions inside the text document.
67 pub positions: Vec<Position>,
68
69 #[serde(flatten)]
70 pub work_done_progress_params: WorkDoneProgressParams,
71
72 #[serde(flatten)]
73 pub partial_result_params: PartialResultParams,
74}
75
76/// Represents a selection range.
77#[derive(Debug, Eq, PartialEq, Clone, Default, Deserialize, Serialize)]
78#[serde(rename_all = "camelCase")]
79pub struct SelectionRange {
80 /// Range of the selection.
81 pub range: Range,
82
83 /// The parent selection range containing this range.
84 #[serde(skip_serializing_if = "Option::is_none")]
85 pub parent: Option<Box<SelectionRange>>,
86}
87