diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-10-17 05:02:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-17 05:02:52 -0400 |
| commit | 5ca256c325a1a122d838e095e392ca00c39a632e (patch) | |
| tree | ae71fb1ef49260a762d81c2cbb2f153728b6593b | |
| parent | b596ac80787fec7b53502c59cba39c03a4b80421 (diff) | |
| parent | 4213491d0f51025900cd4fb6d7396eb00edf088a (diff) | |
Merge pull request #1102 from BradLewis/fix/switch-struct-using-tracker-to-da
| -rw-r--r-- | src/server/collector.odin | 6 | ||||
| -rw-r--r-- | src/server/document_symbols.odin | 1 | ||||
| -rw-r--r-- | src/server/documentation.odin | 5 | ||||
| -rw-r--r-- | src/server/symbol.odin | 36 |
4 files changed, 21 insertions, 27 deletions
diff --git a/src/server/collector.odin b/src/server/collector.odin index bd6d040..8dcb794 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -1,13 +1,9 @@ package server -import "core:fmt" -import "core:hash" -import "core:log" import "core:mem" import "core:odin/ast" import "core:path/filepath" import path "core:path/slashpath" -import "core:strconv" import "core:strings" import "src:common" @@ -153,7 +149,7 @@ collect_struct_fields :: proc( if .Using in field.flags { append(&b.unexpanded_usings, len(b.names) - 1) - b.usings[len(b.names) - 1] = struct{}{} + append(&b.usings, len(b.names) - 1) } append(&b.ranges, common.get_token_range(n, file.src)) diff --git a/src/server/document_symbols.odin b/src/server/document_symbols.odin index 64fd820..8d6d801 100644 --- a/src/server/document_symbols.odin +++ b/src/server/document_symbols.odin @@ -1,6 +1,5 @@ package server -import "core:log" import "core:odin/ast" import "src:common" diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 65b9139..42afe6e 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -2,7 +2,6 @@ package server import "core:fmt" -import "core:log" import "core:odin/ast" import path "core:path/slashpath" import "core:strings" @@ -651,7 +650,7 @@ write_struct_hover :: proc(sb: ^strings.Builder, ast_context: ^AstContext, v: Sy longestNameLen := 0 for name, i in v.names { l := len(name) - if _, ok := v.usings[i]; ok { + if symbol_struct_value_has_using(v, i) { l += len(using_prefix) } if l > longestNameLen { @@ -692,7 +691,7 @@ write_struct_hover :: proc(sb: ^strings.Builder, ast_context: ^AstContext, v: Sy write_indent(sb, depth + 1) name_len := len(v.names[i]) - if _, ok := v.usings[i]; ok { + if symbol_struct_value_has_using(v, i) { strings.write_string(sb, using_prefix) name_len += len(using_prefix) } diff --git a/src/server/symbol.odin b/src/server/symbol.odin index caec706..d4be282 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -1,16 +1,9 @@ package server -import "core:fmt" -import "core:hash" -import "core:log" import "core:mem" import "core:odin/ast" -import "core:odin/parser" import "core:odin/tokenizer" -import "core:path/filepath" -import path "core:path/slashpath" import "core:slice" -import "core:strings" import "src:common" @@ -31,7 +24,7 @@ SymbolStructValue :: struct { names: []string, ranges: []common.Range, types: []^ast.Expr, - usings: map[int]struct{}, + usings: []int, from_usings: []int, unexpanded_usings: []int, poly: ^ast.Field_List, @@ -52,6 +45,15 @@ SymbolStructValue :: struct { tags: SymbolStructTags, } +symbol_struct_value_has_using :: proc(v: SymbolStructValue, index: int) -> bool { + for u in v.usings { + if u == index { + return true + } + } + return false +} + SymbolBitFieldValue :: struct { backing_type: ^ast.Expr, names: []string, @@ -253,7 +255,7 @@ SymbolStructValueBuilder :: struct { ranges: [dynamic]common.Range, docs: [dynamic]^ast.Comment_Group, comments: [dynamic]^ast.Comment_Group, - usings: map[int]struct{}, + usings: [dynamic]int, from_usings: [dynamic]int, unexpanded_usings: [dynamic]int, poly: ^ast.Field_List, @@ -279,9 +281,7 @@ symbol_struct_value_builder_make_none :: proc(allocator := context.allocator) -> ranges = make([dynamic]common.Range, allocator), docs = make([dynamic]^ast.Comment_Group, allocator), comments = make([dynamic]^ast.Comment_Group, allocator), - // Set it to an arbitary size due to issues with crashes - // See https://github.com/DanielGavin/ols/issues/787 - usings = make(map[int]struct{}, 16, allocator), + usings = make([dynamic]int, allocator), from_usings = make([dynamic]int, allocator), unexpanded_usings = make([dynamic]int, allocator), poly_names = make([dynamic]string, allocator), @@ -303,7 +303,7 @@ symbol_struct_value_builder_make_symbol :: proc( ranges = make([dynamic]common.Range, allocator), docs = make([dynamic]^ast.Comment_Group, allocator), comments = make([dynamic]^ast.Comment_Group, allocator), - usings = make(map[int]struct{}, allocator), + usings = make([dynamic]int, allocator), from_usings = make([dynamic]int, allocator), unexpanded_usings = make([dynamic]int, allocator), poly_names = make([dynamic]string, allocator), @@ -326,7 +326,7 @@ symbol_struct_value_builder_make_symbol_symbol_struct_value :: proc( ranges = slice.to_dynamic(v.ranges, allocator), docs = slice.to_dynamic(v.docs, allocator), comments = slice.to_dynamic(v.comments, allocator), - usings = v.usings, + usings = slice.to_dynamic(v.usings, allocator), from_usings = slice.to_dynamic(v.from_usings, allocator), unexpanded_usings = slice.to_dynamic(v.unexpanded_usings, allocator), poly_names = slice.to_dynamic(v.poly_names, allocator), @@ -360,7 +360,7 @@ to_symbol_struct_value :: proc(b: SymbolStructValueBuilder) -> SymbolStructValue args = b.args[:], docs = b.docs[:], comments = b.comments[:], - usings = b.usings, + usings = b.usings[:], from_usings = b.from_usings[:], unexpanded_usings = b.unexpanded_usings[:], poly = b.poly, @@ -391,7 +391,7 @@ write_struct_type :: proc( if identifier, ok := n.derived.(^ast.Ident); ok && field.type != nil { if .Using in field.flags { append(&b.unexpanded_usings, len(b.types)) - b.usings[len(b.types)] = struct{}{} + append(&b.usings, len(b.types)) } append(&b.names, identifier.name) @@ -485,7 +485,7 @@ write_symbol_struct_value :: proc( b.bit_sizes[k + base_index] = value } for k in v.usings { - b.usings[k + base_index] = struct{}{} + append(&b.usings, k + base_index) } expand_usings(ast_context, b) } @@ -534,7 +534,7 @@ expand_usings :: proc(ast_context: ^AstContext, b: ^SymbolStructValueBuilder) { continue } - b.usings[u] = struct{}{} + append(&b.usings, u) derived := field_expr.derived if ptr, ok := field_expr.derived.(^ast.Pointer_Type); ok { |