aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-17 20:25:53 -0400
committerGitHub <noreply@github.com>2025-09-17 20:25:53 -0400
commit5bf8612ce6f39f8e7a1774b09948ddecdeb471d3 (patch)
treeefcb5ad78cb489a0a1d0f3db130bf3b051640b3d
parent761f556b80abe30d7b2b6c1c692d584eeff91795 (diff)
parent9d152084c75aa3b2f0deaaada4cb24d7f368922c (diff)
Merge pull request #1027 from BradLewis/fix/semantic-token-fixes
Fix/semantic token fixes
-rw-r--r--src/server/analysis.odin10
-rw-r--r--src/server/collector.odin3
-rw-r--r--src/server/semantic_tokens.odin1
-rw-r--r--tests/semantic_tokens_test.odin47
4 files changed, 59 insertions, 2 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index db37ef7..7798be9 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1405,7 +1405,8 @@ resolve_selector_expression :: proc(ast_context: ^AstContext, node: ^ast.Selecto
set_ast_package_from_symbol_scoped(ast_context, selector)
ok := internal_resolve_type_expression(ast_context, s.expr, &symbol)
- symbol.type = .Variable
+ symbol.type = .Field
+ symbol.flags |= {.Mutable}
return symbol, ok
} else {
value := SymbolFixedArrayValue {
@@ -2457,6 +2458,12 @@ resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: Symbol, ok := tr
if symbol.type == .Variable {
ret.type = symbol.type
}
+ if .Variable in symbol.flags {
+ ret.flags |= {.Variable}
+ }
+ if .Mutable in symbol.flags {
+ ret.flags |= {.Mutable}
+ }
return ret, ok
}
@@ -2489,6 +2496,7 @@ resolve_unresolved_symbol :: proc(ast_context: ^AstContext, symbol: ^Symbol) ->
symbol.signature = ret.signature
symbol.value = ret.value
symbol.pkg = ret.pkg
+ symbol.flags |= ret.flags
} else {
return false
}
diff --git a/src/server/collector.odin b/src/server/collector.odin
index ff1c791..3b52ca2 100644
--- a/src/server/collector.odin
+++ b/src/server/collector.odin
@@ -745,6 +745,9 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri
symbol.flags |= {.Variable}
}
+ if .Mutable in expr.flags {
+ symbol.flags |= {.Mutable}
+ }
pkg: ^SymbolPackage
ok: bool
diff --git a/src/server/semantic_tokens.odin b/src/server/semantic_tokens.odin
index 7d6b653..60042cd 100644
--- a/src/server/semantic_tokens.odin
+++ b/src/server/semantic_tokens.odin
@@ -423,6 +423,7 @@ visit_proc_type :: proc(node: ^ast.Proc_Type, builder: ^SemanticTokenBuilder) {
}
visit_node(param.type, builder)
+ visit_node(param.default_value, builder)
}
}
diff --git a/tests/semantic_tokens_test.odin b/tests/semantic_tokens_test.odin
index 8fd8468..6aec84b 100644
--- a/tests/semantic_tokens_test.odin
+++ b/tests/semantic_tokens_test.odin
@@ -117,7 +117,52 @@ semantic_tokens_proc_return :: proc(t: ^testing.T) {
test.expect_semantic_tokens(t, &src, {
{1, 2, 3, .Function, {.ReadOnly}}, // [0] foo
{0, 18, 3, .Variable, {}}, // [1] ret
- {0, 5, 3, .Type, {.ReadOnly}}, // [2] proc
+ {0, 5, 3, .Type, {.ReadOnly}}, // [2] int
{1, 3, 3, .Variable, {}}, // [3] ret
})
}
+
+@(test)
+semantic_tokens_fixed_array_fields :: proc(t: ^testing.T) {
+ src := test.Source {
+ main = `package test
+ main :: proc() {
+ foo: [2]f32
+ y := foo.x
+ }
+ `
+ }
+
+ test.expect_semantic_tokens(t, &src, {
+ {1, 2, 4, .Function, {.ReadOnly}}, // [0] main
+ {1, 3, 3, .Variable, {}}, // [1] foo
+ {0, 8, 3, .Type, {.ReadOnly}}, // [2] f32
+ {1, 3, 1, .Variable, {}}, // [3] y
+ {0, 5, 3, .Variable, {}}, // [4] foo
+ {0, 4, 1, .Property, {}}, // [5] x
+ })
+}
+
+@(test)
+semantic_tokens_enum_member_default_param :: proc(t: ^testing.T) {
+ src := test.Source {
+ main = `package test
+ Foo :: enum {
+ A,
+ B,
+ }
+
+ bar :: proc(foo: Foo = .A) {}
+ `
+ }
+
+ test.expect_semantic_tokens(t, &src, {
+ {1, 2, 3, .Enum, {.ReadOnly}}, // [0] Foo
+ {1, 3, 1, .EnumMember, {}}, // [1] A
+ {1, 3, 1, .EnumMember, {}}, // [2] B
+ {3, 2, 3, .Function, {.ReadOnly}}, // [3] bar
+ {0, 12, 3, .Parameter, {}}, // [4] foo
+ {0, 5, 3, .Enum, {.ReadOnly}}, // [5] Foo
+ {0, 7, 1, .EnumMember, {}}, // [6] A
+ })
+}