diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2026-02-10 19:31:11 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-10 19:31:11 +1100 |
| commit | 3e8434dd66c7cbba28cfa3dd5824b26c2ce70b29 (patch) | |
| tree | 0039b735ee840e6a268d2770de5ac651e786289d /src | |
| parent | 475ef9ec7abaf8a4e1f8eb231fc91372dca60da1 (diff) | |
| parent | 7acacb7c506af7f6d2277d76f5df5729d8b88566 (diff) | |
Merge pull request #1288 from BradLewis/fix/qualified-builtin-types
Correctly resolve builtin types when using the fully qualified name with the package
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/completion.odin | 12 | ||||
| -rw-r--r-- | src/server/indexer.odin | 27 |
2 files changed, 37 insertions, 2 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 60ca2bc..5bbbcf8 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -966,9 +966,17 @@ get_selector_completion :: proc( case SymbolPackageValue: is_incomplete = true - pkg := selector.pkg + packages := make([dynamic]string, context.temp_allocator) + if is_builtin_pkg(selector.pkg) { + append(&packages, "$builtin") + for built in indexer.builtin_packages { + append(&packages, built) + } + } else { + append(&packages, selector.pkg) + } - if searched, ok := fuzzy_search(field, {pkg}, ast_context.fullpath); ok { + if searched, ok := fuzzy_search(field, packages[:], ast_context.fullpath); ok { for search in searched { symbol := search.symbol 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) { |