aboutsummaryrefslogtreecommitdiff
path: root/src/server/hover.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/hover.odin')
-rw-r--r--src/server/hover.odin43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/server/hover.odin b/src/server/hover.odin
index 2c68ad0..03cdedf 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -153,7 +153,12 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
position_context.value_decl.names[0],
); ok {
if value, ok := struct_symbol.value.(SymbolStructValue); ok {
- construct_struct_field_symbol(&symbol, struct_symbol.name, value, field_index+name_index)
+ construct_struct_field_symbol(
+ &symbol,
+ struct_symbol.name,
+ value,
+ field_index + name_index,
+ )
build_documentation(&ast_context, &symbol, true)
hover.contents = write_hover_content(&ast_context, symbol)
return hover, true, true
@@ -188,7 +193,8 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
}
}
- if position_context.field_value != nil && position_in_node(position_context.field_value.field, position_context.position) {
+ if position_context.field_value != nil &&
+ position_in_node(position_context.field_value.field, position_context.position) {
if position_context.comp_lit != nil {
if comp_symbol, ok := resolve_comp_literal(&ast_context, &position_context); ok {
if field, ok := position_context.field_value.field.derived.(^ast.Ident); ok {
@@ -347,6 +353,12 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
return hover, true, true
}
}
+ case SymbolSliceValue:
+ return get_soa_hover(&ast_context, selector, v.expr, nil, field)
+ case SymbolDynamicArrayValue:
+ return get_soa_hover(&ast_context, selector, v.expr, nil, field)
+ case SymbolFixedArrayValue:
+ return get_soa_hover(&ast_context, selector, v.expr, v.len, field)
}
} else if position_context.implicit_selector_expr != nil {
implicit_selector := position_context.implicit_selector_expr
@@ -425,3 +437,30 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
return hover, false, true
}
+
+@(private = "file")
+get_soa_hover :: proc(
+ ast_context: ^AstContext,
+ selector: Symbol,
+ expr: ^ast.Expr,
+ size: ^ast.Expr,
+ field: string,
+) -> (
+ Hover,
+ bool,
+ bool,
+) {
+ if .SoaPointer not_in selector.flags && .Soa not_in selector.flags {
+ return {}, false, true
+ }
+ if symbol, ok := resolve_soa_selector_field(ast_context, selector, expr, size, field); ok {
+ if selector.name != "" {
+ symbol.pkg = selector.name
+ }
+ build_documentation(ast_context, &symbol, false)
+ hover: Hover
+ hover.contents = write_hover_content(ast_context, symbol)
+ return hover, true, true
+ }
+ return {}, false, true
+}