diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-03 21:20:29 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-04 20:39:31 -0400 |
| commit | d91f1da376e12f7ea8eef54528dc6f5ace6cf8bb (patch) | |
| tree | 94314490b8abe972f369217b6e5991c558dcee25 /src/server/collector.odin | |
| parent | c7c76658be61af1532c0320dc0029e5b39f1c6fd (diff) | |
Enrich bit field hover documentation
Diffstat (limited to 'src/server/collector.odin')
| -rw-r--r-- | src/server/collector.odin | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/server/collector.odin b/src/server/collector.odin index 22aba08..f4e4a1c 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -158,15 +158,19 @@ collect_struct_fields :: proc( collect_bit_field_fields :: proc( collection: ^SymbolCollection, - fields: []^ast.Bit_Field_Field, + bit_field_type: ^ast.Bit_Field_Type, package_map: map[string]string, file: ast.File, ) -> SymbolBitFieldValue { - names := make([dynamic]string, 0, len(fields), collection.allocator) - types := make([dynamic]^ast.Expr, 0, len(fields), collection.allocator) - ranges := make([dynamic]common.Range, 0, len(fields), collection.allocator) - - for field, i in fields { + construct_bit_field_field_docs(file, bit_field_type) + names := make([dynamic]string, 0, len(bit_field_type.fields), collection.allocator) + types := make([dynamic]^ast.Expr, 0, len(bit_field_type.fields), collection.allocator) + ranges := make([dynamic]common.Range, 0, len(bit_field_type.fields), collection.allocator) + docs := make([dynamic]^ast.Comment_Group, 0, collection.allocator) + comments := make([dynamic]^ast.Comment_Group, 0, collection.allocator) + bit_sizes := make([dynamic]^ast.Expr, 0, collection.allocator) + + for field, i in bit_field_type.fields { if ident, ok := field.name.derived.(^ast.Ident); ok { append(&names, get_index_unique_string(collection, ident.name)) @@ -175,13 +179,20 @@ collect_bit_field_fields :: proc( append(&types, cloned) append(&ranges, common.get_token_range(ident, file.src)) + append(&docs, clone_comment_group(field.docs, collection.allocator, &collection.unique_strings)) + append(&comments, clone_comment_group(field.comments, collection.allocator, &collection.unique_strings)) + append(&bit_sizes, clone_type(field.bit_size, collection.allocator, &collection.unique_strings)) } } value := SymbolBitFieldValue { - names = names[:], - types = types[:], - ranges = ranges[:], + backing_type = clone_type(bit_field_type.backing_type, collection.allocator, &collection.unique_strings), + names = names[:], + types = types[:], + ranges = ranges[:], + docs = docs[:], + comments = comments[:], + bit_sizes = bit_sizes[:], } return value @@ -547,7 +558,7 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri case ^ast.Bit_Field_Type: token = v^ token_type = .Struct - symbol.value = collect_bit_field_fields(collection, v.fields, package_map, file) + symbol.value = collect_bit_field_fields(collection, v, package_map, file) symbol.signature = "bit_field" case ^ast.Map_Type: token = v^ |