Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jfcherng opened this issue May 29, 2024 · 1 comment · Fixed by #2487
Closed

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

jfcherng opened this issue May 29, 2024 · 1 comment · Fixed by #2487

Comments

@jfcherng
Copy link
Contributor

jfcherng commented May 29, 2024

Related to #2446 (comment).

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': {}}
  • CodeActionKind
  • FailureHandlingKind
  • FoldingRangeKind
  • MarkupKind
  • SemanticTokenModifiers
  • SemanticTokenTypes
  • TokenFormat
@jwortmann
Copy link
Member

I remember that I had manually fixed the values for the IntEnums in the PR merged as c5321ad, but for the StrEnums it seems they got introduced in 0ae1c7b by adding this as the base class:

class StrEnum(str, Enum):
"""
Naive polyfill for Python 3.11's StrEnum.
See https://docs.python.org/3.11/library/enum.html#enum.StrEnum
"""
__format__ = str.__format__
__str__ = str.__str__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants