aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/analysis.odin44
-rw-r--r--src/server/completion.odin3
2 files changed, 32 insertions, 15 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index ff94e41..32d38eb 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -2096,21 +2096,8 @@ internal_resolve_comp_literal :: proc(
symbol = resolve_proc(ast_context, position_context.parent_comp_lit.type) or_return
} else if position_context.call != nil {
if call_expr, ok := position_context.call.derived.(^ast.Call_Expr); ok {
- arg_index := find_position_in_call_param(position_context, call_expr^) or_return
-
- symbol = resolve_proc(ast_context, position_context.call) or_return
-
- value := symbol.value.(SymbolProcedureValue) or_return
-
- if len(value.arg_types) <= arg_index {
- return {}, false
- }
-
- if value.arg_types[arg_index].type == nil {
- return {}, false
- }
-
- symbol = resolve_proc(ast_context, value.arg_types[arg_index].type) or_return
+ type := get_call_argument_type(ast_context, position_context, call_expr) or_return
+ symbol = resolve_proc(ast_context, type) or_return
}
} else if position_context.returns != nil {
return_index: int
@@ -3151,6 +3138,33 @@ find_position_in_call_param :: proc(position_context: ^DocumentPositionContext,
return len(call.args) - 1, true
}
+get_call_argument_type :: proc(
+ ast_context: ^AstContext,
+ position_context: ^DocumentPositionContext,
+ call: ^ast.Call_Expr,
+) -> (
+ expr: ^ast.Expr,
+ ok: bool,
+) {
+ index := find_position_in_call_param(position_context, call^) or_return
+ symbol := resolve_type_expression(ast_context, call) or_return
+ value := symbol.value.(SymbolProcedureValue) or_return
+
+ arg: ^ast.Field
+ if field, ok := call.args[index].derived.(^ast.Field_Value); ok {
+ ident := field.field.derived.(^ast.Ident) or_return
+ arg = get_proc_arg_type_from_name(value, ident.name) or_return
+ } else {
+ arg = get_proc_arg_type_from_index(value, index) or_return
+ }
+
+ if arg.type == nil {
+ return arg.default_value, true
+ }
+
+ return arg.type, true
+}
+
make_pointer_ast :: proc(ast_context: ^AstContext, elem: ^ast.Expr) -> ^ast.Pointer_Type {
pointer := new_type(ast.Pointer_Type, elem.pos, elem.end, ast_context.allocator)
pointer.elem = elem
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 5d39109..f1bd9a8 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -1353,6 +1353,9 @@ get_implicit_completion :: proc(
return is_incomplete
} else if s, ok := unwrap_bitset(ast_context, comp_symbol); ok {
for enum_name in s.names {
+ if field_exists_in_comp_lit(position_context.comp_lit, enum_name) {
+ continue
+ }
item := CompletionItem {
label = enum_name,
kind = .EnumMember,