aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/vscode/package.json2
-rw-r--r--editors/vscode/src/extension.ts1
-rw-r--r--src/server/action.odin2
-rw-r--r--src/server/analysis.odin34
-rw-r--r--tests/completions_test.odin24
5 files changed, 60 insertions, 3 deletions
diff --git a/editors/vscode/package.json b/editors/vscode/package.json
index 0b3e8c0..cf2db7c 100644
--- a/editors/vscode/package.json
+++ b/editors/vscode/package.json
@@ -7,7 +7,7 @@
"type": "git",
"url": "git://github.com/DanielGavin/ols.git"
},
- "version": "0.0.7",
+ "version": "0.0.9",
"engines": {
"vscode": "^1.55.2"
},
diff --git a/editors/vscode/src/extension.ts b/editors/vscode/src/extension.ts
index 056e8ea..8cafc94 100644
--- a/editors/vscode/src/extension.ts
+++ b/editors/vscode/src/extension.ts
@@ -141,6 +141,7 @@ export async function activate(context: vscode.ExtensionContext) {
client.start();
+ parseOlsFile(config, olsFile);
watchOlsConfigFile(ctx, olsFile);
}
diff --git a/src/server/action.odin b/src/server/action.odin
index ba1b367..44b3458 100644
--- a/src/server/action.odin
+++ b/src/server/action.odin
@@ -13,4 +13,4 @@ CodeActionClientCapabilities :: struct {
CodeActionOptions :: struct {
codeActionKinds: []CodeActionKind,
resolveProvider: bool,
-}
+} \ No newline at end of file
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 8e56322..15ab92e 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -630,6 +630,21 @@ is_symbol_same_typed :: proc(ast_context: ^AstContext, a, b: index.Symbol) -> bo
return false;
}
+get_field_list_name_index :: proc(name: string, field_list: []^ast.Field) -> (int, bool) {
+
+ for field, i in field_list {
+ for field_name in field.names {
+ if ident, ok := field_name.derived.(ast.Ident); ok {
+ if name == ident.name {
+ return i, true;
+ }
+ }
+ }
+ }
+
+ return 0, false;
+}
+
/*
Figure out which function the call expression is using out of the list from proc group
*/
@@ -673,12 +688,29 @@ resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Grou
call_symbol: index.Symbol;
arg_symbol: index.Symbol;
ok: bool;
+ i := i;
if _, ok = arg.derived.(ast.Bad_Expr); ok {
continue;
}
- call_symbol, ok = resolve_type_expression(ast_context, arg);
+ //named parameter
+ if field, is_field := arg.derived.(ast.Field_Value); is_field {
+ call_symbol, ok = resolve_type_expression(ast_context, field.value);
+
+ if !ok {
+ break next_fn;
+ }
+
+ if ident, is_ident := field.field.derived.(ast.Ident); is_ident {
+ i, ok = get_field_list_name_index(field.field.derived.(ast.Ident).name, procedure.arg_types);
+ } else {
+ break next_fn;
+ }
+
+ } else {
+ call_symbol, ok = resolve_type_expression(ast_context, arg);
+ }
if !ok {
break next_fn;
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 2a9b5ae..eb1957e 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -336,6 +336,30 @@ ast_generic_make_slice :: proc(t: ^testing.T) {
test.expect_completion_details(t, &source, "", {"test.my_slice: []My_Struct"});
}
+@(test)
+ast_named_procedure_1 :: proc(t: ^testing.T) {
+
+ source := test.Source {
+ main = `package test
+ proc_a :: proc(a: int, b: int) -> int {
+ }
+
+ proc_b :: proc(a: int, b: bool) -> bool {
+ }
+
+ my_group :: proc {proc_a, proc_b};
+
+ main :: proc() {
+ my_bool := my_group(b = false, a = 2);
+ my_boo*
+ }
+ `,
+ packages = {},
+ };
+
+ test.expect_completion_details(t, &source, "", {"test.my_bool: bool"});
+}
+
/*
Figure out whether i want to introduce the runtime to the tests