diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-19 20:10:50 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-22 18:48:36 -0400 |
| commit | dc8fdcb3d55d613dc71044e7a549b15b00e12cc7 (patch) | |
| tree | 952fa71105631f61758072c96a03873d578403ba /src/server | |
| parent | ddd6485f6ea68e445ee893721b2696aa2ab91bc4 (diff) | |
Add proc attribute to hover information
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/analysis.odin | 1 | ||||
| -rw-r--r-- | src/server/collector.odin | 8 | ||||
| -rw-r--r-- | src/server/documentation.odin | 35 | ||||
| -rw-r--r-- | src/server/symbol.odin | 1 |
4 files changed, 45 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 8b4e3f9..53f42c2 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2802,6 +2802,7 @@ make_symbol_procedure_from_ast :: proc( diverging = v.diverging, calling_convention = v.calling_convention, tags = v.tags, + attributes = attributes, } if _, ok := get_attribute_objc_name(attributes); ok { diff --git a/src/server/collector.odin b/src/server/collector.odin index fc4f603..ffff688 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -87,6 +87,7 @@ collect_procedure_fields :: proc( ) -> SymbolProcedureValue { returns := make([dynamic]^ast.Field, 0, collection.allocator) args := make([dynamic]^ast.Field, 0, collection.allocator) + attrs := make([dynamic]^ast.Attribute, 0, collection.allocator) if return_list != nil { for ret in return_list.list { @@ -104,6 +105,12 @@ collect_procedure_fields :: proc( } } + for attr in attributes { + cloned := cast(^ast.Attribute)clone_type(attr, collection.allocator, &collection.unique_strings) + append(&attrs, cloned) + } + + value := SymbolProcedureValue { return_types = returns[:], orig_return_types = returns[:], @@ -113,6 +120,7 @@ collect_procedure_fields :: proc( diverging = proc_type.diverging, calling_convention = clone_calling_convention(proc_type.calling_convention, collection.allocator, &collection.unique_strings), tags = proc_type.tags, + attributes = attrs[:], } return value diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 1698d61..301d7e1 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -643,6 +643,41 @@ concatenate_symbol_information :: proc { } concatenate_raw_symbol_information :: proc(ast_context: ^AstContext, symbol: Symbol) -> string { + if v, ok := symbol.value.(SymbolProcedureValue); ok { + pkg := path.base(symbol.pkg, false, context.temp_allocator) + sb := strings.builder_make(context.temp_allocator) + if symbol.comment != "" { + fmt.sbprintf(&sb, "%s\n", symbol.comment) + } + for attribute in v.attributes { + if len(attribute.elems) == 0 { + strings.write_string(&sb, "@()\n") + continue + } + strings.write_string(&sb, "@(") + for elem, i in attribute.elems { + if directive, ok := elem.derived.(^ast.Field_Value); ok { + build_string_node(directive.field, &sb, false) + strings.write_string(&sb, "=") + build_string_node(directive.value, &sb, false) + } else { + build_string_node(elem, &sb, false) + } + if i != len(attribute.elems) - 1 { + strings.write_string(&sb, ", ") + } + + } + strings.write_string(&sb, ")\n") + } + + fmt.sbprintf(&sb, "%v.%v", pkg, symbol.name) + if symbol.signature != "" { + fmt.sbprintf(&sb, ": %v", symbol.signature) + } + return strings.to_string(sb) + } + return concatenate_raw_string_information( ast_context, symbol.pkg, diff --git a/src/server/symbol.odin b/src/server/symbol.odin index 3cff104..141d4d4 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -59,6 +59,7 @@ SymbolProcedureValue :: struct { diverging: bool, calling_convention: ast.Proc_Calling_Convention, tags: ast.Proc_Tags, + attributes: []^ast.Attribute, } SymbolProcedureGroupValue :: struct { |