aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-12-14 04:21:30 -0500
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-12-14 04:21:30 -0500
commit29ccf52e9cef7dc77f0b42f58669eb7e539cd12f (patch)
tree97d1fc8eb5ac252dc60ab1083365ca459705754d
parente9f9961537d7818e7a512f8dc43f6483c607b1a0 (diff)
Handle global call directives
-rw-r--r--src/server/analysis.odin7
-rw-r--r--tests/hover_test.odin20
2 files changed, 24 insertions, 3 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index ccaefbf..4fc69c4 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1388,7 +1388,7 @@ resolve_call_directive :: proc(ast_context: ^AstContext, call: ^ast.Call_Expr) -
value := SymbolSliceValue{
expr = ident
}
- symbol := Symbol{name = "#load", value = value}
+ symbol := Symbol{name = "#load", pkg = ast_context.current_package, value = value}
return symbol, true
} else if len(call.args) == 2 {
return resolve_type_expression(ast_context, call.args[1])
@@ -1977,8 +1977,9 @@ resolve_global_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, glo
defer {
ast_context.call = old_call
}
-
- if ok = internal_resolve_type_expression(ast_context, v.expr, &return_symbol); ok {
+ if _, ok = v.expr.derived.(^ast.Basic_Directive); ok {
+ return_symbol, ok = resolve_call_directive(ast_context, v)
+ } else if ok = internal_resolve_type_expression(ast_context, v.expr, &return_symbol); ok {
return_types := get_proc_return_types(ast_context, return_symbol, v, .Mutable in global.flags)
if len(return_types) > 0 {
ok = internal_resolve_type_expression(ast_context, return_types[0], &return_symbol)
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 51a2edc..81a26ce 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -5930,6 +5930,26 @@ ast_hover_directives_load_hash_local :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "test.bar: int")
}
+
+@(test)
+ast_hover_directives_config :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ b{*}ar :: #config(TEST, false)
+ `,
+ }
+ test.expect_hover(t, &source, "test.bar :: #config(TEST, false)")
+}
+
+@(test)
+ast_hover_directives_load :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ b{*}ar :: #load("foo.txt")
+ `,
+ }
+ test.expect_hover(t, &source, "test.bar :: #load(\"foo.txt\")")
+}
/*
Waiting for odin fix