diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-17 21:42:44 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-17 21:42:44 -0400 |
| commit | 7f8c9bdf7d1be2f4e4f2301de163a8bac8bb025b (patch) | |
| tree | bd06c4da9dbfe0f56cc2817f5e3287b7d4dd657d /src/server/hover.odin | |
| parent | 6282669ff2438cdeb1b90b05af0f573602ad3144 (diff) | |
| parent | 03a531cc687b4a97c5834037598a7ba74b3ef116 (diff) | |
Merge pull request #900 from BradLewis/feat/soa
Support #soa fields
Diffstat (limited to 'src/server/hover.odin')
| -rw-r--r-- | src/server/hover.odin | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/server/hover.odin b/src/server/hover.odin index 2c68ad0..03cdedf 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -153,7 +153,12 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> position_context.value_decl.names[0], ); ok { if value, ok := struct_symbol.value.(SymbolStructValue); ok { - construct_struct_field_symbol(&symbol, struct_symbol.name, value, field_index+name_index) + construct_struct_field_symbol( + &symbol, + struct_symbol.name, + value, + field_index + name_index, + ) build_documentation(&ast_context, &symbol, true) hover.contents = write_hover_content(&ast_context, symbol) return hover, true, true @@ -188,7 +193,8 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> } } - if position_context.field_value != nil && position_in_node(position_context.field_value.field, position_context.position) { + if position_context.field_value != nil && + position_in_node(position_context.field_value.field, position_context.position) { if position_context.comp_lit != nil { if comp_symbol, ok := resolve_comp_literal(&ast_context, &position_context); ok { if field, ok := position_context.field_value.field.derived.(^ast.Ident); ok { @@ -347,6 +353,12 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> return hover, true, true } } + case SymbolSliceValue: + return get_soa_hover(&ast_context, selector, v.expr, nil, field) + case SymbolDynamicArrayValue: + return get_soa_hover(&ast_context, selector, v.expr, nil, field) + case SymbolFixedArrayValue: + return get_soa_hover(&ast_context, selector, v.expr, v.len, field) } } else if position_context.implicit_selector_expr != nil { implicit_selector := position_context.implicit_selector_expr @@ -425,3 +437,30 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> return hover, false, true } + +@(private = "file") +get_soa_hover :: proc( + ast_context: ^AstContext, + selector: Symbol, + expr: ^ast.Expr, + size: ^ast.Expr, + field: string, +) -> ( + Hover, + bool, + bool, +) { + if .SoaPointer not_in selector.flags && .Soa not_in selector.flags { + return {}, false, true + } + if symbol, ok := resolve_soa_selector_field(ast_context, selector, expr, size, field); ok { + if selector.name != "" { + symbol.pkg = selector.name + } + build_documentation(ast_context, &symbol, false) + hover: Hover + hover.contents = write_hover_content(ast_context, symbol) + return hover, true, true + } + return {}, false, true +} |