diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-03-12 00:27:26 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-03-12 00:27:26 +0100 |
| commit | 207fe98a46b28297755608904dbf08d06fc50970 (patch) | |
| tree | ad50171aa05b2a7275243d722ec991c2afdd2278 /src/server/completion.odin | |
| parent | 447284f2366d8cf51ab4417427cdb3c079670282 (diff) | |
Support completion and gotos for comp literals in procs
Diffstat (limited to 'src/server/completion.odin')
| -rw-r--r-- | src/server/completion.odin | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 2f5c1ce..eb83432 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -222,57 +222,45 @@ get_comp_lit_completion :: proc( ) { items := make([dynamic]CompletionItem, context.temp_allocator) - if position_context.parent_comp_lit.type == nil { - return - } - if symbol, ok := resolve_type_expression( - ast_context, - position_context.parent_comp_lit.type, - ); ok { - if comp_symbol, _, ok := resolve_type_comp_literal( - ast_context, - position_context, - symbol, - position_context.parent_comp_lit, - ); ok { - ast_context.current_package = comp_symbol.pkg - #partial switch v in comp_symbol.value { - case SymbolStructValue: - for name, i in v.names { - if name == "_" { + if symbol, ok := resolve_comp_literal(ast_context, position_context); ok { + //ast_context.current_package = comp_symbol.pkg + #partial switch v in symbol.value { + case SymbolStructValue: + for name, i in v.names { + if name == "_" { + continue + } + + ast_context.current_package = symbol.pkg + + if resolved, ok := resolve_type_expression( + ast_context, + v.types[i], + ); ok { + if field_exists_in_comp_lit( + position_context.comp_lit, + name, + ) { continue } - ast_context.current_package = comp_symbol.pkg - - if resolved, ok := resolve_type_expression( - ast_context, - v.types[i], - ); ok { - if field_exists_in_comp_lit( - position_context.comp_lit, + item := CompletionItem { + label = name, + kind = .Field, + detail = fmt.tprintf( + "%v.%v: %v", + symbol.name, name, - ) { - continue - } - - item := CompletionItem { - label = name, - kind = .Field, - detail = fmt.tprintf( - "%v.%v: %v", - comp_symbol.name, - name, - common.node_to_string(v.types[i]), - ), - documentation = resolved.doc, - } - - append(&items, item) + common.node_to_string(v.types[i]), + ), + documentation = resolved.doc, } + + append(&items, item) } } + } } |