Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

ConditionalCompilationBlock

mattt edited this page Feb 7, 2020 · 7 revisions

ConditionalCompilationBlock

A conditional compilation block declaration.

public struct ConditionalCompilationBlock: Declaration, Hashable, Codable

Inheritance

Codable, Hashable, Declaration

Nested Types

ConditionalCompilationBlock.Branch

Initializers

init(from:)

public init(from decoder: Decoder) throws

init(_:)

Creates an instance initialized with the given syntax node.

public init(_ node: IfConfigDeclSyntax)

init(_:)

Creates an instance initialized with the given syntax node.

public init(_ node: IfConfigClauseSyntax)

Properties

branches

The conditional compilation block branches.

let branches: [Branch]

For example, the following compilation block declaration has two branches:

#if true
enum A {}
#else
enum B {}
#endif

The first branch has the keyword #if and condition "true". The second branch has the keyword #else and no condition.

context

A dot-delimited (.) path describing the enclosing scope of the conditional compilation block declaration, or nil if the conditional compilation block isn't nested (that is, declared at the top-level scope of a module).

let context: String?

For example, the following conditional compilation block declaration has the context "A.B":

enum A {
   enum B {
       #if true
           enum C {}
       #endif
   }
}

Methods

encode(to:)

public func encode(to encoder: Encoder) throws