diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-10-11 20:11:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-11 20:11:33 -0400 |
| commit | cbb4e352197763b0475ed3be6650fc9fe08d9c99 (patch) | |
| tree | 376fe061ecd3e88ffd5cabf382db9aedda1f0cf4 /src | |
| parent | 3e9dc7f8353edd0ef389005fbf98a900e8007b6c (diff) | |
| parent | a2b472d5fd8169de682e144b5dc76c99a24fe96c (diff) | |
Merge pull request #1087 from BradLewis/feat/proc-group-implicit-selector
Feat/proc group implicit selector
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/analysis.odin | 34 | ||||
| -rw-r--r-- | src/server/hover.odin | 2 |
2 files changed, 31 insertions, 5 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 3c896fe..ff94e41 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -729,7 +729,7 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou if !resolve_all_possibilities { arg_count := get_proc_arg_count(procedure) - if call_expr != nil && arg_count < call_unnamed_arg_count { + if call_expr != nil && arg_count < len(call_expr.args) { break next_fn } } @@ -747,6 +747,7 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou arg_symbol: Symbol ok: bool is_call_arg_nil: bool + implicit_selector: ^ast.Implicit_Selector_Expr if _, ok = call_arg.derived.(^ast.Bad_Expr); ok { continue @@ -755,9 +756,13 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou //named parameter if field, is_field := call_arg.derived.(^ast.Field_Value); is_field { named = true - if ident, is_ident := field.field.derived.(^ast.Ident); is_ident && ident.name == "nil" { + if ident, is_ident := field.value.derived.(^ast.Ident); is_ident && ident.name == "nil" { is_call_arg_nil = true ok = true + } else if implicit, is_implicit := field.value.derived.(^ast.Implicit_Selector_Expr); + is_implicit { + implicit_selector = implicit + ok = true } else { call_symbol, ok = resolve_call_arg_type_expression(ast_context, field.value) if !ok { @@ -781,6 +786,10 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou if ident, is_ident := call_arg.derived.(^ast.Ident); is_ident && ident.name == "nil" { is_call_arg_nil = true ok = true + } else if implicit, is_implicit_selector := call_arg.derived.(^ast.Implicit_Selector_Expr); + is_implicit_selector { + implicit_selector = implicit + ok = true } else { call_symbol, ok = resolve_call_arg_type_expression(ast_context, call_arg) } @@ -790,6 +799,7 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou break next_fn } + if p, ok := call_symbol.value.(SymbolProcedureValue); ok { if len(p.return_types) != 1 { break next_fn @@ -822,6 +832,23 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou break next_fn } + if implicit_selector != nil { + if value, ok := arg_symbol.value.(SymbolEnumValue); ok { + found: bool + for name in value.names { + if implicit_selector.field.name == name { + found = true + break + } + } + if found { + continue + } + + } + break next_fn + } + if is_call_arg_nil { if is_valid_nil_symbol(arg_symbol) { continue @@ -2296,7 +2323,6 @@ resolve_implicit_selector_comp_literal :: proc( resolve_implicit_selector :: proc( ast_context: ^AstContext, position_context: ^DocumentPositionContext, - selector_expr: ^ast.Implicit_Selector_Expr, ) -> ( Symbol, bool, @@ -2787,7 +2813,7 @@ resolve_location_implicit_selector :: proc( set_ast_package_set_scoped(ast_context, ast_context.document_package) - symbol = resolve_implicit_selector(ast_context, position_context, implicit_selector) or_return + symbol = resolve_implicit_selector(ast_context, position_context) or_return #partial switch v in symbol.value { case SymbolEnumValue: diff --git a/src/server/hover.odin b/src/server/hover.odin index 89935ea..20651e4 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -373,7 +373,7 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> } else if position_context.implicit_selector_expr != nil { implicit_selector := position_context.implicit_selector_expr hover.range = common.get_token_range(implicit_selector, document.ast.src) - if symbol, ok := resolve_implicit_selector(&ast_context, &position_context, implicit_selector); ok { + if symbol, ok := resolve_implicit_selector(&ast_context, &position_context); ok { #partial switch v in symbol.value { case SymbolEnumValue: for name, i in v.names { |