aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/completion.odin11
-rw-r--r--tests/completions_test.odin40
2 files changed, 51 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index eb0a76e..d81998a 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -46,9 +46,15 @@ get_completion_list :: proc(document: ^common.Document, position: common.Positio
return list, true;
}
+ /*
+ NOTE
+ Currently bug in contains_any, uncomment when https://github.com/odin-lang/Odin/issues/1129 is closed.
+ */
+ /*
if position_context.import_stmt == nil && strings.contains_any(completion_context.triggerCharacter, "/:\"") {
return list, true;
}
+ */
ast_context := make_ast_context(document.ast, document.imports, document.package_name, document.uri.uri);
@@ -969,6 +975,11 @@ get_identifier_completion :: proc(ast_context: ^analysis.AstContext, position_co
result := result;
+ //Skip procedures when the position is in proc decl
+ if position_in_proc_decl(position_context) && result.symbol.type == .Function && common.config.enable_procedure_context {
+ continue;
+ }
+
item := CompletionItem {
label = result.symbol.name,
};
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 09e44d0..a9909d5 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -508,6 +508,46 @@ ast_for_in_identifier_completion :: proc(t: ^testing.T) {
test.expect_completion_details(t, &source, "", {"test.my_element: My_Struct"});
}
+@(test)
+ast_completion_poly_struct_proc :: proc(t: ^testing.T) {
+
+ source := test.Source {
+ main = `package test
+ RenderPass :: struct(type : typeid) { list : ^int, data : type, }
+
+ LightingAccumPass2 :: struct {
+ foo: int,
+ }
+
+ execute_lighting_pass2 :: proc(pass : RenderPass(LightingAccumPass2)) {
+ pass.*
+ }
+ `,
+ packages = {},
+ };
+
+ test.expect_completion_details(t, &source, "", {"RenderPass.list: ^int"});
+}
+
+/*
+@(test)
+ast_completion_core_fmt_proc :: proc(t: ^testing.T) {
+
+ source := test.Source {
+ main = `package test
+ import "core:fmt"
+ main :: proc() {
+ fmt.*
+ }
+ `,
+ packages = {},
+ };
+
+ test.expect_completion_details(t, &source, "", {"RenderPass.list: ^int"});
+
+}
+*/
+
/*
Figure out whether i want to introduce the runtime to the tests