From 75add788487b2a4a1b5069484b97818142555ed0 Mon Sep 17 00:00:00 2001 From: Damian Tarnawski Date: Mon, 29 Jul 2024 01:17:44 +0200 Subject: Correct collecting symbols for array types --- src/server/collector.odin | 32 ++++++++++++++++---------------- src/testing/testing.odin | 20 ++++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/server/collector.odin b/src/server/collector.odin index bdc69a6..92b4137 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -313,38 +313,38 @@ collect_slice :: proc( collection: ^SymbolCollection, array: ast.Array_Type, package_map: map[string]string, -) -> SymbolFixedArrayValue { +) -> SymbolSliceValue { elem := clone_type( array.elem, collection.allocator, &collection.unique_strings, ) - len := clone_type( - array.len, - collection.allocator, - &collection.unique_strings, - ) replace_package_alias(elem, package_map, collection) - replace_package_alias(len, package_map, collection) - return SymbolFixedArrayValue{expr = elem, len = len} + return SymbolSliceValue{expr = elem} } collect_array :: proc( collection: ^SymbolCollection, array: ast.Array_Type, package_map: map[string]string, -) -> SymbolSliceValue { +) -> SymbolFixedArrayValue { elem := clone_type( array.elem, collection.allocator, &collection.unique_strings, ) + len := clone_type( + array.len, + collection.allocator, + &collection.unique_strings, + ) replace_package_alias(elem, package_map, collection) + replace_package_alias(len, package_map, collection) - return SymbolSliceValue{expr = elem} + return SymbolFixedArrayValue{expr = elem, len = len} } collect_map :: proc( @@ -610,7 +610,7 @@ collect_symbols :: proc( #partial switch v in col_expr.derived { case ^ast.Matrix_Type: token = v^ - token_type = .Variable + token_type = .Type symbol.value = collect_matrix(collection, v^, package_map) case ^ast.Proc_Lit: token = v^ @@ -636,7 +636,7 @@ collect_symbols :: proc( } case ^ast.Proc_Type: token = v^ - token_type = .Function + token_type = .Type_Function symbol.value = collect_procedure_fields( collection, cast(^ast.Proc_Type)col_expr, @@ -706,11 +706,11 @@ collect_symbols :: proc( symbol.signature = "bit_field" case ^ast.Map_Type: token = v^ - token_type = .Variable + token_type = .Type symbol.value = collect_map(collection, v^, package_map) case ^ast.Array_Type: token = v^ - token_type = .Variable + token_type = .Type if v.len == nil { symbol.value = collect_slice(collection, v^, package_map) } else { @@ -718,11 +718,11 @@ collect_symbols :: proc( } case ^ast.Dynamic_Array_Type: token = v^ - token_type = .Variable + token_type = .Type symbol.value = collect_dynamic_array(collection, v^, package_map) case ^ast.Multi_Pointer_Type: token = v^ - token_type = .Variable + token_type = .Type symbol.value = collect_multi_pointer(collection, v^, package_map) case ^ast.Typeid_Type: if v.specialization == nil { diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 0d9c028..a9b8362 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -329,18 +329,18 @@ expect_hover :: proc( log.error(t, "Failed get_hover_information") } - if expect_hover_string == "" && hover.contents.value != "" { + /* + ```odin\n + content\n + ``` + */ + content_without_markdown := hover.contents.value[8:len(hover.contents.value)-5] + + if content_without_markdown != expect_hover_string { log.errorf( - "Expected empty hover string, but received %v", - hover.contents.value, - ) - } - - if !strings.contains(hover.contents.value, expect_hover_string) { - log.errorf( - "Expected hover string %v, but received %v", + "Expected hover string:\n\"%v\", but received:\n\"%v\"", expect_hover_string, - hover.contents.value, + content_without_markdown, ) } } -- cgit v1.2.3