# Discussion: Test coverage for RemoveUnusedImports in conditional compilation contexts

**URL:** <https://forums.swift.org/t/discussion-test-coverage-for-removeunusedimports-in-conditional-compilation-contexts/84925>\
**Category:** SourceKit-LSP\
**Tags:** code-action\
**Created:** [February 23, 2026, 7:12pm UTC](https://forums.swift.org/t/discussion-test-coverage-for-removeunusedimports-in-conditional-compilation-contexts/84925 "2026-02-23T19:12:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amanmrya](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/amanmrya/32/44601_2.png) [@amanmrya](https://forums.swift.org/u/amanmrya)\
**Post date:** [February 23, 2026, 7:12pm UTC](https://forums.swift.org/t/discussion-test-coverage-for-removeunusedimports-in-conditional-compilation-contexts/84925/1 "2026-02-23T19:12:08Z")

</div>

I’ve been working on improving `RemoveUnusedImports` to handle imports inside conditional compilation blocks as discussed in [#2335](https://github.com/swiftlang/sourcekit-lsp/issues/2335). I’m planning to expand the test coverage around this behaviour, and this thread is intended to gather feedback on which scenarios are worth covering.

I’m currently considering tests for:

- Removing imports from active `#if` clauses

- Not removing imports from inactive `#if` / `#elseif` clauses

- Ignoring imports inside `#if false` blocks

- Treating imports inside `#if true` like top-level imports

- Mixed top-level and conditional imports

- Nested inactive conditional regions

I’ve started prototyping support for active `#if` clauses in this PR: [PR of the tests](https://github.com/swiftlang/sourcekit-lsp/pull/2488).

Would appreciate any guidance on which of these cases should be included.
