diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-04-27 22:21:04 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-04-27 22:21:04 +0200 |
| commit | fc742ab3b8fde5a70fa314c5ed2a1c94e503e877 (patch) | |
| tree | 57178511f76e9ddbaf7d2ee0fa9e846de6533a7d | |
| parent | 07e8e34144d2c8929c8eb40779488464d77308bc (diff) | |
new tests
| -rw-r--r-- | src/server/analysis.odin | 17 | ||||
| -rw-r--r-- | tests/completions_test.odin | 59 |
2 files changed, 71 insertions, 5 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 6c615e6..30ae974 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -767,6 +767,8 @@ resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (i return make_symbol_array_from_ast(ast_context, v), true; case Dynamic_Array_Type: return make_symbol_dynamic_array_from_ast(ast_context, v), true; + case Map_Type: + return make_symbol_map_from_ast(ast_context, v), true; case Call_Expr: return resolve_type_expression(ast_context, local); case: @@ -1216,6 +1218,21 @@ make_symbol_dynamic_array_from_ast :: proc(ast_context: ^AstContext, v: ast.Dyna return symbol; } +make_symbol_map_from_ast :: proc(ast_context: ^AstContext, v: ast.Map_Type) -> index.Symbol { + + symbol := index.Symbol { + range = common.get_token_range(v.node, ast_context.file.src), + pkg = get_package_from_node(v.node), + }; + + symbol.value = index.SymbolMapValue { + key = v.key, + value = v.value, + }; + + return symbol; +} + make_symbol_basic_type_from_ast :: proc(ast_context: ^AstContext, n: ^ast.Node, v: ^ast.Ident) -> index.Symbol { symbol := index.Symbol { diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 3b4ecc8..987f43f 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -7,7 +7,6 @@ import test "shared:testing" @(test)
ast_simple_struct_completion :: proc(t: ^testing.T) {
-
source := test.Source {
main = `package test
@@ -30,7 +29,6 @@ ast_simple_struct_completion :: proc(t: ^testing.T) { @(test)
ast_index_array_completion :: proc(t: ^testing.T) {
-
source := test.Source {
main = `package test
@@ -53,7 +51,6 @@ ast_index_array_completion :: proc(t: ^testing.T) { @(test)
ast_struct_pointer_completion :: proc(t: ^testing.T) {
-
source := test.Source {
main = `package test
@@ -76,7 +73,6 @@ ast_struct_pointer_completion :: proc(t: ^testing.T) { @(test)
ast_struct_take_address_completion :: proc(t: ^testing.T) {
-
source := test.Source {
main = `package test
@@ -100,7 +96,6 @@ ast_struct_take_address_completion :: proc(t: ^testing.T) { @(test)
ast_struct_deref_completion :: proc(t: ^testing.T) {
-
source := test.Source {
main = `package test
@@ -122,4 +117,58 @@ ast_struct_deref_completion :: proc(t: ^testing.T) { test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
}
+@(test)
+ast_range_map :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ My_Struct :: struct {
+ one: int,
+ two: int,
+ three: int,
+ }
+
+ main :: proc() {
+ my_map: map[int]My_Struct;
+
+ for key, value in my_map {
+ value.*
+ }
+
+ }
+ `,
+ source_packages = {},
+ };
+
+ test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+}
+
+@(test)
+ast_range_array :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ My_Struct :: struct {
+ one: int,
+ two: int,
+ three: int,
+ }
+
+ main :: proc() {
+ my_array: []My_Struct;
+
+ for value in my_array {
+ value.*
+ }
+
+ }
+ `,
+ source_packages = {},
+ };
+
+ test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+}
+
+
+
|