Skip to content

Remove unused imports should be able to remove unused import declarations in active #if clauses #2335

@ahoppen

Description

@ahoppen

Currently, the Remove unused imports code action only removes import declarations that are at the top level and not nested inside #if clauses. We should be able to also remove import declarations from those #if branches that are active in the current build configuration. For that, SourceKit-LSP needs to know which #if branches are active. While we could use the active regions sourcekitd requests, I think the cleaner design would be to implement a SwiftIfConfig.BuildConfiguration that gets its results from sourcekitd, similar to CompilerBuildConfiguration in the compiler’s repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code actionCode action provided by LSPenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions