sublimelsp / LSP

Client implementation of the Language Server Protocol for Sublime Text
https://lsp.sublimetext.io/
MIT License
1.65k stars 182 forks source link

Replace `Enum` object with it's scalar value in the LSP log panel? #2485

Closed jfcherng closed 4 months ago

jfcherng commented 4 months ago

Related to https://github.com/sublimelsp/LSP/pull/2446#issuecomment-2059553794.

Not sure whether this is interested or not. In the LSP log panel, because we now uses Enum, there are enum object in the log rather than its scalar value. This disallows the payload can be formatted as JS or Python for easier reading. I know there is a website for formatting it but I've never remembered that :(

E.g., <SemanticTokenTypes.Type: 'type'>

Example Payload

:: [13:53:58.990] --> groovy-language-server initialize (1): {'processId': 18380, 'clientInfo': {'name': 'Sublime Text LSP', 'version': '2.1.0'}, 'rootUri': 'file:///D:/jfcherng/Desktop/XXX', 'rootPath': 'D:\\jfcherng\\Desktop\\repos\\sdlc\\release_parent', 'workspaceFolders': [{'name': 'release_parent', 'uri': 'file:///D:/jfcherng/Desktop/XXX'}, {'name': 'admin_statistic', 'uri': 'file:///D:/jfcherng/Desktop/XXX'}, {'name': 'admin_scripts', 'uri': 'file:///D:/jfcherng/Desktop/XXX'}, {'name': 'checker', 'uri': 'file:///D:/jfcherng/Desktop/XXX'}], 'capabilities': {'general': {'regularExpressions': {'engine': 'ECMAScript'}, 'markdown': {'parser': 'Python-Markdown', 'version': '3.2.2'}}, 'textDocument': {'synchronization': {'dynamicRegistration': True, 'didSave': True, 'willSave': True, 'willSaveWaitUntil': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': [<MarkupKind.Markdown: 'markdown'>, <MarkupKind.PlainText: 'plaintext'>]}, 'completion': {'dynamicRegistration': True, 'completionItem': {'snippetSupport': True, 'deprecatedSupport': True, 'documentationFormat': [<MarkupKind.Markdown: 'markdown'>, <MarkupKind.PlainText: 'plaintext'>], 'tagSupport': {'valueSet': [1]}, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertReplaceSupport': True, 'insertTextModeSupport': {'valueSet': [2]}, 'labelDetailsSupport': True}, 'completionItemKind': {'valueSet': [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]}, 'insertTextMode': 2, 'completionList': {'itemDefaults': ['editRange', 'insertTextFormat', 'data']}}, 'signatureHelp': {'dynamicRegistration': True, 'contextSupport': True, 'signatureInformation': {'activeParameterSupport': True, 'documentationFormat': [<MarkupKind.Markdown: 'markdown'>, <MarkupKind.PlainText: 'plaintext'>], 'parameterInformation': {'labelOffsetSupport': True}}}, 'references': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'hierarchicalDocumentSymbolSupport': True, 'symbolKind': {'valueSet': [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]}, 'tagSupport': {'valueSet': [1]}}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'formatting': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True, 'rangesSupport': True}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'codeAction': {'dynamicRegistration': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': [<CodeActionKind.QuickFix: 'quickfix'>, <CodeActionKind.Refactor: 'refactor'>, <CodeActionKind.RefactorExtract: 'refactor.extract'>, <CodeActionKind.RefactorInline: 'refactor.inline'>, <CodeActionKind.RefactorRewrite: 'refactor.rewrite'>, <CodeActionKind.SourceFixAll: 'source.fixAll'>, <CodeActionKind.SourceOrganizeImports: 'source.organizeImports'>]}}, 'dataSupport': True, 'isPreferredSupport': True, 'resolveSupport': {'properties': ['edit']}}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True, 'prepareSupportDefaultBehavior': 1}, 'colorProvider': {'dynamicRegistration': True}, 'publishDiagnostics': {'relatedInformation': True, 'tagSupport': {'valueSet': [1, 2]}, 'versionSupport': True, 'codeDescriptionSupport': True, 'dataSupport': True}, 'diagnostic': {'dynamicRegistration': True, 'relatedDocumentSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'foldingRange': {'dynamicRegistration': True, 'foldingRangeKind': {'valueSet': [<FoldingRangeKind.Comment: 'comment'>, <FoldingRangeKind.Imports: 'imports'>, <FoldingRangeKind.Region: 'region'>]}}, 'codeLens': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'semanticTokens': {'dynamicRegistration': True, 'requests': {'range': True, 'full': {'delta': True}}, 'tokenTypes': [<SemanticTokenTypes.Namespace: 'namespace'>, <SemanticTokenTypes.Type: 'type'>, <SemanticTokenTypes.Class: 'class'>, <SemanticTokenTypes.Enum: 'enum'>, <SemanticTokenTypes.Interface: 'interface'>, <SemanticTokenTypes.Struct: 'struct'>, <SemanticTokenTypes.TypeParameter: 'typeParameter'>, <SemanticTokenTypes.Parameter: 'parameter'>, <SemanticTokenTypes.Variable: 'variable'>, <SemanticTokenTypes.Property: 'property'>, <SemanticTokenTypes.EnumMember: 'enumMember'>, <SemanticTokenTypes.Event: 'event'>, <SemanticTokenTypes.Function: 'function'>, <SemanticTokenTypes.Method: 'method'>, <SemanticTokenTypes.Macro: 'macro'>, <SemanticTokenTypes.Keyword: 'keyword'>, <SemanticTokenTypes.Modifier: 'modifier'>, <SemanticTokenTypes.Comment: 'comment'>, <SemanticTokenTypes.String: 'string'>, <SemanticTokenTypes.Number: 'number'>, <SemanticTokenTypes.Regexp: 'regexp'>, <SemanticTokenTypes.Operator: 'operator'>, <SemanticTokenTypes.Decorator: 'decorator'>], 'tokenModifiers': [<SemanticTokenModifiers.Declaration: 'declaration'>, <SemanticTokenModifiers.Definition: 'definition'>, <SemanticTokenModifiers.Readonly: 'readonly'>, <SemanticTokenModifiers.Static: 'static'>, <SemanticTokenModifiers.Deprecated: 'deprecated'>, <SemanticTokenModifiers.Abstract: 'abstract'>, <SemanticTokenModifiers.Async: 'async'>, <SemanticTokenModifiers.Modification: 'modification'>, <SemanticTokenModifiers.Documentation: 'documentation'>, <SemanticTokenModifiers.DefaultLibrary: 'defaultLibrary'>], 'formats': [<TokenFormat.Relative: 'relative'>], 'overlappingTokenSupport': False, 'multilineTokenSupport': True, 'augmentsSyntaxTokens': True}, 'callHierarchy': {'dynamicRegistration': True}, 'typeHierarchy': {'dynamicRegistration': True}}, 'workspace': {'applyEdit': True, 'didChangeConfiguration': {'dynamicRegistration': True}, 'executeCommand': {}, 'workspaceEdit': {'documentChanges': True, 'failureHandling': <FailureHandlingKind.Abort: 'abort'>}, 'workspaceFolders': True, 'symbol': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['location.range']}, 'symbolKind': {'valueSet': [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]}, 'tagSupport': {'valueSet': [1]}}, 'configuration': True, 'codeLens': {'refreshSupport': True}, 'inlayHint': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'diagnostics': {'refreshSupport': True}, 'didChangeWatchedFiles': {'dynamicRegistration': True}}, 'window': {'showDocument': {'support': True}, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'workDoneProgress': True}}, 'initializationOptions': {}}
jwortmann commented 4 months ago

I remember that I had manually fixed the values for the IntEnums in the PR merged as https://github.com/sublimelsp/LSP/commit/c5321ad504a2060e7be466a0779544e3d72af319, but for the StrEnums it seems they got introduced in https://github.com/sublimelsp/LSP/commit/0ae1c7b4b4639c74d3bf688044eb428558d67d95 by adding this as the base class: https://github.com/sublimelsp/LSP/blob/fc5a7c75c8cec2e6765e218f7df980315c5c9ff3/plugin/core/typing.py#L40-L48