aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-08-28 19:54:32 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-08-28 19:54:32 +0200
commitcdc3c3193db88cd96c75f23332814e97e057ad20 (patch)
tree8dea9c09f5c851cd60c2814b68cc2e5d27643dce
parent76c9be02a7a3512eba1a4d22c7d55938d7ba96cb (diff)
Fix issues with not collection non-mutable symbols with procedures in procedures.
-rw-r--r--src/server/analysis.odin30
-rw-r--r--tests/completions_test.odin587
-rw-r--r--tests/definition_test.odin4
-rw-r--r--tests/hover_test.odin46
-rw-r--r--tests/session_test.odin87
-rw-r--r--tests/signatures_test.odin197
6 files changed, 613 insertions, 338 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 18ae976..d910e5f 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -29,6 +29,7 @@ DocumentPositionContext :: struct {
position: common.AbsolutePosition,
line: int,
function: ^ast.Proc_Lit, //used to help with type resolving in function scope
+ functions: [dynamic]^ast.Proc_Lit, //stores all the functions that have been iterated through to find the position
selector: ^ast.Expr, //used for completion
selector_expr: ^ast.Selector_Expr,
identifier: ^ast.Node,
@@ -89,6 +90,7 @@ AstContext :: struct {
uri: string,
fullpath: string,
recursion_counter: int, //Sometimes the ast is so malformed that it causes infinite recursion.
+ non_mutable_only: bool,
}
make_ast_context :: proc(
@@ -2834,7 +2836,14 @@ get_locals_block_stmt :: proc(
}
for stmt in block.stmts {
- get_locals_stmt(file, stmt, ast_context, document_position)
+ if ast_context.non_mutable_only {
+ if value_decl, ok := stmt.derived.(^ast.Value_Decl);
+ ok && !value_decl.is_mutable {
+ get_locals_stmt(file, stmt, ast_context, document_position)
+ }
+ } else {
+ get_locals_stmt(file, stmt, ast_context, document_position)
+ }
}
}
@@ -3291,6 +3300,11 @@ get_locals :: proc(
for stmt in block.stmts {
get_locals_stmt(file, stmt, ast_context, document_position)
}
+
+ for function in document_position.functions {
+ ast_context.non_mutable_only = true
+ get_locals_stmt(file, function.body, ast_context, document_position)
+ }
}
clear_locals :: proc(ast_context: ^AstContext) {
@@ -3505,6 +3519,14 @@ resolve_entire_decl :: proc(
symbol = symbol,
}
}
+
+ if _, is_ident := v.field.derived.(^ast.Ident); is_ident {
+ if data.resolve_flag == .Constant ||
+ data.resolve_flag == .Variable {
+ return nil
+ }
+
+ }
case ^ast.Ident:
if data.resolve_flag == .Variable && v.name != data.reference {
break done
@@ -3963,6 +3985,11 @@ get_document_position_context :: proc(
position_context.file = document.ast
position_context.line = position.line
+ position_context.functions = make(
+ [dynamic]^ast.Proc_Lit,
+ context.temp_allocator,
+ )
+
absolute_position, ok := common.get_absolute_position(
position,
document.text,
@@ -4434,6 +4461,7 @@ get_document_position_node :: proc(
if position_in_node(n.body, position_context.position) {
position_context.function = cast(^Proc_Lit)node
+ append(&position_context.functions, position_context.function)
get_document_position(n.body, position_context)
}
case ^Comp_Lit:
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index 6beb610..a63c32c 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -22,9 +22,14 @@ ast_simple_struct_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"},
+ )
}
@(test)
@@ -44,9 +49,14 @@ ast_index_array_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"},
+ )
}
@(test)
@@ -66,9 +76,14 @@ ast_struct_pointer_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"},
+ )
}
@(test)
@@ -89,9 +104,14 @@ ast_struct_take_address_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"},
+ )
}
@(test)
@@ -112,9 +132,14 @@ ast_struct_deref_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"},
+ )
}
@(test)
@@ -138,9 +163,14 @@ ast_range_map :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"},
+ )
}
@(test)
@@ -164,9 +194,14 @@ ast_range_array :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int", "My_Struct.three: int"},
+ )
}
@(test)
@@ -193,9 +228,14 @@ ast_completion_identifier_proc_group :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.group_function: proc"});
+ test.expect_completion_details(
+ t,
+ &source,
+ "",
+ {"test.group_function: proc"},
+ )
}
@(test)
@@ -215,9 +255,9 @@ ast_completion_in_comp_lit_type :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.My_Struct: struct"});
+ test.expect_completion_details(t, &source, "", {"test.My_Struct: struct"})
}
@(test)
@@ -239,9 +279,9 @@ ast_completion_range_struct_selector_strings :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.value: string"});
+ test.expect_completion_details(t, &source, "", {"test.value: string"})
}
@(test)
@@ -266,29 +306,37 @@ ast_completion_selector_on_indexed_array :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Foo.a: int", "My_Foo.b: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Foo.a: int", "My_Foo.b: int"},
+ )
}
@(test)
index_package_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
My_Struct :: struct {
one: int,
two: int,
three: int,
}
`,
- });
+ },
+ )
- source := test.Source {
- main = `package test
+ source := test.Source {
+ main = `package test
import "my_package"
@@ -297,9 +345,14 @@ index_package_completion :: proc(t: ^testing.T) {
}
`,
packages = packages[:],
- };
+ }
- test.expect_completion_details(t, &source, ".", {"my_package.My_Struct: struct"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"my_package.My_Struct: struct"},
+ )
}
import "core:odin/ast"
@@ -329,9 +382,14 @@ ast_generic_make_slice :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_slice: []My_Struct"});
+ test.expect_completion_details(
+ t,
+ &source,
+ "",
+ {"test.my_slice: []My_Struct"},
+ )
}
@(test)
@@ -353,9 +411,9 @@ ast_named_procedure_1 :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_bool: bool"});
+ test.expect_completion_details(t, &source, "", {"test.my_bool: bool"})
}
@(test)
@@ -376,9 +434,9 @@ ast_named_procedure_2 :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_bool: bool"});
+ test.expect_completion_details(t, &source, "", {"test.my_bool: bool"})
}
@(test)
@@ -391,9 +449,23 @@ ast_swizzle_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"x: f32", "y: f32", "z: f32", "w: f32", "r: f32", "g: f32", "b: f32", "a: f32"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {
+ "x: f32",
+ "y: f32",
+ "z: f32",
+ "w: f32",
+ "r: f32",
+ "g: f32",
+ "b: f32",
+ "a: f32",
+ },
+ )
}
@(test)
@@ -406,9 +478,14 @@ ast_swizzle_completion_one_component :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"xx: [2]f32", "xy: [2]f32", "xz: [2]f32", "xw: [2]f32"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"xx: [2]f32", "xy: [2]f32", "xz: [2]f32", "xw: [2]f32"},
+ )
}
@(test)
@@ -421,9 +498,14 @@ ast_swizzle_completion_few_components :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"xx: [2]f32", "xy: [2]f32"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"xx: [2]f32", "xy: [2]f32"},
+ )
}
@@ -438,9 +520,9 @@ ast_swizzle_resolve_one_components :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_swizzle: f32"});
+ test.expect_completion_details(t, &source, "", {"test.my_swizzle: f32"})
}
@(test)
@@ -454,9 +536,9 @@ ast_swizzle_resolve_two_components :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_swizzle: [2]f32"});
+ test.expect_completion_details(t, &source, "", {"test.my_swizzle: [2]f32"})
}
@(test)
@@ -473,9 +555,14 @@ ast_swizzle_resolve_one_component_struct_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.one: int", "My_Struct.two: int"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.one: int", "My_Struct.two: int"},
+ )
}
@(test)
@@ -499,11 +586,16 @@ ast_for_in_identifier_completion :: proc(t: ^testing.T) {
}
`,
- packages = {},
- };
+ packages = {},
+ }
- test.expect_completion_details(t, &source, "", {"test.my_element: My_Struct"});
+ test.expect_completion_details(
+ t,
+ &source,
+ "",
+ {"test.my_element: My_Struct"},
+ )
}
@(test)
@@ -521,10 +613,10 @@ ast_completion_poly_struct_proc :: proc(t: ^testing.T) {
pass.*
}
`,
- packages = {},
- };
+ packages = {},
+ }
- test.expect_completion_details(t, &source, "", {"RenderPass.list: ^int"});
+ test.expect_completion_details(t, &source, "", {"RenderPass.list: ^int"})
}
@(test)
@@ -561,9 +653,9 @@ ast_generic_make_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"});
+ test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"})
}
@(test)
@@ -601,9 +693,9 @@ ast_generic_make_completion_2 :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"});
+ test.expect_completion_details(t, &source, ".", {"My_Struct.my_int: int"})
}
@(test)
@@ -631,9 +723,9 @@ ast_struct_for_in_switch_stmt_completion :: proc(t: ^testing.T) {
}
}
`,
- };
+ }
- test.expect_completion_details(t, &source, ".", {"Window.height: int"});
+ test.expect_completion_details(t, &source, ".", {"Window.height: int"})
}
@(test)
@@ -657,9 +749,9 @@ ast_overload_with_autocast_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_value: bool"});
+ test.expect_completion_details(t, &source, "", {"test.my_value: bool"})
}
@@ -684,9 +776,9 @@ ast_overload_with_any_int_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_value: bool"});
+ test.expect_completion_details(t, &source, "", {"test.my_value: bool"})
}
@(test)
@@ -710,9 +802,9 @@ ast_overload_with_any_int_with_poly_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_value: bool"});
+ test.expect_completion_details(t, &source, "", {"test.my_value: bool"})
}
@@ -745,11 +837,13 @@ ast_completion_in_between_struct :: proc(t: ^testing.T) {
@(test)
ast_overload_with_any_int_index_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
my_group :: proc{
with_any_int,
with_bool,
@@ -759,10 +853,11 @@ ast_overload_with_any_int_index_completion :: proc(t: ^testing.T) {
with_bool :: proc($T: typeid/[dynamic]$E, a: bool) -> int {
}
`,
- });
+ },
+ )
- source := test.Source {
- main = `package test
+ source := test.Source {
+ main = `package test
import "my_package"
@@ -773,26 +868,34 @@ ast_overload_with_any_int_index_completion :: proc(t: ^testing.T) {
}
`,
packages = packages[:],
- };
+ }
- test.expect_completion_details(t, &source, ".", {"my_package.my_value: bool"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"my_package.my_value: bool"},
+ )
}
@(test)
ast_package_procedure_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
my_proc :: proc() -> bool {
}
`,
- });
+ },
+ )
- source := test.Source {
- main = `package test
+ source := test.Source {
+ main = `package test
import "my_package"
@@ -801,14 +904,19 @@ ast_package_procedure_completion :: proc(t: ^testing.T) {
}
`,
packages = packages[:],
- };
+ }
- test.expect_completion_details(t, &source, ".", {"my_package.my_proc: proc() -> bool"});
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"my_package.my_proc: proc() -> bool"},
+ )
}
@(test)
ast_poly_with_comp_lit_empty_completion :: proc(t: ^testing.T) {
- source := test.Source {
+ source := test.Source {
main = `package test
My_Struct :: struct {
@@ -824,15 +932,15 @@ ast_poly_with_comp_lit_empty_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
//FIXME
- //test.expect_completion_details(t, &source, ".", {"my_package.my_proc: proc() -> bool"});
+ //test.expect_completion_details(t, &source, ".", {"my_package.my_proc: proc() -> bool"});
}
@(test)
ast_global_struct_completion :: proc(t: ^testing.T) {
- source := test.Source {
+ source := test.Source {
main = `package main
Foo :: struct { x: int }
@@ -842,9 +950,9 @@ ast_global_struct_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {"Foo.x: int"});
+ test.expect_completion_details(t, &source, ".", {"Foo.x: int"})
}
@(test)
@@ -858,9 +966,9 @@ ast_global_non_mutable_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, ".", {});
+ test.expect_completion_details(t, &source, ".", {})
}
@(test)
@@ -874,9 +982,9 @@ ast_basic_value_untyped_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.xaa: int"});
+ test.expect_completion_details(t, &source, "", {"test.xaa: int"})
}
@(test)
@@ -891,85 +999,94 @@ ast_basic_value_binary_completion :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.xb2: int"});
+ test.expect_completion_details(t, &source, "", {"test.xb2: int"})
}
@(test)
ast_file_private_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
@(private="file") my_proc :: proc() -> bool {
}
`,
- });
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "my_package"
main :: proc() {
my_package.*
}
`,
packages = packages[:],
- };
+ }
- test.expect_completion_details(t, &source, ".", {});
+ test.expect_completion_details(t, &source, ".", {})
}
@(test)
ast_non_mutable_variable_struct_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
My_Struct :: struct { a: int }
Im :: My_Struct;
`,
- });
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "my_package"
main :: proc() {
my_package.*
}
`,
packages = packages[:],
- };
+ }
- test.expect_completion_details(t, &source, ".", {"my_package.Im: struct"});
+ test.expect_completion_details(t, &source, ".", {"my_package.Im: struct"})
}
@(test)
ast_mutable_variable_struct_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
My_Struct :: struct { a: int }
var: My_Struct;
`,
- });
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "my_package"
main :: proc() {
my_package.var.*
}
`,
packages = packages[:],
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.a: int"});
+ test.expect_completion_details(t, &source, ".", {"My_Struct.a: int"})
}
@(test)
@@ -983,9 +1100,9 @@ ast_out_of_block_scope_completion :: proc(t: ^testing.T) {
aab*
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {});
+ test.expect_completion_details(t, &source, "", {})
}
@(test)
@@ -998,9 +1115,9 @@ ast_value_decl_multiple_name_same_type :: proc(t: ^testing.T) {
yaaa*
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.yaaaa: string"});
+ test.expect_completion_details(t, &source, "", {"test.yaaaa: string"})
}
@(test)
@@ -1018,9 +1135,9 @@ ast_value_decl_comp_lit :: proc(t: ^testing.T) {
my_struct.*
}
`,
- };
+ }
- test.expect_completion_details(t, &source, ".", {"My_Struct.a: int"});
+ test.expect_completion_details(t, &source, ".", {"My_Struct.a: int"})
}
@(test)
@@ -1032,9 +1149,9 @@ ast_multi_pointer_completion :: proc(t: ^testing.T) {
fa*
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.faa: [^]int"});
+ test.expect_completion_details(t, &source, "", {"test.faa: [^]int"})
}
@(test)
@@ -1047,9 +1164,9 @@ ast_multi_pointer_indexed_completion :: proc(t: ^testing.T) {
sa*
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.sap: int"});
+ test.expect_completion_details(t, &source, "", {"test.sap: int"})
}
@(test)
@@ -1068,9 +1185,9 @@ ast_implicit_named_comp_lit_bitset :: proc(t: ^testing.T) {
}
}
`,
- };
+ }
- test.expect_completion_details(t, &source, ".", {"A", "B", "C"});
+ test.expect_completion_details(t, &source, ".", {"A", "B", "C"})
}
@(test)
@@ -1090,9 +1207,9 @@ ast_implicit_unnamed_comp_lit_bitset :: proc(t: ^testing.T) {
}
}
`,
- };
-
- test.expect_completion_details(t, &source, ".", {"A", "B", "C"});
+ }
+
+ test.expect_completion_details(t, &source, ".", {"A", "B", "C"})
}
@(test)
@@ -1112,9 +1229,9 @@ ast_implicit_unnamed_comp_lit_enum :: proc(t: ^testing.T) {
}
}
`,
- };
-
- test.expect_completion_details(t, &source, ".", {"A", "B", "C"});
+ }
+
+ test.expect_completion_details(t, &source, ".", {"A", "B", "C"})
}
@(test)
@@ -1138,8 +1255,8 @@ ast_implicit_mixed_named_and_unnamed_comp_lit_bitset :: proc(t: ^testing.T) {
}
`,
}
-
- test.expect_completion_details(t, &source, ".", {"A", "B", "C"});
+
+ test.expect_completion_details(t, &source, ".", {"A", "B", "C"})
}
@(test)
@@ -1164,7 +1281,12 @@ ast_comp_lit_in_complit_completion :: proc(t: ^testing.T) {
`,
}
- test.expect_completion_details(t, &source, "", {"My_Struct_2.aab: int", "My_Struct_2.aaa: int"})
+ test.expect_completion_details(
+ t,
+ &source,
+ "",
+ {"My_Struct_2.aab: int", "My_Struct_2.aaa: int"},
+ )
}
@(test)
@@ -1184,8 +1306,13 @@ ast_inlined_struct :: proc(t: ^testing.T) {
}
`,
}
-
- test.expect_completion_details(t, &source, ".", {"struct.a: int", "struct.b: int"})
+
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"struct.a: int", "struct.b: int"},
+ )
}
@(test)
@@ -1202,9 +1329,14 @@ ast_inlined_union :: proc(t: ^testing.T) {
inst.*
}
`,
- };
-
- test.expect_completion_details(t, &source, ".", {"My_Struct.variant: union"});
+ }
+
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_Struct.variant: union"},
+ )
}
@(test)
@@ -1219,9 +1351,9 @@ ast_union_identifier_completion :: proc(t: ^testing.T) {
a: My_*
}
`,
- };
-
- test.expect_completion_details(t, &source, ".", {"test.My_Union: union"});
+ }
+
+ test.expect_completion_details(t, &source, ".", {"test.My_Union: union"})
}
@(test)
@@ -1235,9 +1367,9 @@ ast_union_poly :: proc(t: ^testing.T) {
m.*
}
`,
- };
+ }
- test.expect_completion_labels(t, &source, ".", {"(int)"});
+ test.expect_completion_labels(t, &source, ".", {"(int)"})
}
@(test)
@@ -1252,9 +1384,9 @@ ast_maybe_first_value :: proc(t: ^testing.T) {
v*
}
`,
- };
-
- test.expect_completion_details(t, &source, "", {"test.v: int"});
+ }
+
+ test.expect_completion_details(t, &source, "", {"test.v: int"})
}
@(test)
@@ -1267,9 +1399,9 @@ ast_maybe_second_value :: proc(t: ^testing.T) {
ok*
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.ok: bool"});
+ test.expect_completion_details(t, &source, "", {"test.ok: bool"})
}
@(test)
@@ -1283,25 +1415,28 @@ ast_maybe_array :: proc(t: ^testing.T) {
m.*
}
`,
- };
+ }
- test.expect_completion_labels(t, &source, ".", {"([5]u8)"});
+ test.expect_completion_labels(t, &source, ".", {"([5]u8)"})
}
@(test)
ast_maybe_index_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
Maybe :: union($T: typeid) {T}
`,
- });
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "my_package"
main :: proc() {
m: my_package.Maybe(int)
@@ -1309,9 +1444,9 @@ ast_maybe_index_completion :: proc(t: ^testing.T) {
}
`,
packages = packages[:],
- };
+ }
- test.expect_completion_labels(t, &source, ".", {"(my_package.int)"});
+ test.expect_completion_labels(t, &source, ".", {"(my_package.int)"})
}
@(test)
@@ -1325,9 +1460,9 @@ ast_distinct_u32_completion :: proc(t: ^testing.T) {
d*
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.d: Distinct_Type"});
+ test.expect_completion_details(t, &source, "", {"test.d: Distinct_Type"})
}
@(test)
@@ -1343,9 +1478,9 @@ ast_new_completion :: proc(t: ^testing.T) {
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.adzz: int"});
+ test.expect_completion_details(t, &source, "", {"test.adzz: int"})
}
@(test)
@@ -1363,9 +1498,9 @@ ast_new_clone_completion :: proc(t: ^testing.T) {
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.adzz: Foo"});
+ test.expect_completion_details(t, &source, "", {"test.adzz: Foo"})
}
@(test)
@@ -1380,9 +1515,9 @@ ast_rawtr_cast_completion :: proc(t: ^testing.T) {
}
`,
- };
+ }
- test.expect_completion_details(t, &source, "", {"test.my_int: int"});
+ test.expect_completion_details(t, &source, "", {"test.my_int: int"})
}
ast_overload_with_procedure_return :: proc(t: ^testing.T) {
@@ -1408,26 +1543,29 @@ ast_overload_with_procedure_return :: proc(t: ^testing.T) {
`,
}
- test.expect_completion_details(t, &source, "", {"test.my_in: []int"})
+ test.expect_completion_details(t, &source, "", {"test.my_in: []int"})
}
@(test)
ast_index_proc_parameter_completion :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
My_Struct :: struct {
a: int,
b: int,
}
`,
- })
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "my_package"
f :: proc(param: my_package.My_Struct) {
para*
@@ -1436,7 +1574,12 @@ ast_index_proc_parameter_completion :: proc(t: ^testing.T) {
packages = packages[:],
}
- test.expect_completion_details(t, &source, ".", {"my_package.param: My_Struct"})
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"my_package.param: My_Struct"},
+ )
}
@(test)
@@ -1454,7 +1597,7 @@ ast_implicit_completion_in_enum_array_comp_lit :: proc(t: ^testing.T) {
}
//TODO(Add proper completion support, but right now it's just to ensure no crashes)
- test.expect_completion_details(t, &source, ".", {})
+ test.expect_completion_details(t, &source, ".", {})
}
@(test)
@@ -1468,7 +1611,7 @@ ast_implicit_enum_value_decl_type :: proc(t: ^testing.T) {
`,
}
- test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
+ test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
}
@(test)
@@ -1483,7 +1626,7 @@ ast_implicit_bitset_value_decl :: proc(t: ^testing.T) {
`,
}
- test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
+ test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
}
@(test)
@@ -1499,7 +1642,7 @@ ast_implicit_bitset_add :: proc(t: ^testing.T) {
`,
}
- test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
+ test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
}
@(test)
@@ -1513,7 +1656,7 @@ ast_enum_complete :: proc(t: ^testing.T) {
`,
}
- test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
+ test.expect_completion_labels(t, &source, ".", {"Aa", "Ab", "Ac", "Ad"})
}
@@ -1521,9 +1664,11 @@ ast_enum_complete :: proc(t: ^testing.T) {
ast_comp_lit_with_all_symbols_indexed_enum_implicit :: proc(t: ^testing.T) {
packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
Foo :: enum {
ONE,
TWO,
@@ -1535,10 +1680,11 @@ ast_comp_lit_with_all_symbols_indexed_enum_implicit :: proc(t: ^testing.T) {
c: Foo,
}
`,
- })
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "my_package"
main :: proc() {
a := my_package.Bar {
@@ -1549,16 +1695,18 @@ ast_comp_lit_with_all_symbols_indexed_enum_implicit :: proc(t: ^testing.T) {
packages = packages[:],
}
- test.expect_completion_details(t, &source, ".", {"TWO", "ONE"})
+ test.expect_completion_details(t, &source, ".", {"TWO", "ONE"})
}
@(test)
ast_package_uppercase_test :: proc(t: ^testing.T) {
packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "My_package",
- source = `package My_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "My_package",
+ source = `package My_package
Foo :: enum {
ONE,
TWO,
@@ -1570,10 +1718,11 @@ ast_package_uppercase_test :: proc(t: ^testing.T) {
c: Foo,
}
`,
- })
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "My_package"
main :: proc() {
My_package.*
@@ -1582,7 +1731,12 @@ ast_package_uppercase_test :: proc(t: ^testing.T) {
packages = packages[:],
}
- test.expect_completion_details(t, &source, ".", {"My_package.Foo: enum", "My_package.Bar: struct"})
+ test.expect_completion_details(
+ t,
+ &source,
+ ".",
+ {"My_package.Foo: enum", "My_package.Bar: struct"},
+ )
}
@@ -1590,18 +1744,21 @@ ast_package_uppercase_test :: proc(t: ^testing.T) {
ast_index_enum_infer :: proc(t: ^testing.T) {
packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "My_package",
- source = `package My_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "My_package",
+ source = `package My_package
Foo :: enum {
ONE,
TWO,
}
`,
- })
+ },
+ )
source := test.Source {
- main = `package main
+ main = `package main
import "My_package"
main :: proc() {
my_enum: My_package.Foo
@@ -1612,7 +1769,7 @@ ast_index_enum_infer :: proc(t: ^testing.T) {
packages = packages[:],
}
- test.expect_completion_details(t, &source, ".", {"ONE", "TWO"})
+ test.expect_completion_details(t, &source, ".", {"ONE", "TWO"})
}
@(test)
@@ -1624,7 +1781,7 @@ ast_index_builtin_ODIN_OS :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
test.expect_completion_details(t, &source, ".", {"Darwin"})
}
@@ -1695,3 +1852,19 @@ ast_for_in_switch_type :: proc(t: ^testing.T) {
test.expect_completion_details(t, &source, ".", {"My_Foo.bar: int"})
}
+@(test)
+ast_procedure_in_procedure_non_mutable_completion :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ test :: proc() {
+ Int :: int
+
+ my_procedure_two :: proc() {
+ b : In*
+ }
+ `,
+ packages = {},
+ }
+
+ test.expect_completion_details(t, &source, "", {"Int"})
+}
diff --git a/tests/definition_test.odin b/tests/definition_test.odin
index ea0a35b..250d2da 100644
--- a/tests/definition_test.odin
+++ b/tests/definition_test.odin
@@ -1,4 +1,4 @@
-package tests
+package tests
import "core:testing"
import "core:fmt"
@@ -78,4 +78,4 @@ ast_goto_local_procedure_ret_value :: proc(t: ^testing.T) {
test.expect_definition_locations(t, &source, {location});
}
-*/ \ No newline at end of file
+*/
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 37bef31..1c975cc 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -16,7 +16,7 @@ ast_hover_default_intialized_parameter :: proc(t: ^testing.T) {
`,
packages = {},
- };
+ }
test.expect_hover(t, &source, "test.a: bool")
}
@@ -35,7 +35,11 @@ ast_hover_default_parameter_enum :: proc(t: ^testing.T) {
packages = {},
}
- test.expect_hover(t, &source, "test.procedure: proc(called_from: Expr_Called_Type = .None, options := List_Options{})")
+ test.expect_hover(
+ t,
+ &source,
+ "test.procedure: proc(called_from: Expr_Called_Type = .None, options := List_Options{})",
+ )
}
@(test)
ast_hover_parameter :: proc(t: ^testing.T) {
@@ -54,20 +58,23 @@ ast_hover_parameter :: proc(t: ^testing.T) {
@(test)
ast_hover_external_package_parameter :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
My_Struct :: struct {
one: int,
two: int,
three: int,
}
`,
- })
+ },
+ )
source := test.Source {
- main = `package test
+ main = `package test
import "my_package"
main :: proc(cool: my_package.My_Struct) {
cool*
@@ -81,20 +88,23 @@ ast_hover_external_package_parameter :: proc(t: ^testing.T) {
@(test)
ast_hover_procedure_package_parameter :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
My_Struct :: struct {
one: int,
two: int,
three: int,
}
`,
- })
+ },
+ )
source := test.Source {
- main = `package test
+ main = `package test
import "my_package"
main :: proc(cool: my_packa*ge.My_Struct) {
@@ -122,7 +132,11 @@ ast_hover_procedure_with_default_comp_lit :: proc(t: ^testing.T) {
`,
}
- test.expect_hover(t, &source, "test.fa: proc(color_: Color = {255, 255, 255, 255})")
+ test.expect_hover(
+ t,
+ &source,
+ "test.fa: proc(color_: Color = {255, 255, 255, 255})",
+ )
}
@(test)
@@ -141,4 +155,4 @@ ast_hover_same_name_in_selector_and_field :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "Color.color: int")
-} \ No newline at end of file
+}
diff --git a/tests/session_test.odin b/tests/session_test.odin
index 641fc23..6991125 100644
--- a/tests/session_test.odin
+++ b/tests/session_test.odin
@@ -282,86 +282,89 @@ initialize_request := `
}
]
}
-}`;
+}`
shutdown_request := `{
"jsonrpc":"2.0",
"id":0,
"method":"shutdown"
-}`;
+}`
exit_notification := `{
"jsonrpc":"2.0",
"id":0,
"method":"exit"
-}`;
-
+}`
TestReadBuffer :: struct {
- index: int,
- data: [] byte,
-};
+ index: int,
+ data: []byte,
+}
-test_read :: proc(handle: rawptr, data: [] byte) -> (int, int)
-{
- buffer := cast(^TestReadBuffer)handle;
+test_read :: proc(handle: rawptr, data: []byte) -> (int, int) {
+ buffer := cast(^TestReadBuffer)handle
- if len(buffer.data) <= len(data) + buffer.index {
- dst := data[:];
- src := buffer.data[buffer.index:len(buffer.data)];
+ if len(buffer.data) <= len(data) + buffer.index {
+ dst := data[:]
+ src := buffer.data[buffer.index:len(buffer.data)]
- copy(dst, src);
+ copy(dst, src)
- buffer.index += len(src);
- return len(src), 0;
- }
- else {
- dst := data[:];
- src := buffer.data[buffer.index:];
+ buffer.index += len(src)
+ return len(src), 0
+ } else {
+ dst := data[:]
+ src := buffer.data[buffer.index:]
- copy(dst, src);
+ copy(dst, src)
- buffer.index += len(dst);
- return len(dst), 0;
- }
+ buffer.index += len(dst)
+ return len(dst), 0
+ }
}
make_request :: proc(request: string) -> string {
- return fmt.tprintf("Content-Length: %v\r\n\r\n%v", len(request), request);
+ return fmt.tprintf("Content-Length: %v\r\n\r\n%v", len(request), request)
}
main :: proc() {
-
-
buffer := TestReadBuffer {
- data = transmute([]byte) strings.join({make_request(initialize_request), make_request(shutdown_request), make_request(exit_notification)}, "", context.allocator),
- };
+ data = transmute([]byte)strings.join(
+ {
+ make_request(initialize_request),
+ make_request(shutdown_request),
+ make_request(exit_notification),
+ },
+ "",
+ context.allocator,
+ ),
+ }
- reader := server.make_reader(test_read, &buffer);
- writer := server.make_writer(src.os_write, cast(rawptr)&os.stdout);
+ reader := server.make_reader(test_read, &buffer)
+ writer := server.make_writer(src.os_write, cast(rawptr)&os.stdout)
- tracking_allocator: mem.Tracking_Allocator;
+ tracking_allocator: mem.Tracking_Allocator
- mem.tracking_allocator_init(&tracking_allocator, context.allocator);
- context.allocator = mem.tracking_allocator(&tracking_allocator);
+ mem.tracking_allocator_init(&tracking_allocator, context.allocator)
+ context.allocator = mem.tracking_allocator(&tracking_allocator)
- init_global_temporary_allocator(mem.Megabyte * 5);
+ init_global_temporary_allocator(mem.Megabyte * 5)
- src.run(&reader, &writer);
+ src.run(&reader, &writer)
- //delete(buffer.data);
+ //delete(buffer.data);
for k in tracking_allocator.bad_free_array {
if k.memory == nil {
- continue;
+ continue
}
-
- fmt.println(k);
+
+ fmt.println(k)
}
- fmt.println("finished");
-} \ No newline at end of file
+ fmt.println("finished")
+}
diff --git a/tests/signatures_test.odin b/tests/signatures_test.odin
index 1bb44d5..9795710 100644
--- a/tests/signatures_test.odin
+++ b/tests/signatures_test.odin
@@ -13,9 +13,9 @@ ast_declare_proc_signature :: proc(t: ^testing.T) {
main :: proc(*)
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {});
+ test.expect_signature_labels(t, &source, {})
}
@(test)
@@ -35,9 +35,9 @@ ast_naked_parens :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {});
+ test.expect_signature_labels(t, &source, {})
}
@(test)
@@ -52,9 +52,13 @@ ast_simple_proc_signature :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.cool_function: proc(a: int)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"test.cool_function: proc(a: int)"},
+ )
}
@(test)
@@ -69,9 +73,13 @@ ast_default_assignment_proc_signature :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.cool_function: proc(a: int, b := context.allocator)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"test.cool_function: proc(a: int, b := context.allocator)"},
+ )
}
@(test)
@@ -86,9 +94,9 @@ ast_proc_signature_argument_last_position :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_parameter_position(t, &source, 1);
+ test.expect_signature_parameter_position(t, &source, 1)
}
@(test)
@@ -103,9 +111,9 @@ ast_proc_signature_argument_first_position :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_parameter_position(t, &source, 0);
+ test.expect_signature_parameter_position(t, &source, 0)
}
@@ -121,9 +129,9 @@ ast_proc_signature_argument_move_position :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_parameter_position(t, &source, 1);
+ test.expect_signature_parameter_position(t, &source, 1)
}
@(test)
@@ -138,9 +146,9 @@ ast_proc_signature_argument_complex :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_parameter_position(t, &source, 1);
+ test.expect_signature_parameter_position(t, &source, 1)
}
@(test)
@@ -155,9 +163,9 @@ ast_proc_signature_argument_open_brace_position :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_parameter_position(t, &source, 2);
+ test.expect_signature_parameter_position(t, &source, 2)
}
@(test)
@@ -172,9 +180,9 @@ ast_proc_signature_argument_any_ellipsis_position :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_parameter_position(t, &source, 0);
+ test.expect_signature_parameter_position(t, &source, 0)
}
@(test)
@@ -197,9 +205,16 @@ ast_proc_group_signature_empty_call :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
-
- test.expect_signature_labels(t, &source, {"test.int_function: proc(a: int)", "test.bool_function: proc(a: bool)"});
+ }
+
+ test.expect_signature_labels(
+ t,
+ &source,
+ {
+ "test.int_function: proc(a: int)",
+ "test.bool_function: proc(a: bool)",
+ },
+ )
}
@(test)
@@ -217,9 +232,15 @@ ast_proc_signature_generic :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
-
- test.expect_signature_labels(t, &source, {"test.clone_array: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A"});
+ }
+
+ test.expect_signature_labels(
+ t,
+ &source,
+ {
+ "test.clone_array: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A",
+ },
+ )
}
@(test)
@@ -242,9 +263,13 @@ ast_proc_group_signature_basic_types :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.int_function: proc(a: int, b: bool, c: int)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"test.int_function: proc(a: int, b: bool, c: int)"},
+ )
}
@@ -274,9 +299,13 @@ ast_proc_group_signature_distinct_basic_types :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.distinct_function: proc(a: My_Int, c: int)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"test.distinct_function: proc(a: My_Int, c: int)"},
+ )
}
@(test)
@@ -314,26 +343,33 @@ ast_proc_group_signature_struct :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.struct_function: proc(a: int, b: My_Struct, c: int)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"test.struct_function: proc(a: int, b: My_Struct, c: int)"},
+ )
}
@(test)
index_simple_signature :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
my_function :: proc(a: int, b := context.allocator) {
}
`,
- });
+ },
+ )
- source := test.Source {
- main = `package test
+ source := test.Source {
+ main = `package test
import "my_package"
@@ -342,9 +378,13 @@ index_simple_signature :: proc(t: ^testing.T) {
}
`,
packages = packages[:],
- };
+ }
- test.expect_signature_labels(t, &source, {"my_package.my_function: proc(a: int, b := context.allocator)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"my_package.my_function: proc(a: int, b := context.allocator)"},
+ )
}
@(test)
@@ -356,9 +396,13 @@ ast_index_builtin_len_proc :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"$builtin.len: proc(array: Array_Type) -> int"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"$builtin.len: proc(array: Array_Type) -> int"},
+ )
}
@(test)
@@ -371,9 +415,9 @@ ast_signature_on_invalid_package :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {});
+ test.expect_signature_labels(t, &source, {})
}
@(test)
@@ -391,9 +435,9 @@ ast_signature_variable_pointer :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"});
+ test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"})
}
@@ -413,27 +457,30 @@ ast_signature_global_variable_pointer :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"});
+ test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"})
}
@(test)
index_variable_pointer_signature :: proc(t: ^testing.T) {
- packages := make([dynamic]test.Package);
+ packages := make([dynamic]test.Package)
- append(&packages, test.Package {
- pkg = "my_package",
- source = `package my_package
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
My_Fun :: proc(a: int) {
}
my_fun_ptr: My_Fun;
`,
- });
+ },
+ )
- source := test.Source {
- main = `package test
+ source := test.Source {
+ main = `package test
import "my_package"
main :: proc() {
@@ -441,14 +488,18 @@ index_variable_pointer_signature :: proc(t: ^testing.T) {
}
`,
packages = packages[:],
- };
+ }
- test.expect_signature_labels(t, &source, {"my_package.My_Fun: proc(a: int)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"my_package.My_Fun: proc(a: int)"},
+ )
}
@(test)
shared_value_decl_type_signature :: proc(t: ^testing.T) {
- source := test.Source {
+ source := test.Source {
main = `package test
my_function :: proc(a, b: int) {
@@ -460,14 +511,18 @@ shared_value_decl_type_signature :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.my_function: proc(a: int, b: int)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"test.my_function: proc(a: int, b: int)"},
+ )
}
@(test)
proc_with_struct_poly :: proc(t: ^testing.T) {
- source := test.Source {
+ source := test.Source {
main = `package test
U :: struct(N: int, E: typetid) {
t: [N]E,
@@ -481,14 +536,14 @@ proc_with_struct_poly :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.uf: proc(u: U($T, $E))"});
+ test.expect_signature_labels(t, &source, {"test.uf: proc(u: U($T, $E))"})
}
@(test)
proc_signature_move_outside :: proc(t: ^testing.T) {
- source := test.Source {
+ source := test.Source {
main = `package test
my_cool_function :: proc(aa: int, ba: int, c: int) {
@@ -498,14 +553,16 @@ proc_signature_move_outside :: proc(t: ^testing.T) {
}
`,
packages = {},
- };
+ }
- test.expect_signature_labels(t, &source, {"test.my_cool_function: proc(aa: int, ba: int, c: int)"});
+ test.expect_signature_labels(
+ t,
+ &source,
+ {"test.my_cool_function: proc(aa: int, ba: int, c: int)"},
+ )
}
-
-
/*
@(test)
signature_function_inside_when :: proc(t: ^testing.T) {
@@ -526,4 +583,4 @@ signature_function_inside_when :: proc(t: ^testing.T) {
test.expect_signature_labels(t, &source, {"test.My_Fun: proc(a: int)"});
}
-*/ \ No newline at end of file
+*/