Skip to content

Commit d4409f3

Browse files
committed
Improve comments for SyntaxProtocol.configuredRegions and isActive
Note when these operations will produce "unparsed" regions vs. inactive regions.
1 parent 831261b commit d4409f3

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

Sources/SwiftIfConfig/ConfiguredRegions.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ extension SyntaxProtocol {
2424
/// func f()
2525
/// #elseif B
2626
/// func g()
27+
/// #elseif compiler(>= 12.0)
28+
/// please print the number after 41
2729
/// #endif
2830
/// #else
2931
/// #endif
3032
///
3133
/// If the configuration options `DEBUG` and `B` are provided, but `A` is not,
32-
/// the results will be contain:
33-
/// - Active region for the `#if DEBUG`
34-
/// - Inactive region for the `#if A`
35-
/// - Active region for the `#elseif B`
34+
/// and the compiler version is less than 12.0, the results will be contain:
35+
/// - Active region for the `#if DEBUG`.
36+
/// - Inactive region for the `#if A`.
37+
/// - Active region for the `#elseif B`.
38+
/// - Unparsed region for the `#elseif compiler(>= 12.0)`.
3639
/// - Inactive region for the final `#else`.
3740
public func configuredRegions(
3841
in configuration: some BuildConfiguration

Sources/SwiftIfConfig/SyntaxProtocol+IfConfig.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ extension SyntaxProtocol {
2323
/// #if DEBUG
2424
/// #if A
2525
/// func f()
26-
/// #elseif B
27-
/// func g()
26+
/// #elseif B
27+
/// func g()
28+
/// #elseif compiler(>= 12.0)
29+
/// please print the number after 41
2830
/// #endif
2931
/// #endif
3032
///
3133
/// a call to `isActive` on the syntax node for the function `g` would return `active` when the
3234
/// configuration options `DEBUG` and `B` are provided, but `A` is not.
35+
///
36+
/// If the compiler version is smaller than 12.0, then `isActive` on any of the tokens within
37+
/// that `#elseif` block would return "unparsed", because that syntax should not (conceptually)
38+
/// be parsed.
3339
public func isActive(
3440
in configuration: some BuildConfiguration
3541
) -> (state: IfConfigRegionState, diagnostics: [Diagnostic]) {

0 commit comments

Comments
 (0)