From d13384a1e9a0758e4c608f4dfe3226e78fa4803e Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:12:46 -0400 Subject: Goto definition on package use goes to package declaration --- src/server/analysis.odin | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/server/analysis.odin') diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 8e1d7f0..9ee621a 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2591,7 +2591,9 @@ resolve_location_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) - symbol.uri = uri.uri symbol.flags |= {.Local} return symbol, true - } else if global, ok := ast_context.globals[node.name]; ok { + } + + if global, ok := ast_context.globals[node.name]; ok { symbol.range = common.get_token_range(global.name_expr, ast_context.file.src) uri := common.create_uri(global.expr.pos.file, ast_context.allocator) symbol.pkg = ast_context.document_package @@ -2599,6 +2601,25 @@ resolve_location_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) - return symbol, true } + for imp in ast_context.imports { + if imp.name == ast_context.current_package { + continue + } + + if strings.compare(imp.base, node.name) == 0 { + symbol := Symbol { + type = .Package, + pkg = imp.name, + value = SymbolPackageValue{}, + range = imp.range, + } + + try_build_package(symbol.pkg) + + return symbol, true + } + } + pkg := get_package_from_node(node) if symbol, ok := lookup(node.name, pkg, node.pos.file); ok { return symbol, ok -- cgit v1.2.3