1use oak_core::language::UniversalElementRole;
2use serde::{Deserialize, Serialize};
3
4pub use core::range::Range;
5pub use oak_folding::{FoldingRange, FoldingRangeKind};
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub struct Position {
9 pub line: u32,
10 pub character: u32,
11}
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
14pub struct LspRange {
15 pub start: Position,
16 pub end: Position,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
22#[serde(bound(serialize = "R: Serialize", deserialize = "R: Deserialize<'de>"))]
23pub struct Location<R = Range<usize>> {
24 pub uri: String,
25 pub range: R,
26}
27
28#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
30pub struct LocationRange {
31 pub uri: String,
32 #[serde(with = "oak_core::serde_range")]
33 pub range: Range<usize>,
34}
35
36impl From<LocationRange> for Location<Range<usize>> {
37 fn from(loc: LocationRange) -> Self {
38 Self { uri: loc.uri, range: loc.range }
39 }
40}
41
42impl From<Location<Range<usize>>> for LocationRange {
43 fn from(loc: Location<Range<usize>>) -> Self {
44 Self { uri: loc.uri, range: loc.range }
45 }
46}
47
48#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
52pub enum DocumentHighlightKind {
53 Text = 1,
54 Read = 2,
55 Write = 3,
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
59pub struct DocumentHighlight {
60 pub range: LspRange,
61 pub kind: Option<DocumentHighlightKind>,
62}
63
64#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
66pub struct Color {
67 pub red: f32,
68 pub green: f32,
69 pub blue: f32,
70 pub alpha: f32,
71}
72
73#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
75pub struct ColorInformation {
76 pub range: LspRange,
77 pub color: Color,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
82pub struct Hover {
83 pub contents: String,
85 #[serde(with = "oak_core::serde_range::option")]
87 pub range: Option<Range<usize>>,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
92pub struct StructureItem {
93 pub name: String,
95 pub detail: Option<String>,
97 pub role: UniversalElementRole,
99 pub kind: SymbolKind,
101 #[serde(with = "oak_core::serde_range")]
103 pub range: Range<usize>,
104 #[serde(with = "oak_core::serde_range")]
107 pub selection_range: Range<usize>,
108 pub deprecated: bool,
110 pub children: Vec<StructureItem>,
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize, Default)]
116pub struct InitializeParams {
117 pub root_uri: Option<String>,
118 pub workspace_folders: Vec<WorkspaceFolder>,
119}
120
121#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct WorkspaceFolder {
124 pub uri: String,
125 pub name: String,
126}
127
128#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
130pub enum SymbolKind {
131 File = 1,
132 Module = 2,
133 Namespace = 3,
134 Package = 4,
135 Class = 5,
136 Method = 6,
137 Property = 7,
138 Field = 8,
139 Constructor = 9,
140 Enum = 10,
141 Interface = 11,
142 Function = 12,
143 Variable = 13,
144 Constant = 14,
145 String = 15,
146 Number = 16,
147 Boolean = 17,
148 Array = 18,
149 Object = 19,
150 Key = 20,
151 Null = 21,
152 EnumMember = 22,
153 Struct = 23,
154 Event = 24,
155 Operator = 25,
156 TypeParameter = 26,
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize)]
161pub struct WorkspaceSymbol {
162 pub name: String,
164 pub kind: SymbolKind,
166 pub location: LocationRange,
168 pub container_name: Option<String>,
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize)]
174pub struct SymbolInformation {
175 pub name: String,
177 pub kind: SymbolKind,
179 pub location: LocationRange,
181 pub container_name: Option<String>,
183}
184
185#[derive(Debug, Clone, Default, Serialize, Deserialize)]
187pub struct WorkspaceEdit {
188 pub changes: std::collections::HashMap<String, Vec<TextEdit>>,
190}
191
192#[derive(Debug, Clone, Serialize, Deserialize)]
194pub struct TextEdit {
195 #[serde(with = "oak_core::serde_range")]
197 pub range: Range<usize>,
198 pub new_text: String,
200}
201
202#[derive(Debug, Clone, Serialize, Deserialize)]
204pub struct CompletionItem {
205 pub label: String,
207 pub kind: Option<CompletionItemKind>,
209 pub detail: Option<String>,
211 pub documentation: Option<String>,
213 pub insert_text: Option<String>,
215}
216
217#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
219pub enum CompletionItemKind {
220 Text = 1,
221 Method = 2,
222 Function = 3,
223 Constructor = 4,
224 Field = 5,
225 Variable = 6,
226 Class = 7,
227 Interface = 8,
228 Module = 9,
229 Property = 10,
230 Unit = 11,
231 Value = 12,
232 Enum = 13,
233 Keyword = 14,
234 Snippet = 15,
235 Color = 16,
236 File = 17,
237 Reference = 18,
238 Folder = 19,
239 EnumMember = 20,
240 Constant = 21,
241 Struct = 22,
242 Event = 23,
243 Operator = 24,
244 TypeParameter = 25,
245}
246
247#[derive(Debug, Clone, Serialize, Deserialize)]
249pub struct Diagnostic {
250 #[serde(with = "oak_core::serde_range")]
252 pub range: Range<usize>,
253 pub severity: Option<DiagnosticSeverity>,
255 pub code: Option<String>,
257 pub source: Option<String>,
259 pub message: String,
261}
262
263#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
265pub enum DiagnosticSeverity {
266 Error = 1,
267 Warning = 2,
268 Information = 3,
269 Hint = 4,
270}