Skip to content

Commit 2115d77

Browse files
committed
Make the retainFeatureCheckIfConfigs version of removingInactive compiler SPI
I'm not sure we have any clients for this particular option outside of the compiler, so for now, limit it to the compiler. We can expose it later if we'd like.
1 parent 7036a41 commit 2115d77

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Sources/SwiftIfConfig/ActiveSyntaxRewriter.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ import SwiftDiagnostics
1414
import SwiftSyntax
1515

1616
extension SyntaxProtocol {
17+
/// Produce a copy of this syntax node that removes all syntax regions that
18+
/// are inactive according to the given build configuration, leaving only
19+
/// the code that is active within that build configuration.
20+
///
21+
/// If there are errors in the conditions of any configuration
22+
/// clauses, e.g., `#if FOO > 10`, then the condition will be
23+
/// considered to have failed and the clauses's elements will be
24+
/// removed.
25+
/// - Parameters:
26+
/// - configuration: the configuration to apply.
27+
/// - Returns: the syntax node with all inactive regions removed, along with
28+
/// an array containing any diagnostics produced along the way.
29+
public func removingInactive(
30+
in configuration: some BuildConfiguration
31+
) -> (result: Syntax, diagnostics: [Diagnostic]) {
32+
return removingInactive(in: configuration, retainFeatureCheckIfConfigs: false)
33+
}
34+
1735
/// Produce a copy of this syntax node that removes all syntax regions that
1836
/// are inactive according to the given build configuration, leaving only
1937
/// the code that is active within that build configuration.
@@ -29,9 +47,10 @@ extension SyntaxProtocol {
2947
/// feature checks.
3048
/// - Returns: the syntax node with all inactive regions removed, along with
3149
/// an array containing any diagnostics produced along the way.
50+
@_spi(Compiler)
3251
public func removingInactive(
3352
in configuration: some BuildConfiguration,
34-
retainFeatureCheckIfConfigs: Bool = false
53+
retainFeatureCheckIfConfigs: Bool
3554
) -> (result: Syntax, diagnostics: [Diagnostic]) {
3655
// First pass: Find all of the active clauses for the #ifs we need to
3756
// visit, along with any diagnostics produced along the way. This process

0 commit comments

Comments
 (0)