summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/analysis.odin10
-rw-r--r--src/server/generics.odin18
-rw-r--r--tests/hover_test.odin21
3 files changed, 37 insertions, 12 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 83aef98..4c21c81 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -2528,8 +2528,14 @@ resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: Symbol, ok := tr
}
case SymbolProcedureValue:
if v.generic {
- if resolved_symbol, ok := resolve_generic_function(ast_context, v.arg_types, v.return_types, v.inlining);
- ok {
+ if resolved_symbol, ok := resolve_generic_function(
+ ast_context,
+ v.arg_types,
+ v.return_types,
+ v.inlining,
+ symbol.range,
+ symbol.uri,
+ ); ok {
return resolved_symbol, ok
} else {
return symbol, true
diff --git a/src/server/generics.odin b/src/server/generics.odin
index d57f4d5..ed35c65 100644
--- a/src/server/generics.odin
+++ b/src/server/generics.odin
@@ -502,7 +502,9 @@ resolve_generic_function_ast :: proc(ast_context: ^AstContext, proc_lit: ast.Pro
results = proc_lit.type.results.list
}
- return resolve_generic_function_symbol(ast_context, params, results, proc_lit.inlining)
+ range := common.get_token_range(proc_lit, ast_context.file.src)
+ uri := common.create_uri(proc_lit.pos.file, ast_context.allocator).uri
+ return resolve_generic_function_symbol(ast_context, params, results, proc_lit.inlining, range, uri)
}
@@ -511,6 +513,8 @@ resolve_generic_function_symbol :: proc(
params: []^ast.Field,
results: []^ast.Field,
inlining: ast.Proc_Inlining,
+ proc_range: common.Range,
+ proc_uri: string,
) -> (
Symbol,
bool,
@@ -606,27 +610,21 @@ resolve_generic_function_symbol :: proc(
}
function_name := ""
- function_range: common.Range
- function_uri := ""
if ident, ok := call_expr.expr.derived.(^ast.Ident); ok {
function_name = ident.name
- function_range = common.get_token_range(ident, ast_context.file.src)
- function_uri = common.create_uri(ident.pos.file, ast_context.allocator).uri
} else if selector, ok := call_expr.expr.derived.(^ast.Selector_Expr); ok {
function_name = selector.field.name
- function_range = common.get_token_range(selector, ast_context.file.src)
- function_uri = common.create_uri(selector.field.pos.file, ast_context.allocator).uri
} else {
return {}, false
}
symbol := Symbol {
- range = function_range,
+ range = proc_range,
type = .Function,
name = function_name,
- pkg = ast_context.current_package,
- uri = function_uri,
+ uri = proc_uri,
+ pkg = get_package_from_filepath(proc_uri),
}
return_types := make([dynamic]^ast.Field, ast_context.allocator)
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 391ff60..2f33d73 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -5347,6 +5347,27 @@ ast_hover_quaternion_literal :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "test.foo: quaternion256")
}
+
+@(test)
+ast_hover_parapoly_other_package :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package, context.temp_allocator)
+
+ append(&packages, test.Package{pkg = "my_package", source = `package my_package
+ // Docs!
+ bar :: proc(_: $T) {}
+ `})
+ source := test.Source {
+ main = `package test
+ import "my_package"
+
+ main :: proc() {
+ my_package.ba{*}r("test")
+ }
+ `,
+ packages = packages[:],
+ }
+ test.expect_hover(t, &source, "my_package.bar :: proc(_: $T)")
+}
/*
Waiting for odin fix