strop-lsp 0.34.0

strop lsp: async-lsp client, server registry, diagnostics store
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
//! Request admission and the common launcher. Every admitted request
//! ends in exactly one terminal event (R9) — success, empty, error or
//! cancellation — carrying its ORIGINAL stamp and negotiated encoding
use crate::protocol::*;
use std::path::PathBuf;
use strop_core::id::{BufferRevision, ByteColumn, DocumentId, LineIndex};
use strop_workspace::ResourceLocation;

use super::queue::{WireEnv, WireJob, RETRY_DELAY};
use super::sync;
use super::wire::{self, is_content_modified};
use super::{Client, SwitchSourceHeader};
use crate::convert::hover_text;
use async_lsp::lsp_types as lt;

impl Client {
    /// Admit a request against the current open state without sending
    /// anything: the pure half of the replay tape's `lsp.prepare`.
    /// `Ok` carries the owning stamp and captured input; `Err` means
    /// nothing was sent and nothing will arrive.
    pub fn prepare_request(&self, input: RequestInput) -> Result<PendingRequest, RequestRefusal> {
        let state = self.sync.lock();
        let Some(open) = state.documents.get(&input.path) else {
            return Err(RequestRefusal::NotOpen);
        };
        if open.document != input.document || open.revision != input.revision {
            return Err(RequestRefusal::StaleRevision);
        }
        if state.ready && !self.caps.supports(input.kind) {
            return Err(RequestRefusal::Unsupported);
        }
        let request = match self.next_request.fetch_update(
            std::sync::atomic::Ordering::Relaxed,
            std::sync::atomic::Ordering::Relaxed,
            |n| n.checked_add(1),
        ) {
            Ok(value) => value,
            Err(_) => return Err(RequestRefusal::IdentityExhausted),
        };
        let stamp = RequestStamp {
            request: RequestId::new(request),
            server: self.id,
            document: input.document,
            revision: input.revision,
        };
        Ok(PendingRequest {
            stamp,
            input,
            tab_width: None,
        })
    }

    /// Launch an admitted request: onto the ordered wire when ready,
    /// else the pre-init queue flushed by `finish_initialize`. A launch
    /// that cannot be admitted still ends in exactly one terminal event
    /// (R9): an explicit cancellation note.
    pub fn launch_request(&self, request: PendingRequest) {
        let context = ReplyContext {
            stamp: request.stamp,
            encoding: self.caps.encoding(),
            kind: request.input.kind,
        };
        let mut state = self.sync.lock();
        if state.ready {
            if self.queue.send(WireJob::Request(request)) == super::queue::Admission::Refused {
                let _ = self.tx.send(LspEvent::Note {
                    context,
                    text: "cancelled — the server's wire queue is full".into(),
                });
            }
        } else if state.pending_requests.len() >= super::sync::MAX_PENDING_REQUESTS {
            let _ = self.tx.send(LspEvent::Note {
                context,
                text: "cancelled — too many requests pending server startup".into(),
            });
        } else {
            state.pending_requests.push(request);
        }
    }

    /// Workspace-wide symbol query (0063 §2): document-free admission
    /// — no open document, no revision stamp. Only a warm server that
    /// advertises the provider admits; the reply carries the caller's
    /// `generation` for ownership (stale generations drop silently at
    /// the consumer, never cancel mid-wire).
    pub fn workspace_symbols(&self, generation: u64, query: &str) -> Result<(), RequestRefusal> {
        {
            let state = self.sync.lock();
            if !state.ready {
                return Err(RequestRefusal::NotReady);
            }
        }
        if !self.caps.supports(RequestKind::WorkspaceSymbols) {
            return Err(RequestRefusal::Unsupported);
        }
        if self.queue.send(WireJob::WorkspaceSymbols {
            generation,
            query: query.to_string(),
        }) == super::queue::Admission::Refused
        {
            // Refusal before admission is visible (AR06): the caller
            // gets a typed refusal, the query was never on the wire.
            return Err(RequestRefusal::Overloaded);
        }
        Ok(())
    }

    /// Prepare and launch in one step for callers outside the tape
    /// seam (the probe example).
    pub fn request(&self, input: RequestInput) -> Result<RequestStamp, RequestRefusal> {
        let request = self.prepare_request(input)?;
        let stamp = request.stamp;
        self.launch_request(request);
        Ok(stamp)
    }

