diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-31 13:04:55 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-31 13:04:55 -0400 |
| commit | 50a3fd1799c23074452802dcd51fef5c4e03d525 (patch) | |
| tree | a448af819ee0826220342f71af6d9eb8d486b75b /src/server/analysis.odin | |
| parent | 8ee9db53bf77e676afa6ebf9c5a1b5bc6504c627 (diff) | |
Use current package rather than file path to filter private symbols
Diffstat (limited to 'src/server/analysis.odin')
| -rw-r--r-- | src/server/analysis.odin | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 42d908b..06e593a 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1404,7 +1404,10 @@ resolve_selector_expression :: proc(ast_context: ^AstContext, node: ^ast.Selecto try_build_package(ast_context.current_package) if node.field != nil { - return resolve_symbol_return(ast_context, lookup(node.field.name, selector.pkg, node.pos.file)) + return resolve_symbol_return( + ast_context, + lookup(node.field.name, selector.pkg, ast_context.current_package, node.pos.file), + ) } else { return Symbol{}, false } @@ -1541,7 +1544,7 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide switch node.name { case "context": for built in indexer.builtin_packages { - if symbol, ok := lookup("Context", built, ""); ok { + if symbol, ok := lookup("Context", built, "", ""); ok { symbol.type = .Variable return symbol, ok } @@ -1565,24 +1568,24 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide is_runtime := strings.contains(ast_context.current_package, "base/runtime") if is_runtime { - if symbol, ok := lookup(node.name, "$builtin", node.pos.file); ok { + if symbol, ok := lookup(node.name, "$builtin", ast_context.current_package, node.pos.file); ok { return resolve_symbol_return(ast_context, symbol) } } //last option is to check the index - if symbol, ok := lookup(node.name, ast_context.current_package, node.pos.file); ok { + if symbol, ok := lookup(node.name, ast_context.current_package, ast_context.current_package, node.pos.file); ok { return resolve_symbol_return(ast_context, symbol) } if !is_runtime { - if symbol, ok := lookup(node.name, "$builtin", node.pos.file); ok { + if symbol, ok := lookup(node.name, "$builtin", ast_context.current_package, node.pos.file); ok { return resolve_symbol_return(ast_context, symbol) } } for built in indexer.builtin_packages { - if symbol, ok := lookup(node.name, built, node.pos.file); ok { + if symbol, ok := lookup(node.name, built, ast_context.current_package, node.pos.file); ok { return resolve_symbol_return(ast_context, symbol) } } @@ -1590,7 +1593,7 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide for u in ast_context.usings { for imp in ast_context.imports { if strings.compare(imp.name, u.pkg_name) == 0 { - if symbol, ok := lookup(node.name, imp.name, node.pos.file); ok { + if symbol, ok := lookup(node.name, imp.name, ast_context.current_package, node.pos.file); ok { return resolve_symbol_return(ast_context, symbol) } } @@ -2204,7 +2207,8 @@ resolve_implicit_selector :: proc( if cc, ok := stmt.derived.(^ast.Case_Clause); ok { for item in cc.list { if position_in_node(item, position_context.position) { - if symbol, ok := resolve_type_expression(ast_context, position_context.switch_stmt.cond); ok { + if symbol, ok := resolve_type_expression(ast_context, position_context.switch_stmt.cond); + ok { return symbol, ok } } @@ -2423,19 +2427,19 @@ resolve_location_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) - return symbol, true } - if symbol, ok := lookup(node.name, ast_context.document_package, node.pos.file); ok { + if symbol, ok := lookup(node.name, ast_context.document_package, ast_context.current_package, node.pos.file); ok { return symbol, ok } usings := get_using_packages(ast_context) for pkg in usings { - if symbol, ok := lookup(node.name, pkg, node.pos.file); ok { + if symbol, ok := lookup(node.name, pkg, ast_context.current_package, node.pos.file); ok { return symbol, ok } } - if symbol, ok := lookup(node.name, "$builtin", node.pos.file); ok { + if symbol, ok := lookup(node.name, "$builtin", ast_context.current_package, node.pos.file); ok { return resolve_symbol_return(ast_context, symbol) } @@ -2604,7 +2608,7 @@ resolve_location_implicit_selector :: proc( resolve_container_allocator :: proc(ast_context: ^AstContext, container_name: string) -> (Symbol, bool) { for built in indexer.builtin_packages { - if symbol, ok := lookup(container_name, built, ast_context.fullpath); ok { + if symbol, ok := lookup(container_name, built, ast_context.current_package, ast_context.fullpath); ok { if v, ok := symbol.value.(SymbolStructValue); ok { for name, i in v.names { if name == "allocator" { @@ -2624,7 +2628,7 @@ resolve_container_allocator :: proc(ast_context: ^AstContext, container_name: st resolve_container_allocator_location :: proc(ast_context: ^AstContext, container_name: string) -> (Symbol, bool) { for built in indexer.builtin_packages { - if symbol, ok := lookup(container_name, built, ast_context.fullpath); ok { + if symbol, ok := lookup(container_name, built, ast_context.current_package, ast_context.fullpath); ok { if v, ok := symbol.value.(SymbolStructValue); ok { for name, i in v.names { if name == "allocator" { @@ -2690,7 +2694,8 @@ resolve_symbol_selector :: proc( } } case SymbolPackageValue: - if pkg, ok := lookup(field, symbol.pkg, symbol.uri); ok { + if pkg, ok := lookup(field, symbol.pkg, ast_context.current_package, symbol.uri); + ok { symbol.range = pkg.range symbol.uri = pkg.uri } else { |