From 035a0db206ae1651b8e853b5aff5c1562fc7715e Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Thu, 18 Sep 2025 08:43:09 -0400 Subject: Rework how hover info is displayed for constants and types --- src/server/analysis.odin | 2 ++ src/server/documentation.odin | 23 +++++++++++++++++++---- src/server/hover.odin | 1 + src/server/signature.odin | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 684a790..1e570b4 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1348,6 +1348,7 @@ resolve_soa_selector_field :: proc( if resolved, ok := resolve_type_expression(ast_context, v.types[i]); ok { resolved.pkg = symbol.name resolved.range = v.ranges[i] + resolved.type = .Field return resolved, ok } else { return {}, false @@ -2618,6 +2619,7 @@ resolve_type_location_proc_param_name :: proc( symbol.type_name = symbol.name symbol.pkg = call_symbol.name symbol.name = ident.name + symbol.type = .Field return symbol, true } } diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 7979e5a..53c9c36 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -430,6 +430,19 @@ write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, sy strings.write_string(sb, "package") return case SymbolUntypedValue: + if .Mutable in symbol.flags || symbol.type == .Field { + switch v.type { + case .Float: + strings.write_string(sb, "float") + case .String: + strings.write_string(sb, "string") + case .Bool: + strings.write_string(sb, "bool") + case .Integer: + strings.write_string(sb, "int") + } + return + } strings.write_string(sb, v.tok.text) return case SymbolGenericValue: @@ -789,7 +802,12 @@ construct_symbol_information :: proc(ast_context: ^AstContext, symbol: Symbol) - sb := strings.builder_make(ast_context.allocator) write_symbol_attributes(&sb, symbol) write_symbol_name(&sb, symbol) - if .Mutable not_in symbol.flags { + + if symbol.type == .Package { + return strings.to_string(sb) + } + + if symbol.type != .Field && .Mutable not_in symbol.flags { if symbol.type_expr != nil && symbol.value_expr != nil { strings.write_string(&sb, " : ") build_string_node(symbol.type_expr, &sb, false) @@ -802,9 +820,6 @@ construct_symbol_information :: proc(ast_context: ^AstContext, symbol: Symbol) - strings.write_string(&sb, ": ") } - if symbol.type == .Package { - return strings.to_string(sb) - } if write_symbol_type_information(&sb, ast_context, symbol) { return strings.to_string(sb) diff --git a/src/server/hover.odin b/src/server/hover.odin index ef4c046..fe69949 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -344,6 +344,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> name = selector.name, pkg = selector.pkg, signature = get_enum_field_signature(v, i), + type = .Field, } hover.contents = write_hover_content(&ast_context, symbol) return hover, true, true diff --git a/src/server/signature.odin b/src/server/signature.odin index 619453f..9ffe92b 100644 --- a/src/server/signature.odin +++ b/src/server/signature.odin @@ -187,6 +187,7 @@ get_signature_information :: proc(document: ^Document, position: common.Position get_signature :: proc(symbol: Symbol) -> string { sb := strings.builder_make() write_symbol_name(&sb, symbol) + strings.write_string(&sb, " :: ") strings.write_string(&sb, symbol.signature) return strings.to_string(sb) } -- cgit v1.2.3