diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-19 09:13:13 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-19 09:19:45 -0400 |
| commit | beeef74c3b73e1aced5de53d1b6102e1872fa164 (patch) | |
| tree | ac08de764ad7a655f61512a1f6d996c920916aa0 | |
| parent | 0ab1503c0460e41856b113ed641d1c843282cc83 (diff) | |
Add hover information for where clause variables
| -rw-r--r-- | src/server/analysis.odin | 7 | ||||
| -rw-r--r-- | tests/hover_test.odin | 13 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 3583a64..27b8f5c 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -4779,6 +4779,13 @@ get_document_position_node :: proc(node: ^ast.Node, position_context: ^DocumentP } else if position_in_node(n.type, position_context.position) { position_context.function = cast(^Proc_Lit)node get_document_position(n.type, position_context) + } else { + for clause in n.where_clauses { + if position_in_node(clause, position_context.position) { + position_context.function = cast(^Proc_Lit)node + get_document_position(clause, 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/tests/hover_test.odin b/tests/hover_test.odin index f6c7c45..65676f1 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -2636,6 +2636,19 @@ ast_hover_named_parameter_with_default_value_struct :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "foo.a: test.Bar :: struct {\n\tbar: int,\n}") } + +@(test) +ast_hover_inside_where_clause :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + foo :: proc(x: [2]int) + where len(x) > 1, + type_of(x{*}) == [2]int { + } + `, + } + test.expect_hover(t, &source, "test.x: [2]int") +} /* Waiting for odin fix |