diff options
| author | Damian Tarnawski <gthetarnav@gmail.com> | 2025-09-11 00:38:40 +0200 |
|---|---|---|
| committer | Damian Tarnawski <gthetarnav@gmail.com> | 2025-09-11 00:38:40 +0200 |
| commit | 23de8c183d052844f6b23b8ead9d03a33012af27 (patch) | |
| tree | 8ea4398b82bd8cdbe028ca1a774b3380c8e5daa9 /src/testing | |
| parent | 4f808a95f55a940d0dc013ca8b4fd1df427cc3da (diff) | |
Take expected inlay hints from the source code
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/testing.odin | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 57354e1..fed1510 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -532,12 +532,57 @@ expect_semantic_tokens :: proc(t: ^testing.T, src: ^Source, expected: []server.S } } -expect_inlay_hints :: proc(t: ^testing.T, src: ^Source, expected_hints: []server.InlayHint) { +expect_inlay_hints :: proc(t: ^testing.T, src: ^Source) { + + src_builder := strings.builder_make(context.temp_allocator) + expected_hints := make([dynamic]server.InlayHint, context.temp_allocator) + + { + last, line, col: int + saw_brackets: bool + for i:= 0; i < len(src.main); i += 1 { + if saw_brackets { + if i+1 < len(src.main) && src.main[i:i+2] == "]]" { + saw_brackets = false + hint_str := src.main[last:i] + last = i+2 + i += 1 + append(&expected_hints, server.InlayHint{ + position = {line, col}, + label = hint_str, + kind = .Parameter, + }) + } + } else { + if i+1 < len(src.main) && src.main[i:i+2] == "[[" { + strings.write_string(&src_builder, src.main[last:i]) + saw_brackets = true + last = i+2 + i += 1 + } else if src.main[i] == '\n' { + line += 1 + col = 0 + } else { + col += 1 + } + } + } + + if saw_brackets { + log.error("Unclosed inlay hint marker") + return + } + + strings.write_string(&src_builder, src.main[last:len(src.main)]) + } + + src.main = strings.to_string(src_builder) + setup(src) defer teardown(src) resolve_flag: server.ResolveReferenceFlag - symbols_and_nodes := server.resolve_entire_file(src.document, resolve_flag, context.temp_allocator) + symbols_and_nodes := server.resolve_entire_file(src.document, resolve_flag, ) hints, ok := server.get_inlay_hints(src.document, symbols_and_nodes, &src.config) if !ok { |