diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-07 20:29:30 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-07 20:53:27 -0400 |
| commit | 8ec7acff2b5a4a628d09ad3fe4f4b8f74fb8d856 (patch) | |
| tree | 7cb50ad364e5ca369e135d40ac054398888b2de8 /src | |
| parent | 41c5c76526aad8ca69525abfed045d501171fe24 (diff) | |
Fix hover on external package structs returned from procedures
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/analysis.odin | 16 | ||||
| -rw-r--r-- | src/server/hover.odin | 3 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index d04ef9d..dc3a380 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -3765,6 +3765,16 @@ unwrap_bitset :: proc(ast_context: ^AstContext, bitset_symbol: Symbol) -> (Symbo return {}, false } +append_variable_full_name :: proc(sb: ^strings.Builder,ast_context: ^AstContext, symbol: Symbol, pointer_prefix: string) { + pkg_name := get_symbol_pkg_name(ast_context, symbol) + if pkg_name == "" { + fmt.sbprintf(sb, "%s%s :: ", pointer_prefix, symbol.name) + return + } + fmt.sbprintf(sb, "%s%s.%s :: ", pointer_prefix, pkg_name, symbol.name) + return +} + get_signature :: proc(ast_context: ^AstContext, ident: ast.Any_Node, symbol: Symbol, was_variable := false) -> string { if symbol.type == .Function { return symbol.signature @@ -3791,7 +3801,7 @@ get_signature :: proc(ast_context: ^AstContext, ident: ast.Any_Node, symbol: Sym case SymbolEnumValue: builder := strings.builder_make(ast_context.allocator) if is_variable { - fmt.sbprintf(&builder, "%s%s.%s :: ", get_symbol_pkg_name(ast_context, symbol), pointer_prefix, symbol.name) + append_variable_full_name(&builder, ast_context, symbol, pointer_prefix) } strings.write_string(&builder, "enum {\n") for i in 0..<len(v.names) { @@ -3811,7 +3821,7 @@ get_signature :: proc(ast_context: ^AstContext, ident: ast.Any_Node, symbol: Sym case SymbolStructValue: builder := strings.builder_make(ast_context.allocator) if is_variable { - fmt.sbprintf(&builder, "%s%s.%s :: ", get_symbol_pkg_name(ast_context, symbol), pointer_prefix, symbol.name) + append_variable_full_name(&builder, ast_context, symbol, pointer_prefix) } longestNameLen := 0 for name in v.names { @@ -3832,7 +3842,7 @@ get_signature :: proc(ast_context: ^AstContext, ident: ast.Any_Node, symbol: Sym case SymbolUnionValue: builder := strings.builder_make(ast_context.allocator) if is_variable { - fmt.sbprintf(&builder, "%s%s.%s :: ", get_symbol_pkg_name(ast_context, symbol), pointer_prefix, symbol.name) + append_variable_full_name(&builder, ast_context, symbol, pointer_prefix) } strings.write_string(&builder, "union {\n") for i in 0..<len(v.types) { diff --git a/src/server/hover.odin b/src/server/hover.odin index 9dbfc2d..b69385a 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -228,7 +228,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> if symbol, ok := resolve_type_expression(&ast_context, v.types[i]); ok { symbol.name = name symbol.pkg = selector.name - symbol.signature = common.node_to_string(v.types[i]) + symbol.signature = get_signature(&ast_context, v.types[i].derived, symbol) hover.contents = write_hover_content(&ast_context, symbol) return hover, true, true } @@ -250,6 +250,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> if position_context.field != nil { if ident, ok := position_context.field.derived.(^ast.Ident); ok { if symbol, ok := resolve_type_identifier(&ast_context, ident^); ok { + symbol.signature = get_signature(&ast_context, ident, symbol) hover.contents = write_hover_content(&ast_context, symbol) return hover, true, true } |