From 6a693d3ef24236292413e2b52c6476cf762e7e32 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Nov 2025 13:59:21 -0800 Subject: [PATCH 1/5] Add stringer-alike String methods to non-string LSP enums --- internal/lsp/lsproto/_generate/generate.mts | 87 ++++++ internal/lsp/lsproto/lsp_generated.go | 321 ++++++++++++++++++++ 2 files changed, 408 insertions(+) diff --git a/internal/lsp/lsproto/_generate/generate.mts b/internal/lsp/lsproto/_generate/generate.mts index a8dbf32115..a997308d34 100644 --- a/internal/lsp/lsproto/_generate/generate.mts +++ b/internal/lsp/lsproto/_generate/generate.mts @@ -1005,6 +1005,14 @@ function generateCode() { } } + // Helper function to detect if an enum is a bitflag enum + // Hardcoded list of bitflag enums + const bitflagEnums = new Set(["WatchKind"]); + + function isBitflagEnum(enumeration: any): boolean { + return bitflagEnums.has(enumeration.name); + } + // Generate enumerations writeLine("// Enumerations\n"); @@ -1033,6 +1041,8 @@ function generateCode() { const enumValues = enumeration.values.map(value => ({ value: String(value.value), + numericValue: Number(value.value), + name: value.name, identifier: `${enumeration.name}${value.name}`, documentation: value.documentation, deprecated: value.deprecated, @@ -1058,6 +1068,83 @@ function generateCode() { writeLine(")"); writeLine(""); + + // Generate String() method for non-string enums + if (enumeration.type.name !== "string") { + const isBitflag = isBitflagEnum(enumeration); + + if (isBitflag) { + // Generate bitflag-aware String() method using stringer-style efficiency + const sortedValues = [...enumValues].sort((a, b) => a.numericValue - b.numericValue); + const names = sortedValues.map(v => v.name); + const values = sortedValues.map(v => v.numericValue); + + const nameConst = `_${enumeration.name}_name`; + const indexVar = `_${enumeration.name}_index`; + const combinedNames = names.join(""); + + writeLine(`const ${nameConst} = "${combinedNames}"`); + write(`var ${indexVar} = [...]uint16{0`); + let offset = 0; + for (const name of names) { + offset += name.length; + write(`, ${offset}`); + } + writeLine(`}`); + writeLine(""); + + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\tif e == 0 {`); + writeLine(`\t\treturn "0"`); + writeLine(`\t}`); + writeLine(`\tvar result string`); + for (let i = 0; i < values.length; i++) { + writeLine(`\tif e&${values[i]} != 0 {`); + writeLine(`\t\tif result != "" {`); + writeLine(`\t\t\tresult += "|"`); + writeLine(`\t\t}`); + writeLine(`\t\tresult += ${nameConst}[${indexVar}[${i}]:${indexVar}[${i + 1}]]`); + writeLine(`\t}`); + } + writeLine(`\tif result == "" {`); + writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`\t}`); + writeLine(`\treturn result`); + writeLine(`}`); + writeLine(""); + } + else { + // Generate regular String() method using stringer-style efficiency + const sortedValues = [...enumValues].sort((a, b) => a.numericValue - b.numericValue); + const names = sortedValues.map(v => v.name); + const values = sortedValues.map(v => v.numericValue); + + const nameConst = `_${enumeration.name}_name`; + const indexVar = `_${enumeration.name}_index`; + const combinedNames = names.join(""); + + writeLine(`const ${nameConst} = "${combinedNames}"`); + write(`var ${indexVar} = [...]uint16{0`); + let offset = 0; + for (const name of names) { + offset += name.length; + write(`, ${offset}`); + } + writeLine(`}`); + writeLine(""); + + writeLine(`func (e ${enumeration.name}) String() string {`); + const minVal = Math.min(...values); + const maxVal = Math.max(...values); + writeLine(`\ti := int(e) - ${minVal}`); + writeLine(`\tif e < ${minVal} || i >= len(${indexVar})-1 {`); + writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`\t}`); + writeLine(`\treturn ${nameConst}[${indexVar}[i]:${indexVar}[i+1]]`); + writeLine(`}`); + writeLine(""); + } + } } const requestsAndNotifications: (Request | Notification)[] = [...model.requests, ...model.notifications]; diff --git a/internal/lsp/lsproto/lsp_generated.go b/internal/lsp/lsproto/lsp_generated.go index 3c43d47da3..ae7432c917 100644 --- a/internal/lsp/lsproto/lsp_generated.go +++ b/internal/lsp/lsproto/lsp_generated.go @@ -21755,6 +21755,18 @@ const ( ErrorCodesUnknownErrorCode ErrorCodes = -32001 ) +const _ErrorCodes_name = "ParseErrorInternalErrorInvalidParamsMethodNotFoundInvalidRequestServerNotInitializedUnknownErrorCode" + +var _ErrorCodes_index = [...]uint16{0, 10, 23, 36, 50, 64, 84, 100} + +func (e ErrorCodes) String() string { + i := int(e) - -32700 + if e < -32700 || i >= len(_ErrorCodes_index)-1 { + return fmt.Sprintf("ErrorCodes(%d)", e) + } + return _ErrorCodes_name[_ErrorCodes_index[i]:_ErrorCodes_index[i+1]] +} + type LSPErrorCodes int32 const ( @@ -21785,6 +21797,18 @@ const ( LSPErrorCodesRequestCancelled LSPErrorCodes = -32800 ) +const _LSPErrorCodes_name = "RequestFailedServerCancelledContentModifiedRequestCancelled" + +var _LSPErrorCodes_index = [...]uint16{0, 13, 28, 43, 59} + +func (e LSPErrorCodes) String() string { + i := int(e) - -32803 + if e < -32803 || i >= len(_LSPErrorCodes_index)-1 { + return fmt.Sprintf("LSPErrorCodes(%d)", e) + } + return _LSPErrorCodes_name[_LSPErrorCodes_index[i]:_LSPErrorCodes_index[i+1]] +} + // A set of predefined range kinds. type FoldingRangeKind string @@ -21829,6 +21853,18 @@ const ( SymbolKindTypeParameter SymbolKind = 26 ) +const _SymbolKind_name = "FileModuleNamespacePackageClassMethodPropertyFieldConstructorEnumInterfaceFunctionVariableConstantStringNumberBooleanArrayObjectKeyNullEnumMemberStructEventOperatorTypeParameter" + +var _SymbolKind_index = [...]uint16{0, 4, 10, 19, 26, 31, 37, 45, 50, 61, 65, 74, 82, 90, 98, 104, 110, 117, 122, 128, 131, 135, 145, 151, 156, 164, 177} + +func (e SymbolKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_SymbolKind_index)-1 { + return fmt.Sprintf("SymbolKind(%d)", e) + } + return _SymbolKind_name[_SymbolKind_index[i]:_SymbolKind_index[i+1]] +} + // Symbol tags are extra annotations that tweak the rendering of a symbol. // // Since: 3.16 @@ -21839,6 +21875,18 @@ const ( SymbolTagDeprecated SymbolTag = 1 ) +const _SymbolTag_name = "Deprecated" + +var _SymbolTag_index = [...]uint16{0, 10} + +func (e SymbolTag) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_SymbolTag_index)-1 { + return fmt.Sprintf("SymbolTag(%d)", e) + } + return _SymbolTag_name[_SymbolTag_index[i]:_SymbolTag_index[i+1]] +} + // Moniker uniqueness level to define scope of the moniker. // // Since: 3.16.0 @@ -21884,6 +21932,18 @@ const ( InlayHintKindParameter InlayHintKind = 2 ) +const _InlayHintKind_name = "TypeParameter" + +var _InlayHintKind_index = [...]uint16{0, 4, 13} + +func (e InlayHintKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_InlayHintKind_index)-1 { + return fmt.Sprintf("InlayHintKind(%d)", e) + } + return _InlayHintKind_name[_InlayHintKind_index[i]:_InlayHintKind_index[i+1]] +} + // The message type type MessageType uint32 @@ -21904,6 +21964,18 @@ const ( MessageTypeDebug MessageType = 5 ) +const _MessageType_name = "ErrorWarningInfoLogDebug" + +var _MessageType_index = [...]uint16{0, 5, 12, 16, 19, 24} + +func (e MessageType) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_MessageType_index)-1 { + return fmt.Sprintf("MessageType(%d)", e) + } + return _MessageType_name[_MessageType_index[i]:_MessageType_index[i+1]] +} + // Defines how the host (editor) should sync // document changes to the language server. type TextDocumentSyncKind uint32 @@ -21920,6 +21992,18 @@ const ( TextDocumentSyncKindIncremental TextDocumentSyncKind = 2 ) +const _TextDocumentSyncKind_name = "NoneFullIncremental" + +var _TextDocumentSyncKind_index = [...]uint16{0, 4, 8, 19} + +func (e TextDocumentSyncKind) String() string { + i := int(e) - 0 + if e < 0 || i >= len(_TextDocumentSyncKind_index)-1 { + return fmt.Sprintf("TextDocumentSyncKind(%d)", e) + } + return _TextDocumentSyncKind_name[_TextDocumentSyncKind_index[i]:_TextDocumentSyncKind_index[i+1]] +} + // Represents reasons why a text document is saved. type TextDocumentSaveReason uint32 @@ -21933,6 +22017,18 @@ const ( TextDocumentSaveReasonFocusOut TextDocumentSaveReason = 3 ) +const _TextDocumentSaveReason_name = "ManualAfterDelayFocusOut" + +var _TextDocumentSaveReason_index = [...]uint16{0, 6, 16, 24} + +func (e TextDocumentSaveReason) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_TextDocumentSaveReason_index)-1 { + return fmt.Sprintf("TextDocumentSaveReason(%d)", e) + } + return _TextDocumentSaveReason_name[_TextDocumentSaveReason_index[i]:_TextDocumentSaveReason_index[i+1]] +} + // The kind of a completion entry. type CompletionItemKind uint32 @@ -21964,6 +22060,18 @@ const ( CompletionItemKindTypeParameter CompletionItemKind = 25 ) +const _CompletionItemKind_name = "TextMethodFunctionConstructorFieldVariableClassInterfaceModulePropertyUnitValueEnumKeywordSnippetColorFileReferenceFolderEnumMemberConstantStructEventOperatorTypeParameter" + +var _CompletionItemKind_index = [...]uint16{0, 4, 10, 18, 29, 34, 42, 47, 56, 62, 70, 74, 79, 83, 90, 97, 102, 106, 115, 121, 131, 139, 145, 150, 158, 171} + +func (e CompletionItemKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_CompletionItemKind_index)-1 { + return fmt.Sprintf("CompletionItemKind(%d)", e) + } + return _CompletionItemKind_name[_CompletionItemKind_index[i]:_CompletionItemKind_index[i+1]] +} + // Completion item tags are extra annotations that tweak the rendering of a completion // item. // @@ -21975,6 +22083,18 @@ const ( CompletionItemTagDeprecated CompletionItemTag = 1 ) +const _CompletionItemTag_name = "Deprecated" + +var _CompletionItemTag_index = [...]uint16{0, 10} + +func (e CompletionItemTag) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_CompletionItemTag_index)-1 { + return fmt.Sprintf("CompletionItemTag(%d)", e) + } + return _CompletionItemTag_name[_CompletionItemTag_index[i]:_CompletionItemTag_index[i+1]] +} + // Defines whether the insert text in a completion item should be interpreted as // plain text or a snippet. type InsertTextFormat uint32 @@ -21993,6 +22113,18 @@ const ( InsertTextFormatSnippet InsertTextFormat = 2 ) +const _InsertTextFormat_name = "PlainTextSnippet" + +var _InsertTextFormat_index = [...]uint16{0, 9, 16} + +func (e InsertTextFormat) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_InsertTextFormat_index)-1 { + return fmt.Sprintf("InsertTextFormat(%d)", e) + } + return _InsertTextFormat_name[_InsertTextFormat_index[i]:_InsertTextFormat_index[i+1]] +} + // How whitespace and indentation is handled during completion // item insertion. // @@ -22016,6 +22148,18 @@ const ( InsertTextModeadjustIndentation InsertTextMode = 2 ) +const _InsertTextMode_name = "asIsadjustIndentation" + +var _InsertTextMode_index = [...]uint16{0, 4, 21} + +func (e InsertTextMode) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_InsertTextMode_index)-1 { + return fmt.Sprintf("InsertTextMode(%d)", e) + } + return _InsertTextMode_name[_InsertTextMode_index[i]:_InsertTextMode_index[i+1]] +} + // A document highlight kind. type DocumentHighlightKind uint32 @@ -22028,6 +22172,18 @@ const ( DocumentHighlightKindWrite DocumentHighlightKind = 3 ) +const _DocumentHighlightKind_name = "TextReadWrite" + +var _DocumentHighlightKind_index = [...]uint16{0, 4, 8, 13} + +func (e DocumentHighlightKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_DocumentHighlightKind_index)-1 { + return fmt.Sprintf("DocumentHighlightKind(%d)", e) + } + return _DocumentHighlightKind_name[_DocumentHighlightKind_index[i]:_DocumentHighlightKind_index[i+1]] +} + // A set of predefined code action kinds type CodeActionKind string @@ -22111,6 +22267,18 @@ const ( CodeActionTagLLMGenerated CodeActionTag = 1 ) +const _CodeActionTag_name = "LLMGenerated" + +var _CodeActionTag_index = [...]uint16{0, 12} + +func (e CodeActionTag) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_CodeActionTag_index)-1 { + return fmt.Sprintf("CodeActionTag(%d)", e) + } + return _CodeActionTag_name[_CodeActionTag_index[i]:_CodeActionTag_index[i+1]] +} + type TraceValue string const ( @@ -22228,6 +22396,18 @@ const ( InlineCompletionTriggerKindAutomatic InlineCompletionTriggerKind = 2 ) +const _InlineCompletionTriggerKind_name = "InvokedAutomatic" + +var _InlineCompletionTriggerKind_index = [...]uint16{0, 7, 16} + +func (e InlineCompletionTriggerKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_InlineCompletionTriggerKind_index)-1 { + return fmt.Sprintf("InlineCompletionTriggerKind(%d)", e) + } + return _InlineCompletionTriggerKind_name[_InlineCompletionTriggerKind_index[i]:_InlineCompletionTriggerKind_index[i+1]] +} + // A set of predefined position encoding kinds. // // Since: 3.17.0 @@ -22261,6 +22441,18 @@ const ( FileChangeTypeDeleted FileChangeType = 3 ) +const _FileChangeType_name = "CreatedChangedDeleted" + +var _FileChangeType_index = [...]uint16{0, 7, 14, 21} + +func (e FileChangeType) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_FileChangeType_index)-1 { + return fmt.Sprintf("FileChangeType(%d)", e) + } + return _FileChangeType_name[_FileChangeType_index[i]:_FileChangeType_index[i+1]] +} + type WatchKind uint32 const ( @@ -22272,6 +22464,39 @@ const ( WatchKindDelete WatchKind = 4 ) +const _WatchKind_name = "CreateChangeDelete" + +var _WatchKind_index = [...]uint16{0, 6, 12, 18} + +func (e WatchKind) String() string { + if e == 0 { + return "0" + } + var result string + if e&1 != 0 { + if result != "" { + result += "|" + } + result += _WatchKind_name[_WatchKind_index[0]:_WatchKind_index[1]] + } + if e&2 != 0 { + if result != "" { + result += "|" + } + result += _WatchKind_name[_WatchKind_index[1]:_WatchKind_index[2]] + } + if e&4 != 0 { + if result != "" { + result += "|" + } + result += _WatchKind_name[_WatchKind_index[2]:_WatchKind_index[3]] + } + if result == "" { + return fmt.Sprintf("WatchKind(%d)", e) + } + return result +} + // The diagnostic's severity. type DiagnosticSeverity uint32 @@ -22286,6 +22511,18 @@ const ( DiagnosticSeverityHint DiagnosticSeverity = 4 ) +const _DiagnosticSeverity_name = "ErrorWarningInformationHint" + +var _DiagnosticSeverity_index = [...]uint16{0, 5, 12, 23, 27} + +func (e DiagnosticSeverity) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_DiagnosticSeverity_index)-1 { + return fmt.Sprintf("DiagnosticSeverity(%d)", e) + } + return _DiagnosticSeverity_name[_DiagnosticSeverity_index[i]:_DiagnosticSeverity_index[i+1]] +} + // The diagnostic tags. // // Since: 3.15.0 @@ -22303,6 +22540,18 @@ const ( DiagnosticTagDeprecated DiagnosticTag = 2 ) +const _DiagnosticTag_name = "UnnecessaryDeprecated" + +var _DiagnosticTag_index = [...]uint16{0, 11, 21} + +func (e DiagnosticTag) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_DiagnosticTag_index)-1 { + return fmt.Sprintf("DiagnosticTag(%d)", e) + } + return _DiagnosticTag_name[_DiagnosticTag_index[i]:_DiagnosticTag_index[i+1]] +} + // How a completion was triggered type CompletionTriggerKind uint32 @@ -22317,6 +22566,18 @@ const ( CompletionTriggerKindTriggerForIncompleteCompletions CompletionTriggerKind = 3 ) +const _CompletionTriggerKind_name = "InvokedTriggerCharacterTriggerForIncompleteCompletions" + +var _CompletionTriggerKind_index = [...]uint16{0, 7, 23, 54} + +func (e CompletionTriggerKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_CompletionTriggerKind_index)-1 { + return fmt.Sprintf("CompletionTriggerKind(%d)", e) + } + return _CompletionTriggerKind_name[_CompletionTriggerKind_index[i]:_CompletionTriggerKind_index[i+1]] +} + // Defines how values from a set of defaults and an individual item will be // merged. // @@ -22334,6 +22595,18 @@ const ( ApplyKindMerge ApplyKind = 2 ) +const _ApplyKind_name = "ReplaceMerge" + +var _ApplyKind_index = [...]uint16{0, 7, 12} + +func (e ApplyKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_ApplyKind_index)-1 { + return fmt.Sprintf("ApplyKind(%d)", e) + } + return _ApplyKind_name[_ApplyKind_index[i]:_ApplyKind_index[i+1]] +} + // How a signature help was triggered. // // Since: 3.15.0 @@ -22348,6 +22621,18 @@ const ( SignatureHelpTriggerKindContentChange SignatureHelpTriggerKind = 3 ) +const _SignatureHelpTriggerKind_name = "InvokedTriggerCharacterContentChange" + +var _SignatureHelpTriggerKind_index = [...]uint16{0, 7, 23, 36} + +func (e SignatureHelpTriggerKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_SignatureHelpTriggerKind_index)-1 { + return fmt.Sprintf("SignatureHelpTriggerKind(%d)", e) + } + return _SignatureHelpTriggerKind_name[_SignatureHelpTriggerKind_index[i]:_SignatureHelpTriggerKind_index[i+1]] +} + // The reason why code actions were requested. // // Since: 3.17.0 @@ -22363,6 +22648,18 @@ const ( CodeActionTriggerKindAutomatic CodeActionTriggerKind = 2 ) +const _CodeActionTriggerKind_name = "InvokedAutomatic" + +var _CodeActionTriggerKind_index = [...]uint16{0, 7, 16} + +func (e CodeActionTriggerKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_CodeActionTriggerKind_index)-1 { + return fmt.Sprintf("CodeActionTriggerKind(%d)", e) + } + return _CodeActionTriggerKind_name[_CodeActionTriggerKind_index[i]:_CodeActionTriggerKind_index[i+1]] +} + // A pattern kind describing if a glob pattern matches a file a folder or // both. // @@ -22388,6 +22685,18 @@ const ( NotebookCellKindCode NotebookCellKind = 2 ) +const _NotebookCellKind_name = "MarkupCode" + +var _NotebookCellKind_index = [...]uint16{0, 6, 10} + +func (e NotebookCellKind) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_NotebookCellKind_index)-1 { + return fmt.Sprintf("NotebookCellKind(%d)", e) + } + return _NotebookCellKind_name[_NotebookCellKind_index[i]:_NotebookCellKind_index[i+1]] +} + type ResourceOperationKind string const ( @@ -22425,6 +22734,18 @@ const ( PrepareSupportDefaultBehaviorIdentifier PrepareSupportDefaultBehavior = 1 ) +const _PrepareSupportDefaultBehavior_name = "Identifier" + +var _PrepareSupportDefaultBehavior_index = [...]uint16{0, 10} + +func (e PrepareSupportDefaultBehavior) String() string { + i := int(e) - 1 + if e < 1 || i >= len(_PrepareSupportDefaultBehavior_index)-1 { + return fmt.Sprintf("PrepareSupportDefaultBehavior(%d)", e) + } + return _PrepareSupportDefaultBehavior_name[_PrepareSupportDefaultBehavior_index[i]:_PrepareSupportDefaultBehavior_index[i+1]] +} + type TokenFormat string const ( From 623d1bd344500f759d3c1aa5b93b674191485213 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:10:41 -0800 Subject: [PATCH 2/5] Fix runs --- internal/lsp/lsproto/_generate/generate.mts | 153 +++++++++++++++++--- internal/lsp/lsproto/lsp_generated.go | 19 ++- 2 files changed, 146 insertions(+), 26 deletions(-) diff --git a/internal/lsp/lsproto/_generate/generate.mts b/internal/lsp/lsproto/_generate/generate.mts index a997308d34..d34ed661c9 100644 --- a/internal/lsp/lsproto/_generate/generate.mts +++ b/internal/lsp/lsproto/_generate/generate.mts @@ -1114,35 +1114,144 @@ function generateCode() { writeLine(""); } else { - // Generate regular String() method using stringer-style efficiency + // Generate regular String() method using stringer-style approach + // Split values into runs of contiguous values const sortedValues = [...enumValues].sort((a, b) => a.numericValue - b.numericValue); - const names = sortedValues.map(v => v.name); - const values = sortedValues.map(v => v.numericValue); + + // Split into runs + const runs: Array<{ names: string[]; values: number[]; }> = []; + let currentRun = { names: [sortedValues[0].name], values: [sortedValues[0].numericValue] }; + + for (let i = 1; i < sortedValues.length; i++) { + if (sortedValues[i].numericValue === sortedValues[i - 1].numericValue + 1) { + currentRun.names.push(sortedValues[i].name); + currentRun.values.push(sortedValues[i].numericValue); + } + else { + runs.push(currentRun); + currentRun = { names: [sortedValues[i].name], values: [sortedValues[i].numericValue] }; + } + } + runs.push(currentRun); const nameConst = `_${enumeration.name}_name`; const indexVar = `_${enumeration.name}_index`; - const combinedNames = names.join(""); - writeLine(`const ${nameConst} = "${combinedNames}"`); - write(`var ${indexVar} = [...]uint16{0`); - let offset = 0; - for (const name of names) { - offset += name.length; - write(`, ${offset}`); + if (runs.length === 1) { + // Single contiguous run - simple case + const combinedNames = runs[0].names.join(""); + writeLine(`const ${nameConst} = "${combinedNames}"`); + write(`var ${indexVar} = [...]uint16{0`); + let offset = 0; + for (const name of runs[0].names) { + offset += name.length; + write(`, ${offset}`); + } + writeLine(`}`); + writeLine(""); + + const minVal = runs[0].values[0]; + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\ti := int(e) - ${minVal}`); + writeLine(`\tif e < ${minVal} || i >= len(${indexVar})-1 {`); + writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`\t}`); + writeLine(`\treturn ${nameConst}[${indexVar}[i]:${indexVar}[i+1]]`); + writeLine(`}`); + writeLine(""); } - writeLine(`}`); - writeLine(""); + else if (runs.length <= 10) { + // Multiple runs - use switch statement + let allNames = ""; + const runInfo: Array<{ startOffset: number; endOffset: number; minVal: number; maxVal: number; }> = []; + + for (const run of runs) { + const startOffset = allNames.length; + allNames += run.names.join(""); + const endOffset = allNames.length; + runInfo.push({ + startOffset, + endOffset, + minVal: run.values[0], + maxVal: run.values[run.values.length - 1], + }); + } - writeLine(`func (e ${enumeration.name}) String() string {`); - const minVal = Math.min(...values); - const maxVal = Math.max(...values); - writeLine(`\ti := int(e) - ${minVal}`); - writeLine(`\tif e < ${minVal} || i >= len(${indexVar})-1 {`); - writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); - writeLine(`\t}`); - writeLine(`\treturn ${nameConst}[${indexVar}[i]:${indexVar}[i+1]]`); - writeLine(`}`); - writeLine(""); + writeLine(`const ${nameConst} = "${allNames}"`); + writeLine(""); + + // Generate index variables for each run + for (let i = 0; i < runs.length; i++) { + write(`var ${indexVar}_${i} = [...]uint16{0`); + let offset = 0; + for (const name of runs[i].names) { + offset += name.length; + write(`, ${offset}`); + } + writeLine(`}`); + } + writeLine(""); + + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\tswitch {`); + + for (let i = 0; i < runs.length; i++) { + const run = runs[i]; + const info = runInfo[i]; + + if (run.values.length === 1) { + writeLine(`\tcase e == ${run.values[0]}:`); + writeLine(`\t\treturn ${nameConst}[${info.startOffset}:${info.endOffset}]`); + } + else { + if (info.minVal === 0) { + writeLine(`\tcase e <= ${info.maxVal}:`); + } + else { + writeLine(`\tcase ${info.minVal} <= e && e <= ${info.maxVal}:`); + } + writeLine(`\t\ti := int(e) - ${info.minVal}`); + writeLine(`\t\treturn ${nameConst}[${info.startOffset}+${indexVar}_${i}[i]:${info.startOffset}+${indexVar}_${i}[i+1]]`); + } + } + + writeLine(`\tdefault:`); + writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`\t}`); + writeLine(`}`); + writeLine(""); + } + else { + // Too many runs - use a map + let allNames = ""; + const valueMap: Array<{ value: number; startOffset: number; endOffset: number; }> = []; + + for (const run of runs) { + for (let i = 0; i < run.names.length; i++) { + const startOffset = allNames.length; + allNames += run.names[i]; + const endOffset = allNames.length; + valueMap.push({ value: run.values[i], startOffset, endOffset }); + } + } + + writeLine(`const ${nameConst} = "${allNames}"`); + writeLine(""); + writeLine(`var ${enumeration.name}_map = map[${enumeration.name}]string{`); + for (const entry of valueMap) { + writeLine(`\t${entry.value}: ${nameConst}[${entry.startOffset}:${entry.endOffset}],`); + } + writeLine(`}`); + writeLine(""); + + writeLine(`func (e ${enumeration.name}) String() string {`); + writeLine(`\tif str, ok := ${enumeration.name}_map[e]; ok {`); + writeLine(`\t\treturn str`); + writeLine(`\t}`); + writeLine(`\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); + writeLine(`}`); + writeLine(""); + } } } } diff --git a/internal/lsp/lsproto/lsp_generated.go b/internal/lsp/lsproto/lsp_generated.go index ae7432c917..8f1fa0f9f5 100644 --- a/internal/lsp/lsproto/lsp_generated.go +++ b/internal/lsp/lsproto/lsp_generated.go @@ -21757,14 +21757,25 @@ const ( const _ErrorCodes_name = "ParseErrorInternalErrorInvalidParamsMethodNotFoundInvalidRequestServerNotInitializedUnknownErrorCode" -var _ErrorCodes_index = [...]uint16{0, 10, 23, 36, 50, 64, 84, 100} +var ( + _ErrorCodes_index_0 = [...]uint16{0, 10} + _ErrorCodes_index_1 = [...]uint16{0, 13, 26, 40, 54} + _ErrorCodes_index_2 = [...]uint16{0, 20, 36} +) func (e ErrorCodes) String() string { - i := int(e) - -32700 - if e < -32700 || i >= len(_ErrorCodes_index)-1 { + switch { + case e == -32700: + return _ErrorCodes_name[0:10] + case -32603 <= e && e <= -32600: + i := int(e) - -32603 + return _ErrorCodes_name[10+_ErrorCodes_index_1[i] : 10+_ErrorCodes_index_1[i+1]] + case -32002 <= e && e <= -32001: + i := int(e) - -32002 + return _ErrorCodes_name[64+_ErrorCodes_index_2[i] : 64+_ErrorCodes_index_2[i+1]] + default: return fmt.Sprintf("ErrorCodes(%d)", e) } - return _ErrorCodes_name[_ErrorCodes_index[i]:_ErrorCodes_index[i+1]] } type LSPErrorCodes int32 From 2178bfce693d7e9947a17ff3f2a37aaaae9bb7cc Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:14:46 -0800 Subject: [PATCH 3/5] Fix bounds checking --- internal/lsp/lsproto/_generate/generate.mts | 9 +++- internal/lsp/lsproto/lsp_generated.go | 46 ++++++++++----------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/internal/lsp/lsproto/_generate/generate.mts b/internal/lsp/lsproto/_generate/generate.mts index d34ed661c9..e0da04e383 100644 --- a/internal/lsp/lsproto/_generate/generate.mts +++ b/internal/lsp/lsproto/_generate/generate.mts @@ -1153,7 +1153,9 @@ function generateCode() { const minVal = runs[0].values[0]; writeLine(`func (e ${enumeration.name}) String() string {`); writeLine(`\ti := int(e) - ${minVal}`); - writeLine(`\tif e < ${minVal} || i >= len(${indexVar})-1 {`); + // For unsigned types, i can still be negative if e < minVal (due to underflow in conversion) + // So we always need to check both bounds + writeLine(`\tif i < 0 || i >= len(${indexVar})-1 {`); writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); writeLine(`\t}`); writeLine(`\treturn ${nameConst}[${indexVar}[i]:${indexVar}[i+1]]`); @@ -1204,9 +1206,12 @@ function generateCode() { writeLine(`\t\treturn ${nameConst}[${info.startOffset}:${info.endOffset}]`); } else { - if (info.minVal === 0) { + if (info.minVal === 0 && baseType.startsWith("uint")) { writeLine(`\tcase e <= ${info.maxVal}:`); } + else if (info.minVal === 0) { + writeLine(`\tcase 0 <= e && e <= ${info.maxVal}:`); + } else { writeLine(`\tcase ${info.minVal} <= e && e <= ${info.maxVal}:`); } diff --git a/internal/lsp/lsproto/lsp_generated.go b/internal/lsp/lsproto/lsp_generated.go index 8f1fa0f9f5..874d257da8 100644 --- a/internal/lsp/lsproto/lsp_generated.go +++ b/internal/lsp/lsproto/lsp_generated.go @@ -21814,7 +21814,7 @@ var _LSPErrorCodes_index = [...]uint16{0, 13, 28, 43, 59} func (e LSPErrorCodes) String() string { i := int(e) - -32803 - if e < -32803 || i >= len(_LSPErrorCodes_index)-1 { + if i < 0 || i >= len(_LSPErrorCodes_index)-1 { return fmt.Sprintf("LSPErrorCodes(%d)", e) } return _LSPErrorCodes_name[_LSPErrorCodes_index[i]:_LSPErrorCodes_index[i+1]] @@ -21870,7 +21870,7 @@ var _SymbolKind_index = [...]uint16{0, 4, 10, 19, 26, 31, 37, 45, 50, 61, 65, 74 func (e SymbolKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_SymbolKind_index)-1 { + if i < 0 || i >= len(_SymbolKind_index)-1 { return fmt.Sprintf("SymbolKind(%d)", e) } return _SymbolKind_name[_SymbolKind_index[i]:_SymbolKind_index[i+1]] @@ -21892,7 +21892,7 @@ var _SymbolTag_index = [...]uint16{0, 10} func (e SymbolTag) String() string { i := int(e) - 1 - if e < 1 || i >= len(_SymbolTag_index)-1 { + if i < 0 || i >= len(_SymbolTag_index)-1 { return fmt.Sprintf("SymbolTag(%d)", e) } return _SymbolTag_name[_SymbolTag_index[i]:_SymbolTag_index[i+1]] @@ -21949,7 +21949,7 @@ var _InlayHintKind_index = [...]uint16{0, 4, 13} func (e InlayHintKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_InlayHintKind_index)-1 { + if i < 0 || i >= len(_InlayHintKind_index)-1 { return fmt.Sprintf("InlayHintKind(%d)", e) } return _InlayHintKind_name[_InlayHintKind_index[i]:_InlayHintKind_index[i+1]] @@ -21981,7 +21981,7 @@ var _MessageType_index = [...]uint16{0, 5, 12, 16, 19, 24} func (e MessageType) String() string { i := int(e) - 1 - if e < 1 || i >= len(_MessageType_index)-1 { + if i < 0 || i >= len(_MessageType_index)-1 { return fmt.Sprintf("MessageType(%d)", e) } return _MessageType_name[_MessageType_index[i]:_MessageType_index[i+1]] @@ -22009,7 +22009,7 @@ var _TextDocumentSyncKind_index = [...]uint16{0, 4, 8, 19} func (e TextDocumentSyncKind) String() string { i := int(e) - 0 - if e < 0 || i >= len(_TextDocumentSyncKind_index)-1 { + if i < 0 || i >= len(_TextDocumentSyncKind_index)-1 { return fmt.Sprintf("TextDocumentSyncKind(%d)", e) } return _TextDocumentSyncKind_name[_TextDocumentSyncKind_index[i]:_TextDocumentSyncKind_index[i+1]] @@ -22034,7 +22034,7 @@ var _TextDocumentSaveReason_index = [...]uint16{0, 6, 16, 24} func (e TextDocumentSaveReason) String() string { i := int(e) - 1 - if e < 1 || i >= len(_TextDocumentSaveReason_index)-1 { + if i < 0 || i >= len(_TextDocumentSaveReason_index)-1 { return fmt.Sprintf("TextDocumentSaveReason(%d)", e) } return _TextDocumentSaveReason_name[_TextDocumentSaveReason_index[i]:_TextDocumentSaveReason_index[i+1]] @@ -22077,7 +22077,7 @@ var _CompletionItemKind_index = [...]uint16{0, 4, 10, 18, 29, 34, 42, 47, 56, 62 func (e CompletionItemKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_CompletionItemKind_index)-1 { + if i < 0 || i >= len(_CompletionItemKind_index)-1 { return fmt.Sprintf("CompletionItemKind(%d)", e) } return _CompletionItemKind_name[_CompletionItemKind_index[i]:_CompletionItemKind_index[i+1]] @@ -22100,7 +22100,7 @@ var _CompletionItemTag_index = [...]uint16{0, 10} func (e CompletionItemTag) String() string { i := int(e) - 1 - if e < 1 || i >= len(_CompletionItemTag_index)-1 { + if i < 0 || i >= len(_CompletionItemTag_index)-1 { return fmt.Sprintf("CompletionItemTag(%d)", e) } return _CompletionItemTag_name[_CompletionItemTag_index[i]:_CompletionItemTag_index[i+1]] @@ -22130,7 +22130,7 @@ var _InsertTextFormat_index = [...]uint16{0, 9, 16} func (e InsertTextFormat) String() string { i := int(e) - 1 - if e < 1 || i >= len(_InsertTextFormat_index)-1 { + if i < 0 || i >= len(_InsertTextFormat_index)-1 { return fmt.Sprintf("InsertTextFormat(%d)", e) } return _InsertTextFormat_name[_InsertTextFormat_index[i]:_InsertTextFormat_index[i+1]] @@ -22165,7 +22165,7 @@ var _InsertTextMode_index = [...]uint16{0, 4, 21} func (e InsertTextMode) String() string { i := int(e) - 1 - if e < 1 || i >= len(_InsertTextMode_index)-1 { + if i < 0 || i >= len(_InsertTextMode_index)-1 { return fmt.Sprintf("InsertTextMode(%d)", e) } return _InsertTextMode_name[_InsertTextMode_index[i]:_InsertTextMode_index[i+1]] @@ -22189,7 +22189,7 @@ var _DocumentHighlightKind_index = [...]uint16{0, 4, 8, 13} func (e DocumentHighlightKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_DocumentHighlightKind_index)-1 { + if i < 0 || i >= len(_DocumentHighlightKind_index)-1 { return fmt.Sprintf("DocumentHighlightKind(%d)", e) } return _DocumentHighlightKind_name[_DocumentHighlightKind_index[i]:_DocumentHighlightKind_index[i+1]] @@ -22284,7 +22284,7 @@ var _CodeActionTag_index = [...]uint16{0, 12} func (e CodeActionTag) String() string { i := int(e) - 1 - if e < 1 || i >= len(_CodeActionTag_index)-1 { + if i < 0 || i >= len(_CodeActionTag_index)-1 { return fmt.Sprintf("CodeActionTag(%d)", e) } return _CodeActionTag_name[_CodeActionTag_index[i]:_CodeActionTag_index[i+1]] @@ -22413,7 +22413,7 @@ var _InlineCompletionTriggerKind_index = [...]uint16{0, 7, 16} func (e InlineCompletionTriggerKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_InlineCompletionTriggerKind_index)-1 { + if i < 0 || i >= len(_InlineCompletionTriggerKind_index)-1 { return fmt.Sprintf("InlineCompletionTriggerKind(%d)", e) } return _InlineCompletionTriggerKind_name[_InlineCompletionTriggerKind_index[i]:_InlineCompletionTriggerKind_index[i+1]] @@ -22458,7 +22458,7 @@ var _FileChangeType_index = [...]uint16{0, 7, 14, 21} func (e FileChangeType) String() string { i := int(e) - 1 - if e < 1 || i >= len(_FileChangeType_index)-1 { + if i < 0 || i >= len(_FileChangeType_index)-1 { return fmt.Sprintf("FileChangeType(%d)", e) } return _FileChangeType_name[_FileChangeType_index[i]:_FileChangeType_index[i+1]] @@ -22528,7 +22528,7 @@ var _DiagnosticSeverity_index = [...]uint16{0, 5, 12, 23, 27} func (e DiagnosticSeverity) String() string { i := int(e) - 1 - if e < 1 || i >= len(_DiagnosticSeverity_index)-1 { + if i < 0 || i >= len(_DiagnosticSeverity_index)-1 { return fmt.Sprintf("DiagnosticSeverity(%d)", e) } return _DiagnosticSeverity_name[_DiagnosticSeverity_index[i]:_DiagnosticSeverity_index[i+1]] @@ -22557,7 +22557,7 @@ var _DiagnosticTag_index = [...]uint16{0, 11, 21} func (e DiagnosticTag) String() string { i := int(e) - 1 - if e < 1 || i >= len(_DiagnosticTag_index)-1 { + if i < 0 || i >= len(_DiagnosticTag_index)-1 { return fmt.Sprintf("DiagnosticTag(%d)", e) } return _DiagnosticTag_name[_DiagnosticTag_index[i]:_DiagnosticTag_index[i+1]] @@ -22583,7 +22583,7 @@ var _CompletionTriggerKind_index = [...]uint16{0, 7, 23, 54} func (e CompletionTriggerKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_CompletionTriggerKind_index)-1 { + if i < 0 || i >= len(_CompletionTriggerKind_index)-1 { return fmt.Sprintf("CompletionTriggerKind(%d)", e) } return _CompletionTriggerKind_name[_CompletionTriggerKind_index[i]:_CompletionTriggerKind_index[i+1]] @@ -22612,7 +22612,7 @@ var _ApplyKind_index = [...]uint16{0, 7, 12} func (e ApplyKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_ApplyKind_index)-1 { + if i < 0 || i >= len(_ApplyKind_index)-1 { return fmt.Sprintf("ApplyKind(%d)", e) } return _ApplyKind_name[_ApplyKind_index[i]:_ApplyKind_index[i+1]] @@ -22638,7 +22638,7 @@ var _SignatureHelpTriggerKind_index = [...]uint16{0, 7, 23, 36} func (e SignatureHelpTriggerKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_SignatureHelpTriggerKind_index)-1 { + if i < 0 || i >= len(_SignatureHelpTriggerKind_index)-1 { return fmt.Sprintf("SignatureHelpTriggerKind(%d)", e) } return _SignatureHelpTriggerKind_name[_SignatureHelpTriggerKind_index[i]:_SignatureHelpTriggerKind_index[i+1]] @@ -22665,7 +22665,7 @@ var _CodeActionTriggerKind_index = [...]uint16{0, 7, 16} func (e CodeActionTriggerKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_CodeActionTriggerKind_index)-1 { + if i < 0 || i >= len(_CodeActionTriggerKind_index)-1 { return fmt.Sprintf("CodeActionTriggerKind(%d)", e) } return _CodeActionTriggerKind_name[_CodeActionTriggerKind_index[i]:_CodeActionTriggerKind_index[i+1]] @@ -22702,7 +22702,7 @@ var _NotebookCellKind_index = [...]uint16{0, 6, 10} func (e NotebookCellKind) String() string { i := int(e) - 1 - if e < 1 || i >= len(_NotebookCellKind_index)-1 { + if i < 0 || i >= len(_NotebookCellKind_index)-1 { return fmt.Sprintf("NotebookCellKind(%d)", e) } return _NotebookCellKind_name[_NotebookCellKind_index[i]:_NotebookCellKind_index[i+1]] @@ -22751,7 +22751,7 @@ var _PrepareSupportDefaultBehavior_index = [...]uint16{0, 10} func (e PrepareSupportDefaultBehavior) String() string { i := int(e) - 1 - if e < 1 || i >= len(_PrepareSupportDefaultBehavior_index)-1 { + if i < 0 || i >= len(_PrepareSupportDefaultBehavior_index)-1 { return fmt.Sprintf("PrepareSupportDefaultBehavior(%d)", e) } return _PrepareSupportDefaultBehavior_name[_PrepareSupportDefaultBehavior_index[i]:_PrepareSupportDefaultBehavior_index[i+1]] From 9db7e29bb9e3c1d9e6d847d91f5c208d9a47056d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:18:47 -0800 Subject: [PATCH 4/5] Fix weird pipe regression --- internal/lsp/lsproto/_generate/generate.mts | 11 ++++------- internal/lsp/lsproto/lsp_generated.go | 21 ++++++--------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/internal/lsp/lsproto/_generate/generate.mts b/internal/lsp/lsproto/_generate/generate.mts index e0da04e383..b33e932a0e 100644 --- a/internal/lsp/lsproto/_generate/generate.mts +++ b/internal/lsp/lsproto/_generate/generate.mts @@ -1097,19 +1097,16 @@ function generateCode() { writeLine(`\tif e == 0 {`); writeLine(`\t\treturn "0"`); writeLine(`\t}`); - writeLine(`\tvar result string`); + writeLine(`\tvar parts []string`); for (let i = 0; i < values.length; i++) { writeLine(`\tif e&${values[i]} != 0 {`); - writeLine(`\t\tif result != "" {`); - writeLine(`\t\t\tresult += "|"`); - writeLine(`\t\t}`); - writeLine(`\t\tresult += ${nameConst}[${indexVar}[${i}]:${indexVar}[${i + 1}]]`); + writeLine(`\t\tparts = append(parts, ${nameConst}[${indexVar}[${i}]:${indexVar}[${i + 1}]])`); writeLine(`\t}`); } - writeLine(`\tif result == "" {`); + writeLine(`\tif len(parts) == 0 {`); writeLine(`\t\treturn fmt.Sprintf("${enumeration.name}(%d)", e)`); writeLine(`\t}`); - writeLine(`\treturn result`); + writeLine(`\treturn strings.Join(parts, "|")`); writeLine(`}`); writeLine(""); } diff --git a/internal/lsp/lsproto/lsp_generated.go b/internal/lsp/lsproto/lsp_generated.go index 874d257da8..5e19c148cb 100644 --- a/internal/lsp/lsproto/lsp_generated.go +++ b/internal/lsp/lsproto/lsp_generated.go @@ -22483,29 +22483,20 @@ func (e WatchKind) String() string { if e == 0 { return "0" } - var result string + var parts []string if e&1 != 0 { - if result != "" { - result += "|" - } - result += _WatchKind_name[_WatchKind_index[0]:_WatchKind_index[1]] + parts = append(parts, _WatchKind_name[_WatchKind_index[0]:_WatchKind_index[1]]) } if e&2 != 0 { - if result != "" { - result += "|" - } - result += _WatchKind_name[_WatchKind_index[1]:_WatchKind_index[2]] + parts = append(parts, _WatchKind_name[_WatchKind_index[1]:_WatchKind_index[2]]) } if e&4 != 0 { - if result != "" { - result += "|" - } - result += _WatchKind_name[_WatchKind_index[2]:_WatchKind_index[3]] + parts = append(parts, _WatchKind_name[_WatchKind_index[2]:_WatchKind_index[3]]) } - if result == "" { + if len(parts) == 0 { return fmt.Sprintf("WatchKind(%d)", e) } - return result + return strings.Join(parts, "|") } // The diagnostic's severity. From 539fffcf5e0912c1dac8b43e15a59747b8da85ae Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 21 Nov 2025 14:24:14 -0800 Subject: [PATCH 5/5] Use String --- internal/fourslash/baselineutil.go | 59 +------------------ .../declarationMapsWorkspaceSymbols.baseline | 8 +-- 2 files changed, 5 insertions(+), 62 deletions(-) diff --git a/internal/fourslash/baselineutil.go b/internal/fourslash/baselineutil.go index 051b97a9ee..b49fb6b28b 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -904,62 +904,5 @@ func codeFence(lang string, code string) string { } func symbolInformationToData(symbol *lsproto.SymbolInformation) string { - var symbolKindToString string - switch symbol.Kind { - case lsproto.SymbolKindFile: - symbolKindToString = "file" - case lsproto.SymbolKindModule: - symbolKindToString = "module" - case lsproto.SymbolKindNamespace: - symbolKindToString = "namespace" - case lsproto.SymbolKindPackage: - symbolKindToString = "package" - case lsproto.SymbolKindClass: - symbolKindToString = "class" - case lsproto.SymbolKindMethod: - symbolKindToString = "method" - case lsproto.SymbolKindProperty: - symbolKindToString = "property" - case lsproto.SymbolKindField: - symbolKindToString = "field" - case lsproto.SymbolKindConstructor: - symbolKindToString = "constructor" - case lsproto.SymbolKindEnum: - symbolKindToString = "enum" - case lsproto.SymbolKindInterface: - symbolKindToString = "interface" - case lsproto.SymbolKindFunction: - symbolKindToString = "function" - case lsproto.SymbolKindVariable: - symbolKindToString = "variable" - case lsproto.SymbolKindConstant: - symbolKindToString = "constant" - case lsproto.SymbolKindString: - symbolKindToString = "string" - case lsproto.SymbolKindNumber: - symbolKindToString = "number" - case lsproto.SymbolKindBoolean: - symbolKindToString = "boolean" - case lsproto.SymbolKindArray: - symbolKindToString = "array" - case lsproto.SymbolKindObject: - symbolKindToString = "object" - case lsproto.SymbolKindKey: - symbolKindToString = "key" - case lsproto.SymbolKindNull: - symbolKindToString = "null" - case lsproto.SymbolKindEnumMember: - symbolKindToString = "enumMember" - case lsproto.SymbolKindStruct: - symbolKindToString = "struct" - case lsproto.SymbolKindEvent: - symbolKindToString = "event" - case lsproto.SymbolKindOperator: - symbolKindToString = "operator" - case lsproto.SymbolKindTypeParameter: - symbolKindToString = "typeParameter" - default: - symbolKindToString = "unknown" - } - return fmt.Sprintf("{| name: %s, kind: %s |}", symbol.Name, symbolKindToString) + return fmt.Sprintf("{| name: %s, kind: %s |}", symbol.Name, symbol.Kind.String()) } diff --git a/testdata/baselines/reference/fourslash/state/declarationMapsWorkspaceSymbols.baseline b/testdata/baselines/reference/fourslash/state/declarationMapsWorkspaceSymbols.baseline index e633640e55..27ef54e300 100644 --- a/testdata/baselines/reference/fourslash/state/declarationMapsWorkspaceSymbols.baseline +++ b/testdata/baselines/reference/fourslash/state/declarationMapsWorkspaceSymbols.baseline @@ -144,20 +144,20 @@ Config:: // === workspaceSymbol === // === /a/a.ts === -// export function [|{| name: fnA, kind: function |}fnA|]() {} +// export function [|{| name: fnA, kind: Function |}fnA|]() {} // export interface IfaceA {} // export const instanceA: IfaceA = {}; // === /b/b.ts === -// export function [|{| name: fnB, kind: function |}fnB|]() {} +// export function [|{| name: fnB, kind: Function |}fnB|]() {} // === /b/c.ts === -// export function [|{| name: fnC, kind: function |}fnC|]() {} +// export function [|{| name: fnC, kind: Function |}fnC|]() {} // === /user/user.ts === // import * as a from "../a/a"; // import * as b from "../b/b"; -// export function [|{| name: fnUser, kind: function |}fnUser|]() { +// export function [|{| name: fnUser, kind: Function |}fnUser|]() { // a.fnA(); // b.fnB(); // a.instanceA;