From 4f0863dec5da612ea7f277f7cf94f674a4cdefa9 Mon Sep 17 00:00:00 2001 From: habaneraa Date: Thu, 19 Mar 2026 19:02:52 +0800 Subject: [PATCH] fix: Update SymbolKind handling to use Enum _missing_ method --- src/serena/symbol.py | 2 +- src/solidlsp/ls.py | 4 ---- src/solidlsp/ls_types.py | 12 ++---------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/serena/symbol.py b/src/serena/symbol.py index 5e80e93d..f8ba9dd2 100644 --- a/src/serena/symbol.py +++ b/src/serena/symbol.py @@ -222,7 +222,7 @@ class LanguageServerSymbol(Symbol, ToStringMixin): """ :return: string representation of the symbol kind (name attribute of the `SymbolKind` enum item) """ - return SymbolKind.from_int(self.symbol_kind).name + return SymbolKind(self.symbol_kind).name @property def symbol_kind(self) -> SymbolKind: diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index 432f11eb..881f070d 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -1276,10 +1276,6 @@ class SolidLanguageServer(ABC): item = cast(ls_types.UnifiedSymbolInformation, dict(original_symbol_dict)) absolute_path = os.path.join(self.repository_root_path, relative_file_path) - # handle non-standard symbol kind values (e.g., 255) - if "kind" in item and isinstance(item["kind"], int): - item["kind"] = ls_types.SymbolKind.from_int(item["kind"]) - # handle missing location and path entries if "location" not in item: uri = pathlib.Path(absolute_path).as_uri() diff --git a/src/solidlsp/ls_types.py b/src/solidlsp/ls_types.py index 7be552ff..18aaf25d 100644 --- a/src/solidlsp/ls_types.py +++ b/src/solidlsp/ls_types.py @@ -181,16 +181,8 @@ class SymbolKind(IntEnum): TypeParameter = 26 @classmethod - def from_int(cls, value: int) -> "SymbolKind": - """Convert an integer to a SymbolKind. - - Returns Unknown (0) for non-standard values instead of raising ValueError. - This handles language servers that may use custom/extended symbol kinds. - """ - try: - return cls(value) - except ValueError: - return cls.Unknown + def _missing_(cls, value: int) -> "SymbolKind": + return cls.Unknown class SymbolTag(IntEnum):