From 55b4a665fd44789aced32d7929d17cc32c7007a3 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Sun, 9 Nov 2025 22:19:19 +0100 Subject: [PATCH] UnifiedSymbolInformation: Set overload_idx only if there are overloads #515 --- src/solidlsp/ls.py | 6 +++++- src/solidlsp/ls_types.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index e1859dd9..eded9417 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -942,11 +942,15 @@ class SolidLanguageServer(ABC): Converts the given nodes into UnifiedSymbolInformation with proper parent-child relationships, adding overload indices for symbols with the same name under the same parent. """ + total_name_counts = defaultdict(lambda: 0) + for node in nodes: + total_name_counts[node["name"]] += 1 name_counts = defaultdict(lambda: 0) for node in nodes: flat_all_symbol_list.append(node) usymbol_node = turn_item_into_symbol_with_children(node) - usymbol_node["overload_idx"] = name_counts[usymbol_node["name"]] + if total_name_counts[usymbol_node["name"]] > 1: + usymbol_node["overload_idx"] = name_counts[usymbol_node["name"]] name_counts[usymbol_node["name"]] += 1 usymbol_node["parent"] = parent if usymbol_node["children"]: diff --git a/src/solidlsp/ls_types.py b/src/solidlsp/ls_types.py index 8bc6f303..bbd3cbad 100644 --- a/src/solidlsp/ls_types.py +++ b/src/solidlsp/ls_types.py @@ -245,9 +245,9 @@ class UnifiedSymbolInformation(TypedDict): overload_idx: NotRequired[int] """ - The overload index of the symbol, if applicable. If the symbol is an overloaded function or method - (same symbol name with the same parent), this index indicates which overload it is. - The index is 0-based. + The overload index of the symbol, if applicable. If a symbol does not have overloads, this field is omitted. + If the symbol is an overloaded function or method (same symbol name with the same parent), + this index indicates which overload it is. The index is 0-based. Added for Serena, not part of the LSP. """