    /// Formatting admission: no cursor position — the input records
    /// document identity only, and the tab width rides the admission
    /// record so a replay relaunches the identical payload.
    pub fn format(
        &self,
        document: DocumentId,
        revision: BufferRevision,
        path: PathBuf,
        tab_width: usize,
    ) -> Result<RequestStamp, RequestRefusal> {
        let mut request = self.prepare_request(RequestInput {
            document,
            revision,
            path,
            line: LineIndex::new(0),
            byte_col: ByteColumn::new(0),
            line_text: crate::FrozenLine::from(""),
            kind: RequestKind::Format,
            rename_to: None,
        })?;
        request.tab_width = Some(tab_width);
        let stamp = request.stamp;
        self.launch_request(request);
        Ok(stamp)
    }

    /// Rename admission: the new name is recorded on the input so the
    /// replay tape relaunches against the identical payload.
    pub fn rename(
        &self,
        mut input: RequestInput,
        new_name: &str,
    ) -> Result<RequestStamp, RequestRefusal> {
        input.rename_to = Some(new_name.to_owned());
        self.request(input)
    }

    /// Code-action admission at the input's position.
    pub fn code_actions(&self, input: RequestInput) -> Result<RequestStamp, RequestRefusal> {
        self.request(input)
    }
}

/// Launch one admitted request on the wire worker. Called in admission
/// order, so every earlier frame is already on the wire.
pub(crate) fn launch(env: &WireEnv, request: PendingRequest) {
    let kind = request.input.kind;
    let path = request.input.path.clone();
    let stamp = request.stamp;
    let encoding = env.caps.encoding();
    let context = ReplyContext {
        stamp,
        encoding,
        kind,
    };
    if !env.caps.supports(kind) {
        return note(
            env,
            context,
            format!("{} is not supported by this language server", kind.label()),
        );
    }
    let Some(uri) = env.workspace.uri(&request.input.path) else {
        return note(
            env,
            context,
            "cannot map the document path onto a file URI".into(),
        );
    };
    let Ok(line) = u32::try_from(request.input.line.get()) else {
        return note(env, context, "line is out of protocol range".into());
    };
    let server_col = crate::to_server_col_slice(
        request.input.line_text.as_slice(),
        request.input.byte_col,
        encoding,
    );
    let Ok(character) = u32::try_from(server_col.get()) else {
        return note(env, context, "column is out of protocol range".into());
    };
    let tdp = lt::TextDocumentPositionParams {
        text_document: lt::TextDocumentIdentifier { uri },
        position: lt::Position { line, character },
    };
    let tab_width = request.tab_width;
    let rename_to = request.input.rename_to.clone();
    let handle = env.handle.clone();
    let env = env.clone();
    handle.spawn(async move {
        if !sync::owns(&env, &stamp, &path) {
            return note(
                &env,
                context,
                "cancelled — the document changed or closed".into(),
            );
        }
        match kind {
            RequestKind::Hover => hover(env, tdp, context, path).await,
            RequestKind::Goto => goto(env, tdp, context, path).await,
            RequestKind::Locations(kind) => {
                wire::request_locations(&env, kind, tdp, context, path).await
            }
            RequestKind::SwitchHeader => switch_header(env, tdp, context).await,
            RequestKind::Format => match tab_width {
                Some(tab_width) => format(env, tdp.text_document.uri, context, tab_width).await,
                None => note(
                    &env,
                    context,
                    "format request is missing its tab width".into(),
                ),
            },
            RequestKind::Rename => match rename_to {
                Some(new_name) => rename(env, tdp, context, new_name).await,
                None => note(
                    &env,
                    context,
                    "rename request is missing its new name".into(),
                ),
            },
            RequestKind::CodeAction => code_actions(env, tdp, context).await,
            RequestKind::DocumentSymbols => {
                document_symbols(env, tdp.text_document, context, path).await
            }
            // Workspace queries take their own document-free lane
            // (`Client::workspace_symbols`); they can never arrive
            // through the position-bearing launcher.
            RequestKind::WorkspaceSymbols => {}
        }
    });
}

fn note(env: &WireEnv, context: ReplyContext, text: String) {
    let _ = env.tx.send(LspEvent::Note { context, text });
}

async fn hover(
    env: WireEnv,
    tdp: lt::TextDocumentPositionParams,
    context: ReplyContext,
    path: std::path::PathBuf,
) {
    let params = lt::HoverParams {
        text_document_position_params: tdp,
        work_done_progress_params: Default::default(),
    };
    let mut response = env
        .socket
        .request::<lt::request::HoverRequest>(params.clone())
        .await;
    if is_content_modified(&response) {
        tokio::time::sleep(RETRY_DELAY).await;
        if !sync::owns(&env, &context.stamp, &path) {
            return note(
                &env,
                context,
                "cancelled — the document changed or closed".into(),
            );
        }
        response = env
            .socket
            .request::<lt::request::HoverRequest>(params)
            .await;
    }
    match response {
        Ok(Some(hover)) => {
            let text = hover_text(&hover);
            if text.is_empty() {
                note(&env, context, "no hover information at the cursor".into());
            } else {
                let _ = env.tx.send(LspEvent::HoverText { context, text });
            }
        }
        Ok(None) => note(&env, context, "no hover information at the cursor".into()),
        Err(error) => note(&env, context, format!("hover failed: {error}")),
    }
}

