From ddd6485f6ea68e445ee893721b2696aa2ab91bc4 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sat, 19 Jul 2025 19:36:42 -0400 Subject: Add proc directives to hover information --- src/server/analysis.odin | 1 + src/server/collector.odin | 1 + src/server/documentation.odin | 15 +++++++++++++++ src/server/symbol.odin | 1 + tests/hover_test.odin | 10 ++++++++++ 5 files changed, 28 insertions(+) diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 0929a61..8b4e3f9 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2801,6 +2801,7 @@ make_symbol_procedure_from_ast :: proc( generic = v.generic, diverging = v.diverging, calling_convention = v.calling_convention, + tags = v.tags, } if _, ok := get_attribute_objc_name(attributes); ok { diff --git a/src/server/collector.odin b/src/server/collector.odin index 91d948f..fc4f603 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -112,6 +112,7 @@ collect_procedure_fields :: proc( generic = is_procedure_generic(proc_type), diverging = proc_type.diverging, calling_convention = clone_calling_convention(proc_type.calling_convention, collection.allocator, &collection.unique_strings), + tags = proc_type.tags, } return value diff --git a/src/server/documentation.odin b/src/server/documentation.odin index 34a6752..1698d61 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -497,6 +497,21 @@ write_procedure_symbol_signature :: proc(sb: ^strings.Builder, value: SymbolProc } else if value.diverging { strings.write_string(sb, " -> !") } + for tag in value.tags { + s := "" + switch tag { + case .Optional_Ok: + s = "#optional_ok" + case .Optional_Allocator_Error: + s = "#optional_allocator_error" + case .Bounds_Check: + s = "#bounds_check" + case .No_Bounds_Check: + s = "#no_bounds_check" + } + + fmt.sbprintf(sb, " %s", s) + } } write_struct_hover :: proc(ast_context: ^AstContext, sb: ^strings.Builder, v: SymbolStructValue) { diff --git a/src/server/symbol.odin b/src/server/symbol.odin index 1cde72f..3cff104 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -58,6 +58,7 @@ SymbolProcedureValue :: struct { generic: bool, diverging: bool, calling_convention: ast.Proc_Calling_Convention, + tags: ast.Proc_Tags, } SymbolProcedureGroupValue :: struct { diff --git a/tests/hover_test.odin b/tests/hover_test.odin index df7aeae..4f81238 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -2803,6 +2803,16 @@ ast_hover_proc_calling_convention :: proc(t: ^testing.T) { } test.expect_hover(t, &source, "test.foo: proc \"contextless\" (a: int)") } + +@(test) +ast_hover_proc_directives :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + f{*}oo :: proc(a: int) #no_bounds_check {} + `, + } + test.expect_hover(t, &source, "test.foo: proc(a: int) #no_bounds_check") +} /* Waiting for odin fix -- cgit v1.2.3