aboutsummaryrefslogtreecommitdiff
path: root/src/server/indexer.odin
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2026-02-10 19:26:30 +1100
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2026-02-10 19:26:30 +1100
commit7acacb7c506af7f6d2277d76f5df5729d8b88566 (patch)
tree0039b735ee840e6a268d2770de5ac651e786289d /src/server/indexer.odin
parent475ef9ec7abaf8a4e1f8eb231fc91372dca60da1 (diff)
Correctly resolve builtin types when using the fully qualified name with the package
Diffstat (limited to 'src/server/indexer.odin')
-rw-r--r--src/server/indexer.odin27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/server/indexer.odin b/src/server/indexer.odin
index 3337b3b..cbf1bba 100644
--- a/src/server/indexer.odin
+++ b/src/server/indexer.odin
@@ -42,11 +42,38 @@ should_skip_private_symbol :: proc(symbol: Symbol, current_pkg, current_file: st
return false
}
+is_builtin_pkg :: proc(pkg: string) -> bool {
+ return strings.equal_fold(pkg, "$builtin") || strings.has_suffix(pkg, "/builtin")
+}
+
+lookup_builtin_symbol :: proc(name: string, current_file: string) -> (Symbol, bool) {
+ if symbol, ok := lookup_symbol(name, "$builtin", current_file); ok {
+ return symbol, true
+ }
+
+ for built in indexer.builtin_packages {
+ if symbol, ok := lookup_symbol(name, built, current_file); ok {
+ return symbol, true
+ }
+ }
+
+ return {}, false
+}
+
lookup :: proc(name: string, pkg: string, current_file: string, loc := #caller_location) -> (Symbol, bool) {
if name == "" {
return {}, false
}
+ if is_builtin_pkg(pkg) {
+ return lookup_builtin_symbol(name, current_file)
+ }
+
+ return lookup_symbol(name, pkg, current_file)
+}
+
+@(private = "file")
+lookup_symbol ::proc(name: string, pkg: string, current_file: string) -> (Symbol, bool) {
if symbol, ok := memory_index_lookup(&indexer.index, name, pkg); ok {
current_pkg := get_package_from_filepath(current_file)
if should_skip_private_symbol(symbol, current_pkg, current_file) {