async fn goto(
    env: WireEnv,
    tdp: lt::TextDocumentPositionParams,
    context: ReplyContext,
    path: std::path::PathBuf,
) {
    let params = lt::GotoDefinitionParams {
        text_document_position_params: tdp,
        work_done_progress_params: Default::default(),
        partial_result_params: Default::default(),
    };
    let mut response = env
        .socket
        .request::<lt::request::GotoDefinition>(params.clone())
        .await;
    if is_content_modified(&response) {
        tokio::time::sleep(RETRY_DELAY).await;
        if !sync::owns(&env, &context.stamp, &path) {
            return note(
                &env,
                context,
                "cancelled — the document changed or closed".into(),
            );
        }
        response = env
            .socket
            .request::<lt::request::GotoDefinition>(params)
            .await;
    }
    match response {
        Ok(Some(response)) => match wire::first_location(response) {
            Some(location) => match wire::to_server_location(location, &env.workspace) {
                Ok(location) => {
                    let _ = env.tx.send(LspEvent::GotoLocation { context, location });
                }
                Err(uri) => note(
                    &env,
                    context,
                    format!(
                        "definition target is not a file on {}: {uri}",
                        env.workspace.label()
                    ),
                ),
            },
            None => note(&env, context, "no definition found".into()),
        },
        Ok(None) => note(&env, context, "no definition found".into()),
        Err(error) => note(&env, context, format!("goto definition failed: {error}")),
    }
}

async fn switch_header(env: WireEnv, tdp: lt::TextDocumentPositionParams, context: ReplyContext) {
    match env
        .socket
        .request::<SwitchSourceHeader>(tdp.text_document)
        .await
    {
        Ok(Some(uri)) => match env.workspace.decode(&uri) {
            Some(path) => {
                let location = ServerLocation {
                    doc: ResourceLocation {
                        filesystem: env.workspace.target(),
                        path,
                    },
                    position: ServerPosition {
                        line: LineIndex::new(0),
                        column: ServerColumn::new(0),
                    },
                };
                let _ = env.tx.send(LspEvent::GotoLocation { context, location });
            }
            None => note(
                &env,
                context,
                format!(
                    "header/source counterpart is not a file on {}: {uri}",
                    env.workspace.label()
                ),
            ),
        },
        Ok(None) => note(&env, context, "no header/source counterpart".into()),
        Err(error) => note(
            &env,
            context,
            format!("switch source/header failed: {error}"),
        ),
    }
}

/// `textDocument/formatting`: the reply's whole-document edits in
/// server-domain positions. A null reply is an explicit empty edit set,
/// like the locations family's empty lists.
async fn format(env: WireEnv, uri: lt::Url, context: ReplyContext, tab_width: usize) {
    let Ok(tab_size) = u32::try_from(tab_width) else {
        return note(&env, context, "tab width is out of protocol range".into());
    };
    let params = lt::DocumentFormattingParams {
        text_document: lt::TextDocumentIdentifier { uri },
        options: lt::FormattingOptions {
            tab_size,
            insert_spaces: true,
            ..Default::default()
        },
        work_done_progress_params: Default::default(),
    };
    match env.socket.request::<lt::request::Formatting>(params).await {
        Ok(edits) => {
            let edits = edits
                .unwrap_or_default()
                .into_iter()
                .map(wire::server_edit)
                .collect();
            let _ = env.tx.send(LspEvent::Edits { context, edits });
        }
        Err(error) => note(&env, context, format!("format failed: {error}")),
    }
}

/// `textDocument/rename`: both `changes` and `documentChanges` decode
/// to per-resource edit groups; resource operations and foreign
/// versions refuse the whole reply with a note — never a partial set.
async fn rename(
    env: WireEnv,
    tdp: lt::TextDocumentPositionParams,
    context: ReplyContext,
    new_name: String,
) {
    let params = lt::RenameParams {
        text_document_position: tdp,
        new_name,
        work_done_progress_params: Default::default(),
    };
    match env.socket.request::<lt::request::Rename>(params).await {
        Ok(Some(edit)) => match wire::workspace_edits(&env, edit) {
            Ok(edits) => {
                let _ = env.tx.send(LspEvent::WorkspaceEdits { context, edits });
            }
            Err(refusal) => note(
                &env,
                context,
                refusal.note_text("rename", &env.workspace.label()),
            ),
        },
        // A null reply is an explicit empty edit set.
        Ok(None) => {
            let _ = env.tx.send(LspEvent::WorkspaceEdits {
                context,
                edits: Vec::new(),
            });
        }
        Err(error) => note(&env, context, format!("rename failed: {error}")),
    }
}

