aboutsummaryrefslogtreecommitdiff
path: root/src/server/analysis.odin
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-08 10:08:55 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-08 10:24:18 -0400
commit9a4bec40896d034ab0814dd80318b03cb39ca162 (patch)
tree87abc02290922b66ce2060a86ea0ba943cc63641 /src/server/analysis.odin
parent7d334f6c9fff565b5d51c30e13db810f466e6241 (diff)
Provide full path for union enum completion labels
Diffstat (limited to 'src/server/analysis.odin')
-rw-r--r--src/server/analysis.odin24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index ac3680c..5985fea 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -3484,17 +3484,19 @@ unwrap_ident :: proc(node: ^ast.Expr) -> (^ast.Ident, bool) {
return {}, false
}
-unwrap_enum :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (SymbolEnumValue, bool) {
+// Returns the unwrapped enum, whether it unwrapped a super enum, whether it was successful
+unwrap_enum :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (SymbolEnumValue, bool, bool) {
if node == nil {
- return {}, false
+ return {}, false, false
}
if enum_symbol, ok := resolve_type_expression(ast_context, node); ok {
#partial switch value in enum_symbol.value {
case SymbolEnumValue:
- return value, true
+ return value, false, true
case SymbolUnionValue:
- return unwrap_super_enum(ast_context, value)
+ result, ok := unwrap_super_enum(ast_context, value)
+ return result, true, ok
case SymbolSliceValue:
return unwrap_enum(ast_context, value.expr)
case SymbolFixedArrayValue:
@@ -3506,7 +3508,7 @@ unwrap_enum :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (SymbolEnumVal
}
}
- return {}, false
+ return {}, false, false
}
unwrap_super_enum :: proc(
@@ -3522,7 +3524,17 @@ unwrap_super_enum :: proc(
for type in symbol_union.types {
symbol := resolve_type_expression(ast_context, type) or_return
if value, ok := symbol.value.(SymbolEnumValue); ok {
- append(&names, ..value.names)
+ for name in value.names {
+ if ast_context.current_package != symbol.pkg {
+ pkg_name := get_pkg_name(ast_context, symbol.pkg)
+ append(
+ &names,
+ fmt.aprintf("%s.%s.%s", pkg_name, symbol.name, name, allocator = ast_context.allocator),
+ )
+ } else {
+ append(&names, fmt.aprintf("%s.%s", symbol.name, name, allocator = ast_context.allocator))
+ }
+ }
append(&ranges, ..value.ranges)
}
}