|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +import Foundation |
| 14 | +import SwiftSyntax |
| 15 | + |
| 16 | +/// A rule that describes convenienve initialization rules for a ``Node``. |
| 17 | +/// |
| 18 | +/// When generating syntax nodes, SwiftSyntax will make additional |
| 19 | +/// convenience initializer for each rule that a Node has. |
| 20 | +/// |
| 21 | +/// The convenience initializer will take a non-optional parameter |
| 22 | +/// `nonOptionalChildName`, and when a non-optional value is passed, it'll call |
| 23 | +/// the full memberwise initializer with the provided `childDefaultValues`. |
| 24 | +/// |
| 25 | +/// For example, when initializing an `EnumCaseParameterSyntax`, the convenience |
| 26 | +/// initializer will take a non-optional `firstName` parameter, and when it's |
| 27 | +/// passed, it'll call the full memberwise initializer with |
| 28 | +/// `colon = .colonToken()`. |
| 29 | +public struct NodeInitRule { |
| 30 | + /// The name of the parameter that is required to be present for |
| 31 | + /// this conveniece initializer rule to apply. |
| 32 | + public let nonOptionalChildName: String |
| 33 | + |
| 34 | + /// A dicrionary of parameter names to their respective default values |
| 35 | + /// to apply when the `nonOptionalChildName` is passed as concrete value. |
| 36 | + public let childDefaultValues: [String: Token] |
| 37 | +} |
0 commit comments