diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-12 13:34:12 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-12 13:34:12 -0400 |
| commit | 82c8a0b2cb1373afeb9f87339cc3aaccdffb31ff (patch) | |
| tree | 156ef3abf4ab47c82e154e20b7c5bc19ba3df0e6 /src | |
| parent | 3499fc72369763f6b20e39844a274c32e05f9d80 (diff) | |
Add comments when hovering basic struct fields and no longer show the underlying type
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/documentation.odin | 2 | ||||
| -rw-r--r-- | src/server/hover.odin | 29 | ||||
| -rw-r--r-- | src/server/symbol.odin | 5 |
3 files changed, 17 insertions, 19 deletions
diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 733851b..df0b523 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -174,7 +174,7 @@ get_short_signature :: proc(ast_context: ^AstContext, symbol: Symbol) -> string strings.write_string(&sb, pointer_prefix) build_string_node(v.ident, &sb, false) } - if symbol.type == .Field && symbol.comment != "" { + if symbol.comment != "" { fmt.sbprintf(&sb, " %s", symbol.comment) } return strings.to_string(sb) diff --git a/src/server/hover.odin b/src/server/hover.odin index 7ced6c1..7044ad2 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -165,19 +165,20 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> &ast_context, position_context.value_decl.names[0], ); ok { - symbol.type = .Field - symbol.range = common.get_token_range(field.node, ast_context.file.src) - symbol.type_name = symbol.name - symbol.type_pkg = symbol.pkg - symbol.pkg = struct_symbol.name - symbol.name = identifier.name if value, ok := struct_symbol.value.(SymbolStructValue); ok { + symbol.type = .Field + symbol.range = common.get_token_range(field.node, ast_context.file.src) + symbol.type_name = symbol.name + symbol.type_pkg = symbol.pkg + symbol.pkg = struct_symbol.name + symbol.name = identifier.name symbol.comment = get_comment(value.comments[field_index + name_index]) - } + symbol.doc = get_doc(value.docs[field_index + name_index], context.temp_allocator) - symbol.signature = get_short_signature(&ast_context, symbol) - hover.contents = write_hover_content(&ast_context, symbol) - return hover, true, true + symbol.signature = get_short_signature(&ast_context, symbol) + hover.contents = write_hover_content(&ast_context, symbol) + return hover, true, true + } } } } @@ -202,11 +203,11 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> symbol.type_pkg = symbol.pkg symbol.pkg = bit_field_symbol.name symbol.name = identifier.name - symbol.signature = get_bit_field_field_signature(value, i) - if value, ok := bit_field_symbol.value.(SymbolBitFieldValue); ok { symbol.comment = get_comment(value.comments[i]) + symbol.doc = get_doc(value.docs[i], context.temp_allocator) } + symbol.signature = get_bit_field_field_signature(value, i) hover.contents = write_hover_content(&ast_context, symbol) return hover, true, true } @@ -320,7 +321,9 @@ get_hover_information :: proc(document: ^Document, position: common.Position) -> symbol.type_pkg = symbol.pkg symbol.name = name symbol.pkg = selector.name - symbol.signature = get_signature(&ast_context, symbol) + symbol.comment = get_comment(v.comments[i]) + symbol.doc = get_doc(v.docs[i], context.temp_allocator) + symbol.signature = get_short_signature(&ast_context, symbol) hover.contents = write_hover_content(&ast_context, symbol) return hover, true, true } diff --git a/src/server/symbol.odin b/src/server/symbol.odin index 5ca9c17..08a6788 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -19,11 +19,6 @@ SymbolAndNode :: struct { node: ^ast.Node, } -UsingInfo :: struct { - from_index: int, - is_using: bool, -} - SymbolStructValue :: struct { names: []string, ranges: []common.Range, |