diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-04-15 23:20:50 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-04-15 23:20:50 +0200 |
| commit | 25de95df4262c318de7ded5bdc5ca027ab6d4872 (patch) | |
| tree | 11a8d879f9182a70bd8ef54283344266b04667db /src/server/completion.odin | |
| parent | aa1aabda1cce68a6038c48429cc759f09ad2ebab (diff) | |
support bit_fields
They are pretty similar to structs (just a bit simpler) so I piggy backed
of that a lot here, added some basic tests and tested the formatting
myself.
Diffstat (limited to 'src/server/completion.odin')
| -rw-r--r-- | src/server/completion.odin | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index caba5bf..f917498 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -260,7 +260,40 @@ get_comp_lit_completion :: proc( append(&items, item) } } + case SymbolBitFieldValue: + 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 + } + item := CompletionItem { + label = name, + kind = .Field, + detail = fmt.tprintf( + "%v.%v: %v", + symbol.name, + name, + common.node_to_string(v.types[i]), + ), + documentation = resolved.doc, + } + + append(&items, item) + } + } } } @@ -609,6 +642,52 @@ get_selector_completion :: proc( } } + case SymbolBitFieldValue: + list.isIncomplete = false + + for name, i in v.names { + if name == "_" { + continue + } + + if selector.pkg != "" { + ast_context.current_package = selector.pkg + } else { + ast_context.current_package = ast_context.document_package + } + + if symbol, ok := resolve_type_expression(ast_context, v.types[i]); + ok { + item := CompletionItem { + label = name, + kind = .Field, + detail = fmt.tprintf( + "%v.%v: %v", + selector.name, + name, + type_to_string(ast_context, v.types[i]), + ), + documentation = symbol.doc, + } + + append(&items, item) + } else { + //just give some generic symbol with name. + item := CompletionItem { + label = symbol.name, + kind = .Field, + detail = fmt.tprintf( + "%v: %v", + name, + common.node_to_string(v.types[i]), + ), + documentation = symbol.doc, + } + + append(&items, item) + } + } + case SymbolPackageValue: list.isIncomplete = true |