aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-23 08:47:48 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-23 08:47:48 -0400
commit1089170576b4cc4b6330c6e9852cf3598a74991c (patch)
tree413cf6d0b34abc4fc1d50961a4ad4c1637aa0d90 /src
parent51c8693023acb0d5b2e6b80fbb9a31f44fc37fd6 (diff)
Resolve allocator field for container types on hover
Diffstat (limited to 'src')
-rw-r--r--src/server/analysis.odin20
-rw-r--r--src/server/hover.odin13
2 files changed, 33 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 076a7e7..7b78984 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -2625,6 +2625,26 @@ resolve_location_implicit_selector :: proc(
return symbol, ok
}
+resolve_container_allocator :: proc(ast_context: ^AstContext, container_name: string) -> (Symbol, bool) {
+ for built in indexer.builtin_packages {
+ if symbol, ok := lookup(container_name, built, ast_context.fullpath); ok {
+ if v, ok := symbol.value.(SymbolStructValue); ok {
+ for name, i in v.names {
+ if name == "allocator" {
+ if symbol, ok := resolve_type_expression(ast_context, v.types[i]); ok {
+ construct_struct_field_symbol(&symbol, container_name, v, i)
+ build_documentation(ast_context, &symbol, true)
+ return symbol, true
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return {}, false
+}
+
resolve_location_selector :: proc(ast_context: ^AstContext, selector_expr: ^ast.Node) -> (symbol: Symbol, ok: bool) {
reset_ast_context(ast_context)
diff --git a/src/server/hover.odin b/src/server/hover.odin
index bf64967..86fd6a8 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -356,9 +356,22 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
case SymbolSliceValue:
return get_soa_field_hover(&ast_context, selector, v.expr, nil, field)
case SymbolDynamicArrayValue:
+ if field == "allocator" {
+ if symbol, ok := resolve_container_allocator(&ast_context, "Raw_Dynamic_Array"); ok {
+ hover.contents = write_hover_content(&ast_context, symbol)
+ return hover, true, true
+ }
+ }
return get_soa_field_hover(&ast_context, selector, v.expr, nil, field)
case SymbolFixedArrayValue:
return get_soa_field_hover(&ast_context, selector, v.expr, v.len, field)
+ case SymbolMapValue:
+ if field == "allocator" {
+ if symbol, ok := resolve_container_allocator(&ast_context, "Raw_Map"); ok {
+ hover.contents = write_hover_content(&ast_context, symbol)
+ return hover, true, true
+ }
+ }
}
} else if position_context.implicit_selector_expr != nil {
implicit_selector := position_context.implicit_selector_expr