diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-21 10:00:48 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-21 10:00:48 -0400 |
| commit | 225b794cd3bbb0f116a4cf6e389aa5194c5eca46 (patch) | |
| tree | a9728e212a63dc84c9f1ed0e2a567ce62687375c | |
| parent | 405e8ede2eaf2fbccb6ffbaa6b24a434665b056d (diff) | |
Add `#type` to proc type hover information to distinguish with proc implementations
| -rw-r--r-- | src/server/documentation.odin | 6 | ||||
| -rw-r--r-- | tests/hover_test.odin | 24 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 965e331..bc9b12f 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -249,6 +249,9 @@ write_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, symbol: strings.write_string(sb, "}") return case SymbolProcedureValue: + if symbol.type == .Type_Function && depth == 0 { + strings.write_string(sb, "#type ") + } write_procedure_symbol_signature(sb, v, detailed_signature = true) return case SymbolBitFieldValue: @@ -342,6 +345,9 @@ write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, sy write_node(sb, ast_context, v.value, "", short_signature = true) return case SymbolProcedureValue: + if symbol.type == .Type_Function { + strings.write_string(sb, "#type ") + } write_procedure_symbol_signature(sb, v, detailed_signature = true) return case SymbolAggregateValue, SymbolProcedureGroupValue: diff --git a/tests/hover_test.odin b/tests/hover_test.odin index fc66f64..562a2d6 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -182,7 +182,7 @@ ast_hover_procedure_with_default_comp_lit :: proc(t: ^testing.T) { `, } - test.expect_hover(t, &source, "test.fa :: proc(color_: Color = {255, 255, 255, 255})") + test.expect_hover(t, &source, "test.fa :: #type proc(color_: Color = {255, 255, 255, 255})") } @(test) @@ -4958,6 +4958,28 @@ ast_hover_const_complex_comp_lit :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.COLOURS :: Colours {\n\tblue = frgba{0.1, 0.1, 0.1, 0.1},\n\tgreen = frgba{0.1, 0.1, 0.1, 0.1},\n\tfoo = {\n\t\ta = 32,\n\t\tb = \"testing\",\n\t},\n\tbar = 1 + 2,\n}") } + +@(test) +ast_hover_proc_type :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + f{*}oo :: proc(a: int) -> int + `, + } + test.expect_hover(t, &source, "test.foo :: #type proc(a: int) -> int") +} + +@(test) +ast_hover_proc_impl :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + f{*}oo :: proc(a: int) -> int { + return a + 1 + } + `, + } + test.expect_hover(t, &source, "test.foo :: proc(a: int) -> int") +} /* Waiting for odin fix |