diff options
| -rw-r--r-- | src/server/hover.odin | 27 | ||||
| -rw-r--r-- | tests/hover_test.odin | 36 |
2 files changed, 63 insertions, 0 deletions
diff --git a/src/server/hover.odin b/src/server/hover.odin index 9e4e20c..d378696 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -234,6 +234,33 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> } } } + } else if position_context.implicit_selector_expr != nil { + implicit_selector := position_context.implicit_selector_expr + if symbol, ok := resolve_implicit_selector(&ast_context, &position_context, implicit_selector); ok { + #partial switch v in symbol.value { + case SymbolEnumValue: + for name, i in v.names { + if strings.compare(name, implicit_selector.field.name) == 0 { + symbol.pkg = symbol.name + symbol.name = name + hover.contents = write_hover_content(&ast_context, symbol) + return hover, true, true + } + } + case SymbolUnionValue: + if enum_value, ok := unwrap_super_enum(&ast_context, v); ok { + for name, i in enum_value.names { + if strings.compare(name, implicit_selector.field.name) == 0 { + symbol.pkg = symbol.name + symbol.name = name + hover.contents = write_hover_content(&ast_context, symbol) + return hover, true, true + } + } + } + } + } + return {}, false, true } else if position_context.identifier != nil { reset_ast_context(&ast_context) diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 9f1a9f0..dafc81c 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -376,6 +376,42 @@ ast_hover_proc_with_proc_parameter_with_return :: proc(t: ^testing.T) { test.expect_hover(t, &source, "test.aa: proc(p: proc() -> int)") } +@(test) +ast_hover_enum_implicit_selector :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: enum { + Foo1, + Foo2, + } + + foo: Foo + foo = .Fo{*}o1 + ` + } + + test.expect_hover(t, &source, "Foo.Foo1") +} + +@(test) +ast_hover_union_implicit_selector :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: enum { + Foo1, + Foo2, + } + + Bar :: union { Foo } + + bar: Bar + bar = .Fo{*}o1 + ` + } + + test.expect_hover(t, &source, "Bar.Foo1") +} + /* Waiting for odin fix |