diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-27 19:17:55 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-29 15:49:12 -0400 |
| commit | ca1e78574de49aa5b73df422736cdf4b0f093ecd (patch) | |
| tree | a4da4fbf290851deeeebcbddff0c46311a5e7bd3 /src/server/documentation.odin | |
| parent | 83d6bd2630fbcba45a3c912c4a141e4995def4f8 (diff) | |
Implement label details using new method
Diffstat (limited to 'src/server/documentation.odin')
| -rw-r--r-- | src/server/documentation.odin | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/server/documentation.odin b/src/server/documentation.odin index fa6eff5..9767a9d 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -107,9 +107,9 @@ keywords_docs: map[string]bool = { // Adds signature and docs information to the provided symbol build_documentation :: proc(ast_context: ^AstContext, symbol: ^Symbol, short_signature := true) { if short_signature { - symbol.signature = get_short_signature(ast_context, symbol) + symbol.signature = get_short_signature(ast_context, symbol^) } else { - symbol.signature = get_signature(ast_context, symbol) + symbol.signature = get_signature(ast_context, symbol^) } if symbol.doc == "" && symbol.comment == "" { @@ -144,7 +144,7 @@ construct_symbol_docs :: proc(docs, comment: string, allocator := context.temp_a } // Returns the fully detailed signature for the symbol, including things like attributes and fields -get_signature :: proc(ast_context: ^AstContext, symbol: ^Symbol) -> string { +get_signature :: proc(ast_context: ^AstContext, symbol: Symbol) -> string { show_type_info := symbol.type == .Variable || symbol.type == .Field pointer_prefix := repeat("^", symbol.pointers, ast_context.allocator) @@ -236,6 +236,7 @@ get_signature :: proc(ast_context: ^AstContext, symbol: ^Symbol) -> string { sb := strings.builder_make(ast_context.allocator) if show_type_info { append_type_information(&sb, ast_context, symbol, pointer_prefix) + strings.write_string(&sb, " :: ") } write_procedure_symbol_signature(&sb, v, detailed_signature=true) return strings.to_string(sb) @@ -284,7 +285,7 @@ get_signature :: proc(ast_context: ^AstContext, symbol: ^Symbol) -> string { return get_short_signature(ast_context, symbol) } -get_short_signature :: proc(ast_context: ^AstContext, symbol: ^Symbol) -> string { +get_short_signature :: proc(ast_context: ^AstContext, symbol: Symbol) -> string { // TODO: this is also a bit much, might need to clean it up into a function show_type_info := (symbol.type == .Variable || symbol.type == .Field) && !(.Anonymous in symbol.flags) && symbol.type_name != "" @@ -336,11 +337,12 @@ get_short_signature :: proc(ast_context: ^AstContext, symbol: ^Symbol) -> string sb := strings.builder_make(ast_context.allocator) if show_type_info { append_type_information(&sb, ast_context, symbol, pointer_prefix) + strings.write_string(&sb, " :: ") } write_procedure_symbol_signature(&sb, v, detailed_signature=false) return strings.to_string(sb) case SymbolAggregateValue: - return "proc" + return "proc (..)" case SymbolStructValue: sb := strings.builder_make(ast_context.allocator) if show_type_info { @@ -437,10 +439,10 @@ get_bit_field_field_signature :: proc(value: SymbolBitFieldValue, index: int, al return strings.to_string(sb) } -write_symbol_type_information :: proc(ast_context: ^AstContext, sb: ^strings.Builder, symbol: ^Symbol, pointer_prefix: string) { +write_symbol_type_information :: proc(ast_context: ^AstContext, sb: ^strings.Builder, symbol: Symbol, pointer_prefix: string) { append_type_pkg := false pkg_name := get_pkg_name(ast_context, symbol.type_pkg) - if pkg_name != "" { + if pkg_name != "" && pkg_name != "$builtin" { if _, ok := keywords_docs[symbol.type_name]; !ok { append_type_pkg = true } @@ -452,18 +454,7 @@ write_symbol_type_information :: proc(ast_context: ^AstContext, sb: ^strings.Bui } } -write_procedure_symbol_signature :: proc(sb: ^strings.Builder, value: SymbolProcedureValue, detailed_signature: bool) { - if detailed_signature { - if value.inlining == .Inline { - strings.write_string(sb, "#force_inline ") - } else if value.inlining == .No_Inline { - strings.write_string(sb, "#force_no_inline ") - } - } - strings.write_string(sb, "proc") - if s, ok := value.calling_convention.(string); ok && detailed_signature { - fmt.sbprintf(sb, " %s ", s) - } +write_proc_param_list_and_return :: proc(sb: ^strings.Builder, value: SymbolProcedureValue) { strings.write_string(sb, "(") for arg, i in value.orig_arg_types { build_string_node(arg, sb, false) @@ -493,6 +484,22 @@ write_procedure_symbol_signature :: proc(sb: ^strings.Builder, value: SymbolProc } else if value.diverging { strings.write_string(sb, " -> !") } + +} + +write_procedure_symbol_signature :: proc(sb: ^strings.Builder, value: SymbolProcedureValue, detailed_signature: bool) { + if detailed_signature { + if value.inlining == .Inline { + strings.write_string(sb, "#force_inline ") + } else if value.inlining == .No_Inline { + strings.write_string(sb, "#force_no_inline ") + } + } + strings.write_string(sb, "proc") + if s, ok := value.calling_convention.(string); ok && detailed_signature { + fmt.sbprintf(sb, " %s ", s) + } + write_proc_param_list_and_return(sb, value) if detailed_signature { for tag in value.tags { s := "" @@ -607,7 +614,7 @@ write_struct_hover :: proc(ast_context: ^AstContext, sb: ^strings.Builder, v: Sy append_type_information :: proc( sb: ^strings.Builder, ast_context: ^AstContext, - symbol: ^Symbol, + symbol: Symbol, pointer_prefix: string, ) { pkg_name := get_pkg_name(ast_context, symbol.type_pkg) |