diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-06-09 12:55:24 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-06-09 12:55:24 +0200 |
| commit | 33b5b66a53fef0ea3fd9ccec4841290050cd95f4 (patch) | |
| tree | 3e656887b76fed9b1cc1b59bf0addd04f7596f74 /src | |
| parent | ada14e0c911a11129daafbd486386e761661f40b (diff) | |
Improve reference testing
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/analysis.odin | 4 | ||||
| -rw-r--r-- | src/server/file_resolve.odin | 4 | ||||
| -rw-r--r-- | src/server/references.odin | 10 | ||||
| -rw-r--r-- | src/server/symbol.odin | 2 | ||||
| -rw-r--r-- | src/testing/testing.odin | 25 |
5 files changed, 21 insertions, 24 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index acd5733..7b4d125 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -4797,14 +4797,14 @@ get_document_position_node :: proc( case ^Ellipsis: get_document_position(n.expr, position_context) case ^Proc_Lit: - get_document_position(n.type, position_context) - if position_in_node(n.body, position_context.position) { + get_document_position(n.type, position_context) position_context.function = cast(^Proc_Lit)node append(&position_context.functions, position_context.function) get_document_position(n.body, position_context) } else if position_in_node(n.type, position_context.position) { position_context.function = cast(^Proc_Lit)node + get_document_position(n.type, position_context) } case ^Comp_Lit: //only set this for the parent comp literal, since we will need to walk through it to infer types. diff --git a/src/server/file_resolve.odin b/src/server/file_resolve.odin index d6119c5..3c1ed17 100644 --- a/src/server/file_resolve.odin +++ b/src/server/file_resolve.odin @@ -142,7 +142,6 @@ resolve_node :: proc(node: ^ast.Node, data: ^FileResolveData) { case ^Bad_Expr: case ^Ident: data.position_context.identifier = node - if data.flag != .None { if symbol, ok := resolve_location_identifier(data.ast_context, n^); ok { @@ -421,10 +420,9 @@ resolve_node :: proc(node: ^ast.Node, data: ^FileResolveData) { }, } } - } else { - resolve_nodes(n.names, data) } + resolve_nodes(n.names, data) resolve_node(n.type, data) resolve_node(n.default_value, data) case ^Field_List: diff --git a/src/server/references.odin b/src/server/references.odin index a23d968..f82a80e 100644 --- a/src/server/references.odin +++ b/src/server/references.odin @@ -36,9 +36,15 @@ walk_directories :: proc( } if strings.contains(info.name, ".odin") { - slash_path, _ := filepath.to_slash(info.fullpath) + slash_path, _ := filepath.to_slash( + info.fullpath, + context.temp_allocator, + ) if slash_path != document.fullpath { - append(&fullpaths, strings.clone(info.fullpath)) + append( + &fullpaths, + strings.clone(info.fullpath, context.temp_allocator), + ) } } diff --git a/src/server/symbol.odin b/src/server/symbol.odin index 2e9aa27..9e0f154 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -215,6 +215,7 @@ free_symbol :: proc(symbol: Symbol, allocator: mem.Allocator) { common.free_ast(v.arg_types, allocator) case SymbolStructValue: delete(v.names, allocator) + delete(v.ranges, allocator) common.free_ast(v.types, allocator) case SymbolGenericValue: common.free_ast(v.expr, allocator) @@ -248,6 +249,7 @@ free_symbol :: proc(symbol: Symbol, allocator: mem.Allocator) { case SymbolPackageValue: case SymbolBitFieldValue: delete(v.names, allocator) + delete(v.ranges, allocator) common.free_ast(v.types, allocator) } } diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 2a08b23..210db59 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -384,42 +384,33 @@ expect_definition_locations :: proc( } } -expect_symbol_location :: proc( +expect_reference_locations :: proc( t: ^testing.T, src: ^Source, - flag: server.ResolveReferenceFlag, expect_locations: []common.Location, ) { setup(src) defer teardown(src) - symbol_and_nodes := server.resolve_entire_file( - src.document, - flag, - context.temp_allocator, - ) - - ok := true + locations, ok := server.get_references(src.document, src.position) - for location in expect_locations { + for expect_location in expect_locations { match := false - for k, v in symbol_and_nodes { - if v.symbol.range == location.range { + for location in locations { + if location.range == expect_location.range { match = true } } if !match { ok = false - log.errorf("Failed to match with location: %v", location) + log.errorf("Failed to match with location: %v", expect_location) } } if !ok { log.error("Received:") - for k, v in symbol_and_nodes { - log.errorf("%v \n", v.symbol) + for location in locations { + log.errorf("%v \n", location) } } - - } |