Skip to content

Commit 2ab4a9c

Browse files
committed
Regenerate with InfixOperatorExpr.
1 parent 47dcde4 commit 2ab4a9c

File tree

14 files changed

+473
-3
lines changed

14 files changed

+473
-3
lines changed

Sources/SwiftSyntax/gyb_generated/Misc.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ extension SyntaxNode {
277277
return ArrowExprSyntax(asSyntaxData)
278278
}
279279

280+
public var isInfixOperatorExpr: Bool { return raw.kind == .infixOperatorExpr }
281+
public var asInfixOperatorExpr: InfixOperatorExprSyntax? {
282+
guard isInfixOperatorExpr else { return nil }
283+
return InfixOperatorExprSyntax(asSyntaxData)
284+
}
285+
280286
public var isFloatLiteralExpr: Bool { return raw.kind == .floatLiteralExpr }
281287
public var asFloatLiteralExpr: FloatLiteralExprSyntax? {
282288
guard isFloatLiteralExpr else { return nil }
@@ -1665,6 +1671,8 @@ extension Syntax {
16651671
return node
16661672
case .arrowExpr(let node):
16671673
return node
1674+
case .infixOperatorExpr(let node):
1675+
return node
16681676
case .floatLiteralExpr(let node):
16691677
return node
16701678
case .tupleExpr(let node):

Sources/SwiftSyntax/gyb_generated/SyntaxAnyVisitor.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
362362
override open func visitPost(_ node: ArrowExprSyntax) {
363363
visitAnyPost(node._syntaxNode)
364364
}
365+
override open func visit(_ node: InfixOperatorExprSyntax) -> SyntaxVisitorContinueKind {
366+
return visitAny(node._syntaxNode)
367+
}
368+
369+
override open func visitPost(_ node: InfixOperatorExprSyntax) {
370+
visitAnyPost(node._syntaxNode)
371+
}
365372
override open func visit(_ node: FloatLiteralExprSyntax) -> SyntaxVisitorContinueKind {
366373
return visitAny(node._syntaxNode)
367374
}

Sources/SwiftSyntax/gyb_generated/SyntaxBaseNodes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
164164
/// `nil` if the conversion is not possible.
165165
public init?(_ syntax: Syntax) {
166166
switch syntax.raw.kind {
167-
case .unknownExpr, .missingExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .awaitExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFileIDExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .regexLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .postfixIfConfigExpr, .editorPlaceholderExpr, .objectLiteralExpr:
167+
case .unknownExpr, .missingExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .awaitExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFileIDExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .infixOperatorExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .regexLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .postfixIfConfigExpr, .editorPlaceholderExpr, .objectLiteralExpr:
168168
self._syntaxNode = syntax
169169
default:
170170
return nil
@@ -178,7 +178,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
178178
// Assert that the kind of the given data matches in debug builds.
179179
#if DEBUG
180180
switch data.raw.kind {
181-
case .unknownExpr, .missingExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .awaitExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFileIDExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .regexLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .postfixIfConfigExpr, .editorPlaceholderExpr, .objectLiteralExpr:
181+
case .unknownExpr, .missingExpr, .inOutExpr, .poundColumnExpr, .tryExpr, .awaitExpr, .identifierExpr, .superRefExpr, .nilLiteralExpr, .discardAssignmentExpr, .assignmentExpr, .sequenceExpr, .poundLineExpr, .poundFileExpr, .poundFileIDExpr, .poundFilePathExpr, .poundFunctionExpr, .poundDsohandleExpr, .symbolicReferenceExpr, .prefixOperatorExpr, .binaryOperatorExpr, .arrowExpr, .infixOperatorExpr, .floatLiteralExpr, .tupleExpr, .arrayExpr, .dictionaryExpr, .integerLiteralExpr, .booleanLiteralExpr, .ternaryExpr, .memberAccessExpr, .isExpr, .asExpr, .typeExpr, .closureExpr, .unresolvedPatternExpr, .functionCallExpr, .subscriptExpr, .optionalChainingExpr, .forcedValueExpr, .postfixUnaryExpr, .specializeExpr, .stringLiteralExpr, .regexLiteralExpr, .keyPathExpr, .keyPathBaseExpr, .objcKeyPathExpr, .objcSelectorExpr, .postfixIfConfigExpr, .editorPlaceholderExpr, .objectLiteralExpr:
182182
break
183183
default:
184184
fatalError("Unable to create ExprSyntax from \(data.raw.kind)")

Sources/SwiftSyntax/gyb_generated/SyntaxBuilders.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,60 @@ extension ArrowExprSyntax {
10471047
}
10481048
}
10491049

1050+
public struct InfixOperatorExprSyntaxBuilder {
1051+
private var layout =
1052+
Array<RawSyntax?>(repeating: nil, count: 6)
1053+
1054+
internal init() {}
1055+
1056+
public mutating func useLeftOperand(_ node: ExprSyntax) {
1057+
let idx = InfixOperatorExprSyntax.Cursor.leftOperand.rawValue
1058+
layout[idx] = node.raw
1059+
}
1060+
1061+
public mutating func useOperatorOperand(_ node: ExprSyntax) {
1062+
let idx = InfixOperatorExprSyntax.Cursor.operatorOperand.rawValue
1063+
layout[idx] = node.raw
1064+
}
1065+
1066+
public mutating func useRightOperand(_ node: ExprSyntax) {
1067+
let idx = InfixOperatorExprSyntax.Cursor.rightOperand.rawValue
1068+
layout[idx] = node.raw
1069+
}
1070+
1071+
internal mutating func buildData() -> SyntaxData {
1072+
if (layout[1] == nil) {
1073+
layout[1] = RawSyntax.missing(SyntaxKind.missingExpr)
1074+
}
1075+
if (layout[3] == nil) {
1076+
layout[3] = RawSyntax.missing(SyntaxKind.missingExpr)
1077+
}
1078+
if (layout[5] == nil) {
1079+
layout[5] = RawSyntax.missing(SyntaxKind.missingExpr)
1080+
}
1081+
1082+
return .forRoot(RawSyntax.createAndCalcLength(kind: .infixOperatorExpr,
1083+
layout: layout, presence: .present))
1084+
}
1085+
}
1086+
1087+
extension InfixOperatorExprSyntax {
1088+
/// Creates a `InfixOperatorExprSyntax` using the provided build function.
1089+
/// - Parameter:
1090+
/// - build: A closure that will be invoked in order to initialize
1091+
/// the fields of the syntax node.
1092+
/// This closure is passed a `InfixOperatorExprSyntaxBuilder` which you can use to
1093+
/// incrementally build the structure of the node.
1094+
/// - Returns: A `InfixOperatorExprSyntax` with all the fields populated in the builder
1095+
/// closure.
1096+
public init(_ build: (inout InfixOperatorExprSyntaxBuilder) -> Void) {
1097+
var builder = InfixOperatorExprSyntaxBuilder()
1098+
build(&builder)
1099+
let data = builder.buildData()
1100+
self.init(data)
1101+
}
1102+
}
1103+
10501104
public struct FloatLiteralExprSyntaxBuilder {
10511105
private var layout =
10521106
Array<RawSyntax?>(repeating: nil, count: 2)

Sources/SwiftSyntax/gyb_generated/SyntaxEnum.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public enum SyntaxEnum {
5959
case prefixOperatorExpr(PrefixOperatorExprSyntax)
6060
case binaryOperatorExpr(BinaryOperatorExprSyntax)
6161
case arrowExpr(ArrowExprSyntax)
62+
case infixOperatorExpr(InfixOperatorExprSyntax)
6263
case floatLiteralExpr(FloatLiteralExprSyntax)
6364
case tupleExpr(TupleExprSyntax)
6465
case arrayExpr(ArrayExprSyntax)
@@ -369,6 +370,8 @@ public extension Syntax {
369370
return .binaryOperatorExpr(BinaryOperatorExprSyntax(self)!)
370371
case .arrowExpr:
371372
return .arrowExpr(ArrowExprSyntax(self)!)
373+
case .infixOperatorExpr:
374+
return .infixOperatorExpr(InfixOperatorExprSyntax(self)!)
372375
case .floatLiteralExpr:
373376
return .floatLiteralExpr(FloatLiteralExprSyntax(self)!)
374377
case .tupleExpr:

Sources/SwiftSyntax/gyb_generated/SyntaxFactory.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,33 @@ public enum SyntaxFactory {
755755
], length: .zero, presence: presence))
756756
return ArrowExprSyntax(data)
757757
}
758+
public static func makeInfixOperatorExpr(_ garbageBeforeLeftOperand: GarbageNodesSyntax? = nil, leftOperand: ExprSyntax, _ garbageBetweenLeftOperandAndOperatorOperand: GarbageNodesSyntax? = nil, operatorOperand: ExprSyntax, _ garbageBetweenOperatorOperandAndRightOperand: GarbageNodesSyntax? = nil, rightOperand: ExprSyntax) -> InfixOperatorExprSyntax {
759+
let layout: [RawSyntax?] = [
760+
garbageBeforeLeftOperand?.raw,
761+
leftOperand.raw,
762+
garbageBetweenLeftOperandAndOperatorOperand?.raw,
763+
operatorOperand.raw,
764+
garbageBetweenOperatorOperandAndRightOperand?.raw,
765+
rightOperand.raw,
766+
]
767+
let raw = RawSyntax.createAndCalcLength(kind: SyntaxKind.infixOperatorExpr,
768+
layout: layout, presence: SourcePresence.present)
769+
let data = SyntaxData.forRoot(raw)
770+
return InfixOperatorExprSyntax(data)
771+
}
772+
773+
public static func makeBlankInfixOperatorExpr(presence: SourcePresence = .present) -> InfixOperatorExprSyntax {
774+
let data = SyntaxData.forRoot(RawSyntax.create(kind: .infixOperatorExpr,
775+
layout: [
776+
nil,
777+
RawSyntax.missing(SyntaxKind.missingExpr),
778+
nil,
779+
RawSyntax.missing(SyntaxKind.missingExpr),
780+
nil,
781+
RawSyntax.missing(SyntaxKind.missingExpr),
782+
], length: .zero, presence: presence))
783+
return InfixOperatorExprSyntax(data)
784+
}
758785
public static func makeFloatLiteralExpr(_ garbageBeforeFloatingDigits: GarbageNodesSyntax? = nil, floatingDigits: TokenSyntax) -> FloatLiteralExprSyntax {
759786
let layout: [RawSyntax?] = [
760787
garbageBeforeFloatingDigits?.raw,

Sources/SwiftSyntax/gyb_generated/SyntaxKind.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ internal enum SyntaxKind: CSyntaxKind {
5959
case prefixOperatorExpr = 39
6060
case binaryOperatorExpr = 40
6161
case arrowExpr = 41
62+
case infixOperatorExpr = 267
6263
case floatLiteralExpr = 42
6364
case tupleExpr = 43
6465
case arrayExpr = 44

Sources/SwiftSyntax/gyb_generated/SyntaxRewriter.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,13 @@ open class SyntaxRewriter {
324324
return ExprSyntax(visitChildren(node))
325325
}
326326

327+
/// Visit a `InfixOperatorExprSyntax`.
328+
/// - Parameter node: the node that is being visited
329+
/// - Returns: the rewritten node
330+
open func visit(_ node: InfixOperatorExprSyntax) -> ExprSyntax {
331+
return ExprSyntax(visitChildren(node))
332+
}
333+
327334
/// Visit a `FloatLiteralExprSyntax`.
328335
/// - Parameter node: the node that is being visited
329336
/// - Returns: the rewritten node
@@ -2343,6 +2350,16 @@ open class SyntaxRewriter {
23432350
return Syntax(visit(node))
23442351
}
23452352

2353+
/// Implementation detail of visit(_:). Do not call directly.
2354+
private func visitImplInfixOperatorExprSyntax(_ data: SyntaxData) -> Syntax {
2355+
let node = InfixOperatorExprSyntax(data)
2356+
// Accessing _syntaxNode directly is faster than calling Syntax(node)
2357+
visitPre(node._syntaxNode)
2358+
defer { visitPost(node._syntaxNode) }
2359+
if let newNode = visitAny(node._syntaxNode) { return newNode }
2360+
return Syntax(visit(node))
2361+
}
2362+
23462363
/// Implementation detail of visit(_:). Do not call directly.
23472364
private func visitImplFloatLiteralExprSyntax(_ data: SyntaxData) -> Syntax {
23482365
let node = FloatLiteralExprSyntax(data)
@@ -4621,6 +4638,8 @@ open class SyntaxRewriter {
46214638
return visitImplBinaryOperatorExprSyntax
46224639
case .arrowExpr:
46234640
return visitImplArrowExprSyntax
4641+
case .infixOperatorExpr:
4642+
return visitImplInfixOperatorExprSyntax
46244643
case .floatLiteralExpr:
46254644
return visitImplFloatLiteralExprSyntax
46264645
case .tupleExpr:
@@ -5150,6 +5169,8 @@ open class SyntaxRewriter {
51505169
return visitImplBinaryOperatorExprSyntax(data)
51515170
case .arrowExpr:
51525171
return visitImplArrowExprSyntax(data)
5172+
case .infixOperatorExpr:
5173+
return visitImplInfixOperatorExprSyntax(data)
51535174
case .floatLiteralExpr:
51545175
return visitImplFloatLiteralExprSyntax(data)
51555176
case .tupleExpr:

Sources/SwiftSyntax/gyb_generated/SyntaxVisitor.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,16 @@ open class SyntaxVisitor {
471471
/// The function called after visiting `ArrowExprSyntax` and its descendents.
472472
/// - node: the node we just finished visiting.
473473
open func visitPost(_ node: ArrowExprSyntax) {}
474+
/// Visiting `InfixOperatorExprSyntax` specifically.
475+
/// - Parameter node: the node we are visiting.
476+
/// - Returns: how should we continue visiting.
477+
open func visit(_ node: InfixOperatorExprSyntax) -> SyntaxVisitorContinueKind {
478+
return .visitChildren
479+
}
480+
481+
/// The function called after visiting `InfixOperatorExprSyntax` and its descendents.
482+
/// - node: the node we just finished visiting.
483+
open func visitPost(_ node: InfixOperatorExprSyntax) {}
474484
/// Visiting `FloatLiteralExprSyntax` specifically.
475485
/// - Parameter node: the node we are visiting.
476486
/// - Returns: how should we continue visiting.
@@ -3162,6 +3172,17 @@ open class SyntaxVisitor {
31623172
visitPost(node)
31633173
}
31643174

3175+
/// Implementation detail of doVisit(_:_:). Do not call directly.
3176+
private func visitImplInfixOperatorExprSyntax(_ data: SyntaxData) {
3177+
let node = InfixOperatorExprSyntax(data)
3178+
let needsChildren = (visit(node) == .visitChildren)
3179+
// Avoid calling into visitChildren if possible.
3180+
if needsChildren && node.raw.numberOfChildren > 0 {
3181+
visitChildren(node)
3182+
}
3183+
visitPost(node)
3184+
}
3185+
31653186
/// Implementation detail of doVisit(_:_:). Do not call directly.
31663187
private func visitImplFloatLiteralExprSyntax(_ data: SyntaxData) {
31673188
let node = FloatLiteralExprSyntax(data)
@@ -5622,6 +5643,8 @@ open class SyntaxVisitor {
56225643
visitImplBinaryOperatorExprSyntax(data)
56235644
case .arrowExpr:
56245645
visitImplArrowExprSyntax(data)
5646+
case .infixOperatorExpr:
5647+
visitImplInfixOperatorExprSyntax(data)
56255648
case .floatLiteralExpr:
56265649
visitImplFloatLiteralExprSyntax(data)
56275650
case .tupleExpr:

0 commit comments

Comments
 (0)