Skip to content

Regenerate with InfixOperatorExpr. #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/SwiftSyntax/gyb_generated/Misc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ extension SyntaxNode {
return ArrowExprSyntax(asSyntaxData)
}

public var isInfixOperatorExpr: Bool { return raw.kind == .infixOperatorExpr }
public var asInfixOperatorExpr: InfixOperatorExprSyntax? {
guard isInfixOperatorExpr else { return nil }
return InfixOperatorExprSyntax(asSyntaxData)
}

public var isFloatLiteralExpr: Bool { return raw.kind == .floatLiteralExpr }
public var asFloatLiteralExpr: FloatLiteralExprSyntax? {
guard isFloatLiteralExpr else { return nil }
Expand Down Expand Up @@ -1671,6 +1677,8 @@ extension Syntax {
return node
case .arrowExpr(let node):
return node
case .infixOperatorExpr(let node):
return node
case .floatLiteralExpr(let node):
return node
case .tupleExpr(let node):
Expand Down
7 changes: 7 additions & 0 deletions Sources/SwiftSyntax/gyb_generated/SyntaxAnyVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
override open func visitPost(_ node: ArrowExprSyntax) {
visitAnyPost(node._syntaxNode)
}
override open func visit(_ node: InfixOperatorExprSyntax) -> SyntaxVisitorContinueKind {
return visitAny(node._syntaxNode)
}

override open func visitPost(_ node: InfixOperatorExprSyntax) {
visitAnyPost(node._syntaxNode)
}
override open func visit(_ node: FloatLiteralExprSyntax) -> SyntaxVisitorContinueKind {
return visitAny(node._syntaxNode)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftSyntax/gyb_generated/SyntaxBaseNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
/// `nil` if the conversion is not possible.
public init?(_ syntax: Syntax) {
switch syntax.raw.kind {
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:
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:
self._syntaxNode = syntax
default:
return nil
Expand All @@ -178,7 +178,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
// Assert that the kind of the given data matches in debug builds.
#if DEBUG
switch data.raw.kind {
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:
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:
break
default:
fatalError("Unable to create ExprSyntax from \(data.raw.kind)")
Expand Down
54 changes: 54 additions & 0 deletions Sources/SwiftSyntax/gyb_generated/SyntaxBuilders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,60 @@ extension ArrowExprSyntax {
}
}

public struct InfixOperatorExprSyntaxBuilder {
private var layout =
Array<RawSyntax?>(repeating: nil, count: 6)

internal init() {}

public mutating func useLeftOperand(_ node: ExprSyntax) {
let idx = InfixOperatorExprSyntax.Cursor.leftOperand.rawValue
layout[idx] = node.raw
}

public mutating func useOperatorOperand(_ node: ExprSyntax) {
let idx = InfixOperatorExprSyntax.Cursor.operatorOperand.rawValue
layout[idx] = node.raw
}

public mutating func useRightOperand(_ node: ExprSyntax) {
let idx = InfixOperatorExprSyntax.Cursor.rightOperand.rawValue
layout[idx] = node.raw
}

internal mutating func buildData() -> SyntaxData {
if (layout[1] == nil) {
layout[1] = RawSyntax.missing(SyntaxKind.missingExpr)
}
if (layout[3] == nil) {
layout[3] = RawSyntax.missing(SyntaxKind.missingExpr)
}
if (layout[5] == nil) {
layout[5] = RawSyntax.missing(SyntaxKind.missingExpr)
}

return .forRoot(RawSyntax.createAndCalcLength(kind: .infixOperatorExpr,
layout: layout, presence: .present))
}
}

extension InfixOperatorExprSyntax {
/// Creates a `InfixOperatorExprSyntax` using the provided build function.
/// - Parameter:
/// - build: A closure that will be invoked in order to initialize
/// the fields of the syntax node.
/// This closure is passed a `InfixOperatorExprSyntaxBuilder` which you can use to
/// incrementally build the structure of the node.
/// - Returns: A `InfixOperatorExprSyntax` with all the fields populated in the builder
/// closure.
public init(_ build: (inout InfixOperatorExprSyntaxBuilder) -> Void) {
var builder = InfixOperatorExprSyntaxBuilder()
build(&builder)
let data = builder.buildData()
self.init(data)
}
}

public struct FloatLiteralExprSyntaxBuilder {
private var layout =
Array<RawSyntax?>(repeating: nil, count: 2)
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftSyntax/gyb_generated/SyntaxEnum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public enum SyntaxEnum {
case prefixOperatorExpr(PrefixOperatorExprSyntax)
case binaryOperatorExpr(BinaryOperatorExprSyntax)
case arrowExpr(ArrowExprSyntax)
case infixOperatorExpr(InfixOperatorExprSyntax)
case floatLiteralExpr(FloatLiteralExprSyntax)
case tupleExpr(TupleExprSyntax)
case arrayExpr(ArrayExprSyntax)
Expand Down Expand Up @@ -370,6 +371,8 @@ public extension Syntax {
return .binaryOperatorExpr(BinaryOperatorExprSyntax(self)!)
case .arrowExpr:
return .arrowExpr(ArrowExprSyntax(self)!)
case .infixOperatorExpr:
return .infixOperatorExpr(InfixOperatorExprSyntax(self)!)
case .floatLiteralExpr:
return .floatLiteralExpr(FloatLiteralExprSyntax(self)!)
case .tupleExpr:
Expand Down
27 changes: 27 additions & 0 deletions Sources/SwiftSyntax/gyb_generated/SyntaxFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,33 @@ public enum SyntaxFactory {
], length: .zero, presence: presence))
return ArrowExprSyntax(data)
}
public static func makeInfixOperatorExpr(_ garbageBeforeLeftOperand: GarbageNodesSyntax? = nil, leftOperand: ExprSyntax, _ garbageBetweenLeftOperandAndOperatorOperand: GarbageNodesSyntax? = nil, operatorOperand: ExprSyntax, _ garbageBetweenOperatorOperandAndRightOperand: GarbageNodesSyntax? = nil, rightOperand: ExprSyntax) -> InfixOperatorExprSyntax {
let layout: [RawSyntax?] = [
garbageBeforeLeftOperand?.raw,
leftOperand.raw,
garbageBetweenLeftOperandAndOperatorOperand?.raw,
operatorOperand.raw,
garbageBetweenOperatorOperandAndRightOperand?.raw,
rightOperand.raw,
]
let raw = RawSyntax.createAndCalcLength(kind: SyntaxKind.infixOperatorExpr,
layout: layout, presence: SourcePresence.present)
let data = SyntaxData.forRoot(raw)
return InfixOperatorExprSyntax(data)
}

public static func makeBlankInfixOperatorExpr(presence: SourcePresence = .present) -> InfixOperatorExprSyntax {
let data = SyntaxData.forRoot(RawSyntax.create(kind: .infixOperatorExpr,
layout: [
nil,
RawSyntax.missing(SyntaxKind.missingExpr),
nil,
RawSyntax.missing(SyntaxKind.missingExpr),
nil,
RawSyntax.missing(SyntaxKind.missingExpr),
], length: .zero, presence: presence))
return InfixOperatorExprSyntax(data)
}
public static func makeFloatLiteralExpr(_ garbageBeforeFloatingDigits: GarbageNodesSyntax? = nil, floatingDigits: TokenSyntax) -> FloatLiteralExprSyntax {
let layout: [RawSyntax?] = [
garbageBeforeFloatingDigits?.raw,
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftSyntax/gyb_generated/SyntaxKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ internal enum SyntaxKind: CSyntaxKind {
case prefixOperatorExpr = 39
case binaryOperatorExpr = 40
case arrowExpr = 41
case infixOperatorExpr = 268
case floatLiteralExpr = 42
case tupleExpr = 43
case arrayExpr = 44
Expand Down
21 changes: 21 additions & 0 deletions Sources/SwiftSyntax/gyb_generated/SyntaxRewriter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ open class SyntaxRewriter {
return ExprSyntax(visitChildren(node))
}

/// Visit a `InfixOperatorExprSyntax`.
/// - Parameter node: the node that is being visited
/// - Returns: the rewritten node
open func visit(_ node: InfixOperatorExprSyntax) -> ExprSyntax {
return ExprSyntax(visitChildren(node))
}

/// Visit a `FloatLiteralExprSyntax`.
/// - Parameter node: the node that is being visited
/// - Returns: the rewritten node
Expand Down Expand Up @@ -2350,6 +2357,16 @@ open class SyntaxRewriter {
return Syntax(visit(node))
}

/// Implementation detail of visit(_:). Do not call directly.
private func visitImplInfixOperatorExprSyntax(_ data: SyntaxData) -> Syntax {
let node = InfixOperatorExprSyntax(data)
// Accessing _syntaxNode directly is faster than calling Syntax(node)
visitPre(node._syntaxNode)
defer { visitPost(node._syntaxNode) }
if let newNode = visitAny(node._syntaxNode) { return newNode }
return Syntax(visit(node))
}

/// Implementation detail of visit(_:). Do not call directly.
private func visitImplFloatLiteralExprSyntax(_ data: SyntaxData) -> Syntax {
let node = FloatLiteralExprSyntax(data)
Expand Down Expand Up @@ -4638,6 +4655,8 @@ open class SyntaxRewriter {
return visitImplBinaryOperatorExprSyntax
case .arrowExpr:
return visitImplArrowExprSyntax
case .infixOperatorExpr:
return visitImplInfixOperatorExprSyntax
case .floatLiteralExpr:
return visitImplFloatLiteralExprSyntax
case .tupleExpr:
Expand Down Expand Up @@ -5169,6 +5188,8 @@ open class SyntaxRewriter {
return visitImplBinaryOperatorExprSyntax(data)
case .arrowExpr:
return visitImplArrowExprSyntax(data)
case .infixOperatorExpr:
return visitImplInfixOperatorExprSyntax(data)
case .floatLiteralExpr:
return visitImplFloatLiteralExprSyntax(data)
case .tupleExpr:
Expand Down
23 changes: 23 additions & 0 deletions Sources/SwiftSyntax/gyb_generated/SyntaxVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,16 @@ open class SyntaxVisitor {
/// The function called after visiting `ArrowExprSyntax` and its descendents.
/// - node: the node we just finished visiting.
open func visitPost(_ node: ArrowExprSyntax) {}
/// Visiting `InfixOperatorExprSyntax` specifically.
/// - Parameter node: the node we are visiting.
/// - Returns: how should we continue visiting.
open func visit(_ node: InfixOperatorExprSyntax) -> SyntaxVisitorContinueKind {
return .visitChildren
}

/// The function called after visiting `InfixOperatorExprSyntax` and its descendents.
/// - node: the node we just finished visiting.
open func visitPost(_ node: InfixOperatorExprSyntax) {}
/// Visiting `FloatLiteralExprSyntax` specifically.
/// - Parameter node: the node we are visiting.
/// - Returns: how should we continue visiting.
Expand Down Expand Up @@ -3172,6 +3182,17 @@ open class SyntaxVisitor {
visitPost(node)
}

/// Implementation detail of doVisit(_:_:). Do not call directly.
private func visitImplInfixOperatorExprSyntax(_ data: SyntaxData) {
let node = InfixOperatorExprSyntax(data)
let needsChildren = (visit(node) == .visitChildren)
// Avoid calling into visitChildren if possible.
if needsChildren && node.raw.numberOfChildren > 0 {
visitChildren(node)
}
visitPost(node)
}

/// Implementation detail of doVisit(_:_:). Do not call directly.
private func visitImplFloatLiteralExprSyntax(_ data: SyntaxData) {
let node = FloatLiteralExprSyntax(data)
Expand Down Expand Up @@ -5643,6 +5664,8 @@ open class SyntaxVisitor {
visitImplBinaryOperatorExprSyntax(data)
case .arrowExpr:
visitImplArrowExprSyntax(data)
case .infixOperatorExpr:
visitImplInfixOperatorExprSyntax(data)
case .floatLiteralExpr:
visitImplFloatLiteralExprSyntax(data)
case .tupleExpr:
Expand Down
Loading