aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/analysis.odin22
-rw-r--r--src/server/symbol.odin13
-rw-r--r--tests/completions_test.odin41
3 files changed, 66 insertions, 10 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 6da15b0..142ee38 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1133,6 +1133,7 @@ internal_resolve_type_expression :: proc(
ast_context,
v^,
ast_context.field_name,
+ {},
true,
),
true
@@ -1185,6 +1186,7 @@ internal_resolve_type_expression :: proc(
node,
v^,
ast_context.field_name,
+ {},
),
true
case ^Basic_Directive:
@@ -1634,6 +1636,10 @@ internal_resolve_type_identifier :: proc(
}
}
+ if local.pkg != "" {
+ ast_context.current_package = local.pkg
+ }
+
//Sometimes the locals are semi resolved and can no longer use the locals
if local.global {
ast_context.use_locals = false
@@ -1665,7 +1671,7 @@ internal_resolve_type_identifier :: proc(
return_symbol.name = node.name
case ^Struct_Type:
return_symbol, ok =
- make_symbol_struct_from_ast(ast_context, v^, node), true
+ make_symbol_struct_from_ast(ast_context, v^, node, {}), true
return_symbol.name = node.name
case ^Bit_Set_Type:
return_symbol, ok =
@@ -1679,6 +1685,7 @@ internal_resolve_type_identifier :: proc(
local.rhs,
v.type^,
node,
+ {},
),
true
} else {
@@ -1692,6 +1699,7 @@ internal_resolve_type_identifier :: proc(
local.rhs,
v.type^,
node,
+ {},
),
true
}
@@ -1755,7 +1763,13 @@ internal_resolve_type_identifier :: proc(
)
case ^Struct_Type:
return_symbol, ok =
- make_symbol_struct_from_ast(ast_context, v^, node), true
+ make_symbol_struct_from_ast(
+ ast_context,
+ v^,
+ node,
+ global.attributes,
+ ),
+ true
return_symbol.name = node.name
case ^Bit_Set_Type:
return_symbol, ok =
@@ -1777,6 +1791,7 @@ internal_resolve_type_identifier :: proc(
global.expr,
v.type^,
node,
+ global.attributes,
),
true
} else {
@@ -1790,6 +1805,7 @@ internal_resolve_type_identifier :: proc(
global.expr,
v.type^,
node,
+ global.attributes,
),
true
}
@@ -2392,6 +2408,7 @@ make_symbol_procedure_from_ast :: proc(
n: ^ast.Node,
v: ast.Proc_Type,
name: ast.Ident,
+ attributes: []^ast.Attribute,
) -> Symbol {
symbol := Symbol {
range = common.get_token_range(name, ast_context.file.src),
@@ -2662,6 +2679,7 @@ make_symbol_struct_from_ast :: proc(
ast_context: ^AstContext,
v: ast.Struct_Type,
ident: ast.Ident,
+ attributes: []^ast.Attribute,
inlined := false,
) -> Symbol {
symbol := Symbol {
diff --git a/src/server/symbol.odin b/src/server/symbol.odin
index 215e01c..8f7a081 100644
--- a/src/server/symbol.odin
+++ b/src/server/symbol.odin
@@ -17,11 +17,13 @@ SymbolAndNode :: struct {
}
SymbolStructValue :: struct {
- names: []string,
- ranges: []common.Range,
- types: []^ast.Expr,
- usings: map[string]bool,
- poly: ^ast.Field_List,
+ names: []string,
+ ranges: []common.Range,
+ types: []^ast.Expr,
+ usings: map[string]bool,
+ poly: ^ast.Field_List,
+ objc_name: string,
+ objc_is_class_method: bool,
}
SymbolPackageValue :: struct {}
@@ -130,6 +132,7 @@ SymbolFlag :: enum {
Anonymous, //Usually applied to structs that are defined inline inside another struct
Variable, //Symbols that are variable, this means their value decl was mutable
Local,
+ ObjC,
}
SymbolFlags :: bit_set[SymbolFlag]
diff --git a/tests/completions_test.odin b/tests/completions_test.odin
index aef5e14..78d7f28 100644
--- a/tests/completions_test.odin
+++ b/tests/completions_test.odin
@@ -592,9 +592,46 @@ ast_swizzle_resolve_one_component_struct_completion :: proc(t: ^testing.T) {
}
@(test)
-ast_for_in_identifier_completion :: proc(t: ^testing.T) {
+ast_for_in_for_from_different_package :: proc(t: ^testing.T) {
+ packages := make([dynamic]test.Package)
+
+ append(
+ &packages,
+ test.Package{
+ pkg = "my_package",
+ source = `package my_package
+ My_Bar :: struct {
+ number: int,
+ }
+
+ My_Foo :: struct {
+ elems: []^My_Bar,
+ }
+ `,
+ },
+ )
source := test.Source {
+ main = `package test
+ import "my_package"
+ main :: proc() {
+ my_foos: []^my_package.My_Foo
+ for foo in my_foos {
+ for my_bar in foo.elems {
+ my_bar.{*}
+ }
+ }
+ }
+ `,
+ packages = packages[:],
+ }
+
+ test.expect_completion_details(t, &source, "", {"My_Bar.number: int"})
+}
+
+@(test)
+ast_for_in_identifier_completion :: proc(t: ^testing.T) {
+ source := test.Source {
main = `package test
My_Struct :: struct {
one: int,
@@ -626,7 +663,6 @@ ast_for_in_identifier_completion :: proc(t: ^testing.T) {
@(test)
ast_completion_poly_struct_proc :: proc(t: ^testing.T) {
-
source := test.Source {
main = `package test
RenderPass :: struct(type : typeid) { list : ^int, data : type, }
@@ -686,7 +722,6 @@ ast_generic_make_completion :: proc(t: ^testing.T) {
@(test)
ast_generic_make_completion_2 :: proc(t: ^testing.T) {
-
source := test.Source {
main = `package test