aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-19 19:36:42 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-22 18:48:23 -0400
commitddd6485f6ea68e445ee893721b2696aa2ab91bc4 (patch)
treef90f30517bfca81476f48a8a15cf0dd58d9bc607
parent4eda03d0564acbbd577edb54183f4443fbdd0e94 (diff)
Add proc directives to hover information
-rw-r--r--src/server/analysis.odin1
-rw-r--r--src/server/collector.odin1
-rw-r--r--src/server/documentation.odin15
-rw-r--r--src/server/symbol.odin1
-rw-r--r--tests/hover_test.odin10
5 files changed, 28 insertions, 0 deletions
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