From 8816d531da666959b7df0c64401b8fa064b0cd3d Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Mon, 9 Jun 2025 14:32:59 -0400 Subject: Add textDocument/typeDefinition support --- src/testing/testing.odin | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/testing') diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 87f740a..0fff9d6 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -290,6 +290,45 @@ expect_definition_locations :: proc(t: ^testing.T, src: ^Source, expect_location } } +expect_type_definition_locations :: proc(t: ^testing.T, src: ^Source, expect_locations: []common.Location) { + setup(src) + defer teardown(src) + + locations, ok := server.get_type_definition_locations(src.document, src.position) + + if !ok { + log.error("Failed get_definition_location") + } + + if len(expect_locations) == 0 && len(locations) > 0 { + log.errorf("Expected empty locations, but received %v", locations) + } + + flags := make([]int, len(expect_locations), context.temp_allocator) + + for expect_location, i in expect_locations { + for location, j in locations { + if expect_location.uri != "" { + if location.range == expect_location.range && location.uri == expect_location.uri { + flags[i] += 1 + } + } else if location.range == expect_location.range { + flags[i] += 1 + } + } + } + + for flag, i in flags { + if flag != 1 { + if expect_locations[i].uri == "" { + log.errorf("Expected location %v, but received %v", expect_locations[i].range, locations) + } else { + log.errorf("Expected location %v, but received %v", expect_locations[i], locations) + } + } + } +} + expect_reference_locations :: proc(t: ^testing.T, src: ^Source, expect_locations: []common.Location) { setup(src) defer teardown(src) -- cgit v1.2.3