mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-12 20:15:56 +00:00
Merge pull request #1188 from habaneraa/main
Fix: Handle Non-Standard SymbolKind Values from Language Servers
This commit is contained in:
2 files changed
+16
-65
No files matched your search
@@ -7,13 +7,18 @@ from __future__ import annotations
|
||||
from enum import Enum, IntEnum
|
||||
from typing import TYPE_CHECKING, NotRequired, Union
|
||||
|
||||
from sensai.util.helper import mark_used
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from solidlsp.lsp_protocol_handler.lsp_types import DiagnosticSeverity
|
||||
from solidlsp.lsp_protocol_handler.lsp_types import DiagnosticSeverity, SymbolKind
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .ls import SymbolBody
|
||||
|
||||
# a lot of code relied on a previously duplicated SymbolKind definition here.
|
||||
# This line is kept to avoid breaking downstream imports
|
||||
mark_used(SymbolKind)
|
||||
|
||||
|
||||
URI = str
|
||||
DocumentUri = str
|
||||
@@ -147,39 +152,6 @@ class CompletionItem(TypedDict):
|
||||
about this item, like type or symbol information. """
|
||||
|
||||
|
||||
class SymbolKind(IntEnum):
|
||||
"""A symbol kind."""
|
||||
|
||||
# TODO: This is a duplicate of SymbolKind in lsp_types.
|
||||
|
||||
File = 1
|
||||
Module = 2
|
||||
Namespace = 3
|
||||
Package = 4
|
||||
Class = 5
|
||||
Method = 6
|
||||
Property = 7
|
||||
Field = 8
|
||||
Constructor = 9
|
||||
Enum = 10
|
||||
Interface = 11
|
||||
Function = 12
|
||||
Variable = 13
|
||||
Constant = 14
|
||||
String = 15
|
||||
Number = 16
|
||||
Boolean = 17
|
||||
Array = 18
|
||||
Object = 19
|
||||
Key = 20
|
||||
Null = 21
|
||||
EnumMember = 22
|
||||
Struct = 23
|
||||
Event = 24
|
||||
Operator = 25
|
||||
TypeParameter = 26
|
||||
|
||||
|
||||
class SymbolTag(IntEnum):
|
||||
"""Symbol tags are extra annotations that tweak the rendering of a symbol.
|
||||
|
||||
|
||||
@@ -1,36 +1,16 @@
|
||||
# Code generated. DO NOT EDIT.
|
||||
# The code in this module is mostly autogenerated using https://github.com/predragnikolic/OLSP
|
||||
# To update it for higher LSP versions, autogenerate a new version in a different file and merge manually.
|
||||
|
||||
# LSP v3.17.0
|
||||
# TODO: Look into use of https://pypi.org/project/ts2python/ to generate the types for https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/
|
||||
# Note by author of the autogenerator: Look into use of https://pypi.org/project/ts2python/ to generate the types f
|
||||
# or https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/
|
||||
|
||||
"""
|
||||
This file provides the Python types corresponding to the Typescript types defined in the language server protocol.
|
||||
This file is obtained from https://github.com/predragnikolic/OLSP under the MIT License with the following terms:
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Предраг Николић
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"""
|
||||
|
||||
from enum import Enum, IntEnum, IntFlag
|
||||
from typing import Literal, NotRequired, Union
|
||||
from typing import Any, Literal, NotRequired, Union
|
||||
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
@@ -166,6 +146,8 @@ class FoldingRangeKind(Enum):
|
||||
class SymbolKind(IntEnum):
|
||||
"""A symbol kind."""
|
||||
|
||||
Unknown = 0
|
||||
"""Not an LSP type, we use it to represent symbols that don't have a known kind."""
|
||||
File = 1
|
||||
Module = 2
|
||||
Namespace = 3
|
||||
@@ -197,11 +179,8 @@ class SymbolKind(IntEnum):
|
||||
TypeParameter = 26
|
||||
|
||||
@classmethod
|
||||
def from_int(cls, value: int) -> "SymbolKind":
|
||||
for symbol_kind in cls:
|
||||
if symbol_kind.value == value:
|
||||
return symbol_kind
|
||||
raise ValueError(f"Invalid symbol kind: {value}")
|
||||
def _missing_(cls, value: Any) -> "SymbolKind":
|
||||
return cls.Unknown
|
||||
|
||||
|
||||
class SymbolTag(IntEnum):
|
||||
|
||||
Reference in new issue
Block a user