/// `textDocument/codeAction` at a zero-width range with an empty
/// diagnostics context: the actions available at the cursor.
async fn code_actions(env: WireEnv, tdp: lt::TextDocumentPositionParams, context: ReplyContext) {
    let params = lt::CodeActionParams {
        text_document: tdp.text_document,
        range: lt::Range {
            start: tdp.position,
            end: tdp.position,
        },
        context: lt::CodeActionContext {
            diagnostics: Vec::new(),
            only: None,
            trigger_kind: None,
        },
        work_done_progress_params: Default::default(),
        partial_result_params: Default::default(),
    };
    match env
        .socket
        .request::<lt::request::CodeActionRequest>(params)
        .await
    {
        Ok(Some(items)) => {
            let actions = items
                .into_iter()
                .map(|item| match item {
                    lt::CodeActionOrCommand::Command(command) => ProtoAction {
                        title: command.title,
                        edits: None,
                        has_external_command: true,
                    },
                    lt::CodeActionOrCommand::CodeAction(action) => {
                        // An action whose edit carries file operations,
                        // unverifiable versions or undecodable targets
                        // cannot be applied: it stays listed by title
                        // with `edits: None`, and the editor marks it
                        // inapplicable.
                        let edits = action
                            .edit
                            .and_then(|edit| wire::workspace_edits(&env, edit).ok());
                        ProtoAction {
                            title: action.title,
                            edits,
                            has_external_command: action.command.is_some(),
                        }
                    }
                })
                .collect();
            let _ = env.tx.send(LspEvent::ActionList { context, actions });
        }
        // A null reply is an explicit empty action list.
        Ok(None) => {
            let _ = env.tx.send(LspEvent::ActionList {
                context,
                actions: Vec::new(),
            });
        }
        Err(error) => note(&env, context, format!("code action failed: {error}")),
    }
}

/// `textDocument/documentSymbol`: both reply shapes flatten into
/// One workspace-symbol query (0063 §2): both reply shapes land in the
/// same row form as document symbols. A `WorkspaceSymbol` whose
/// location is uri-only (a resolve-support server contract we do not
/// advertise) has no position to jump to and is dropped.
pub(crate) async fn workspace_symbols(env: WireEnv, generation: u64, query: String) {
    let params = lt::WorkspaceSymbolParams {
        partial_result_params: Default::default(),
        work_done_progress_params: Default::default(),
        query,
    };
    let response = env
        .socket
        .request::<lt::request::WorkspaceSymbolRequest>(params)
        .await;
    let server = env.id;
    match response {
        Ok(Some(lt::WorkspaceSymbolResponse::Flat(informations))) => {
            let symbols = informations
                .into_iter()
                .filter_map(|info| {
                    let location = wire::to_server_location(info.location, &env.workspace).ok()?;
                    Some(ProtoSymbol {
                        name: info.name,
                        container: info.container_name.unwrap_or_default(),
                        kind: symbol_kind_label(info.kind).into(),
                        location,
                    })
                })
                .collect::<Vec<_>>();
            let _ = env.tx.send(LspEvent::WorkspaceSymbols {
                server,
                generation,
                symbols,
            });
        }
        Ok(Some(lt::WorkspaceSymbolResponse::Nested(entries))) => {
            let symbols = entries
                .into_iter()
                .filter_map(|entry| {
                    let location = match entry.location {
                        lt::OneOf::Left(location) => location,
                        lt::OneOf::Right(_) => return None,
                    };
                    let location = wire::to_server_location(location, &env.workspace).ok()?;
                    Some(ProtoSymbol {
                        name: entry.name,
                        container: entry.container_name.unwrap_or_default(),
                        kind: symbol_kind_label(entry.kind).into(),
                        location,
                    })
                })
                .collect::<Vec<_>>();
            let _ = env.tx.send(LspEvent::WorkspaceSymbols {
                server,
                generation,
                symbols,
            });
        }
        Ok(None) => {
            let _ = env.tx.send(LspEvent::WorkspaceSymbols {
                server,
                generation,
                symbols: Vec::new(),
            });
        }
        Err(error) => {
            let _ = env.tx.send(LspEvent::WorkspaceSymbolsFailed {
                server,
                generation,
                reason: format!("workspace symbols failed: {error}"),
            });
        }
    }
}

