1use crate::{
2 DocumentSelector, DynamicRegistrationClientCapabilities, PartialResultParams, Range,
3 TextDocumentIdentifier, TextEdit, WorkDoneProgressParams,
4};
5use serde::{Deserialize, Serialize};
6
7pub type DocumentColorClientCapabilities = DynamicRegistrationClientCapabilities;
8
9#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
10#[serde(rename_all = "camelCase")]
11pub struct ColorProviderOptions {}
12
13#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
14#[serde(rename_all = "camelCase")]
15pub struct StaticTextDocumentColorProviderOptions {
16 pub document_selector: Option<DocumentSelector>,
19
20 #[serde(skip_serializing_if = "Option::is_none")]
21 pub id: Option<String>,
22}
23
24#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
25#[serde(untagged)]
26pub enum ColorProviderCapability {
27 Simple(bool),
28 ColorProvider(ColorProviderOptions),
29 Options(StaticTextDocumentColorProviderOptions),
30}
31
32impl From<ColorProviderOptions> for ColorProviderCapability {
33 fn from(from: ColorProviderOptions) -> Self {
34 Self::ColorProvider(from)
35 }
36}
37
38impl From<StaticTextDocumentColorProviderOptions> for ColorProviderCapability {
39 fn from(from: StaticTextDocumentColorProviderOptions) -> Self {
40 Self::Options(from)
41 }
42}
43
44impl From<bool> for ColorProviderCapability {
45 fn from(from: bool) -> Self {
46 Self::Simple(from)
47 }
48}
49
50#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
51#[serde(rename_all = "camelCase")]
52pub struct DocumentColorParams {
53 pub text_document: TextDocumentIdentifier,
55
56 #[serde(flatten)]
57 pub work_done_progress_params: WorkDoneProgressParams,
58
59 #[serde(flatten)]
60 pub partial_result_params: PartialResultParams,
61}
62
63#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
64#[serde(rename_all = "camelCase")]
65pub struct ColorInformation {
66 pub range: Range,
68 pub color: Color,
70}
71
72#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, Copy)]
73#[serde(rename_all = "camelCase")]
74pub struct Color {
75 pub red: f32,
77 pub green: f32,
79 pub blue: f32,
81 pub alpha: f32,
83}
84
85#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
86#[serde(rename_all = "camelCase")]
87pub struct ColorPresentationParams {
88 pub text_document: TextDocumentIdentifier,
90
91 pub color: Color,
93
94 pub range: Range,
96
97 #[serde(flatten)]
98 pub work_done_progress_params: WorkDoneProgressParams,
99
100 #[serde(flatten)]
101 pub partial_result_params: PartialResultParams,
102}
103
104#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, Default, Clone)]
105#[serde(rename_all = "camelCase")]
106pub struct ColorPresentation {
107 pub label: String,
111
112 #[serde(skip_serializing_if = "Option::is_none")]
116 pub text_edit: Option<TextEdit>,
117
118 #[serde(skip_serializing_if = "Option::is_none")]
121 pub additional_text_edits: Option<Vec<TextEdit>>,
122}