aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/completion.odin6
-rw-r--r--src/testing/testing.odin15
-rw-r--r--tests/completions_test.odin33
3 files changed, 45 insertions, 9 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 7038cbd..59e762c 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -447,9 +447,13 @@ get_selector_completion :: proc(
documentation = symbol.doc,
}
+ //Might be a hack...
+ _, is_selector := type.derived.(^ast.Selector_Expr)
+
if symbol.pkg == ast_context.document_package ||
base == "runtime" ||
- base == "$builtin" {
+ base == "$builtin" ||
+ is_selector {
item.label = fmt.aprintf(
"(%v%v)",
common.repeat(
diff --git a/src/testing/testing.odin b/src/testing/testing.odin
index 65694e6..e4ac86d 100644
--- a/src/testing/testing.odin
+++ b/src/testing/testing.odin
@@ -92,9 +92,9 @@ setup :: proc(src: ^Source) {
fullpath := uri.path
p := parser.Parser {
- //err = parser.default_error_handler,
- err = server.log_error_handler,
- warn = server.log_warning_handler,
+ err = parser.default_error_handler,
+ warn = parser.default_error_handler,
+ flags = {.Optional_Semicolons},
}
dir := filepath.base(filepath.dir(fullpath, context.temp_allocator))
@@ -122,11 +122,10 @@ setup :: proc(src: ^Source) {
}
if ret := server.collect_symbols(
- &server.indexer.index.collection,
- file,
- uri.uri,
- );
- ret != .None {
+ &server.indexer.index.collection,
+ file,
+ uri.uri,
+ ); ret != .None {
return
}
}
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 930ede3..14f8800 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -1895,3 +1895,36 @@ ast_switch_completion_for_maybe_enum :: proc(t: ^testing.T) {
test.expect_completion_details(t, &source, ".", {"One", "Two"})
}
+
+ast_union_with_type_from_different_package :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package)
+
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
+ My_Int :: int
+ `,
+ },
+ )
+
+ source := test.Source {
+ main = `package main
+ import "my_package"
+
+ My_Union :: union {
+ bool,
+ my_package.My_Int,
+ }
+
+ main :: proc() {
+ my_union: My_Union
+ my_union.*
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_labels(t, &source, ".", {"(my_package.My_Int)"})
+}