/// [`ProtoSymbol`] rows (0047 §1). Hierarchical trees join ancestors
/// with ` :: ` as the container path; the jump position is the
/// selection range's start (the identifier, not the block).
async fn document_symbols(
    env: WireEnv,
    text_document: lt::TextDocumentIdentifier,
    context: ReplyContext,
    path: std::path::PathBuf,
) {
    let params = lt::DocumentSymbolParams {
        text_document,
        work_done_progress_params: Default::default(),
        partial_result_params: Default::default(),
    };
    let response = env
        .socket
        .request::<lt::request::DocumentSymbolRequest>(params)
        .await;
    let location = |line: u32, character: u32| ServerLocation {
        doc: ResourceLocation {
            filesystem: env.workspace.target(),
            path: path.clone(),
        },
        position: ServerPosition {
            line: LineIndex::new(line as usize),
            column: ServerColumn::new(character as usize),
        },
    };
    match response {
        Ok(Some(lt::DocumentSymbolResponse::Flat(informations))) => {
            let symbols = informations
                .into_iter()
                .filter_map(|info| {
                    let location = wire::to_server_location(info.location, &env.workspace).ok()?;
                    Some(ProtoSymbol {
                        name: info.name,
                        container: info.container_name.unwrap_or_default(),
                        kind: symbol_kind_label(info.kind).into(),
                        location,
                    })
                })
                .collect::<Vec<_>>();
            let _ = env.tx.send(LspEvent::Symbols { context, symbols });
        }
        Ok(Some(lt::DocumentSymbolResponse::Nested(tree))) => {
            let mut symbols = Vec::new();
            flatten_symbols(&tree, "", &mut |name, container, kind, line, character| {
                symbols.push(ProtoSymbol {
                    name,
                    container,
                    kind,
                    location: location(line, character),
                });
            });
            let _ = env.tx.send(LspEvent::Symbols { context, symbols });
        }
        Ok(None) => note(&env, context, "no symbols in this document".into()),
        Err(error) => note(&env, context, format!("document symbols failed: {error}")),
    }
}

fn flatten_symbols(
    symbols: &[lt::DocumentSymbol],
    ancestors: &str,
    emit: &mut impl FnMut(String, String, String, u32, u32),
) {
    for symbol in symbols {
        let container = if ancestors.is_empty() {
            String::new()
        } else {
            ancestors.to_string()
        };
        let path = if ancestors.is_empty() {
            symbol.name.clone()
        } else {
            format!("{ancestors} :: {}", symbol.name)
        };
        emit(
            symbol.name.clone(),
            container,
            symbol_kind_label(symbol.kind).into(),
            symbol.selection_range.start.line,
            symbol.selection_range.start.character,
        );
        if let Some(children) = symbol.children.as_deref() {
            flatten_symbols(children, &path, emit);
        }
    }
}

/// SymbolKind's LSP name for the picker row.
fn symbol_kind_label(kind: lt::SymbolKind) -> &'static str {
    match kind {
        lt::SymbolKind::FILE => "File",
        lt::SymbolKind::MODULE => "Module",
        lt::SymbolKind::NAMESPACE => "Namespace",
        lt::SymbolKind::PACKAGE => "Package",
        lt::SymbolKind::CLASS => "Class",
        lt::SymbolKind::METHOD => "Method",
        lt::SymbolKind::PROPERTY => "Property",
        lt::SymbolKind::FIELD => "Field",
        lt::SymbolKind::CONSTRUCTOR => "Constructor",
        lt::SymbolKind::ENUM => "Enum",
        lt::SymbolKind::INTERFACE => "Interface",
        lt::SymbolKind::FUNCTION => "Function",
        lt::SymbolKind::VARIABLE => "Variable",
        lt::SymbolKind::CONSTANT => "Constant",
        lt::SymbolKind::STRING => "String",
        lt::SymbolKind::NUMBER => "Number",
        lt::SymbolKind::BOOLEAN => "Boolean",
        lt::SymbolKind::ARRAY => "Array",
        lt::SymbolKind::OBJECT => "Object",
        lt::SymbolKind::KEY => "Key",
        lt::SymbolKind::NULL => "Null",
        lt::SymbolKind::ENUM_MEMBER => "EnumMember",
        lt::SymbolKind::STRUCT => "Struct",
        lt::SymbolKind::EVENT => "Event",
        lt::SymbolKind::OPERATOR => "Operator",
        lt::SymbolKind::TYPE_PARAMETER => "TypeParameter",
        _ => "Symbol",
    }
}