aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2026-02-12 15:15:46 +1100
committerGitHub <noreply@github.com>2026-02-12 15:15:46 +1100
commit6f33789343f66b8f239de1266242c5487ab2ac03 (patch)
tree8887736ced99ba5c39f75b22448f966e2a6e74cf
parent4f309f96acc53f788dabf7a9d0cb7319dbe16ebd (diff)
parentee32288b28a939bd500143589800217f844031cb (diff)
Merge pull request #1296 from BradLewis/fix/unused-imports-when-stmt
Resolve decls in when statements to fix incorrectly flagging imports as unused
-rw-r--r--src/server/file_resolve.odin8
-rw-r--r--tests/actions_test.odin23
2 files changed, 23 insertions, 8 deletions
diff --git a/src/server/file_resolve.odin b/src/server/file_resolve.odin
index f381aac..c4b2467 100644
--- a/src/server/file_resolve.odin
+++ b/src/server/file_resolve.odin
@@ -51,10 +51,6 @@ resolve_ranged_file :: proc(
margin := 20
for decl in document.ast.decls {
- if _, is_value := decl.derived.(^ast.Value_Decl); !is_value {
- continue
- }
-
//Look for declarations that overlap with range
if range.start.line - margin <= decl.end.line && decl.pos.line <= range.end.line + margin {
resolve_decl(&position_context, &ast_context, document, decl, &symbols, .None, allocator)
@@ -88,10 +84,6 @@ resolve_entire_file :: proc(
symbols := make(map[uintptr]SymbolAndNode, 10000, allocator)
for decl in document.ast.decls {
- if _, is_value := decl.derived.(^ast.Value_Decl); !is_value {
- continue
- }
-
resolve_decl(&position_context, &ast_context, document, decl, &symbols, flag, allocator)
clear(&ast_context.locals)
}
diff --git a/tests/actions_test.odin b/tests/actions_test.odin
new file mode 100644
index 0000000..935e168
--- /dev/null
+++ b/tests/actions_test.odin
@@ -0,0 +1,23 @@
+package tests
+
+import "core:testing"
+
+import test "src:testing"
+
+@(test)
+action_remove_unsed_import_when_stmt :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ import "core:fm{*}t"
+
+ when true {
+ main :: proc() {
+ _ = fmt.printf
+ }
+ }
+ `,
+ packages = {},
+ }
+
+ test.expect_action(t, &source, {})
+}