Skip to content

Commit 05f6206

Browse files
committed
Update swift-syntax for MoveExpr.
1 parent 0805792 commit 05f6206

File tree

15 files changed

+415
-3
lines changed

15 files changed

+415
-3
lines changed

Sources/SwiftSyntax/gyb_generated/Misc.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ extension SyntaxNode {
157157
return AwaitExprSyntax(asSyntaxData)
158158
}
159159

160+
public var isMoveExpr: Bool { return raw.kind == .moveExpr }
161+
public var asMoveExpr: MoveExprSyntax? {
162+
guard isMoveExpr else { return nil }
163+
return MoveExprSyntax(asSyntaxData)
164+
}
165+
160166
public var isDeclNameArgument: Bool { return raw.kind == .declNameArgument }
161167
public var asDeclNameArgument: DeclNameArgumentSyntax? {
162168
guard isDeclNameArgument else { return nil }
@@ -1631,6 +1637,8 @@ extension Syntax {
16311637
return node
16321638
case .awaitExpr(let node):
16331639
return node
1640+
case .moveExpr(let node):
1641+
return node
16341642
case .declNameArgument(let node):
16351643
return node
16361644
case .declNameArgumentList(let node):

Sources/SwiftSyntax/gyb_generated/SyntaxAnyVisitor.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
222222
override open func visitPost(_ node: AwaitExprSyntax) {
223223
visitAnyPost(node._syntaxNode)
224224
}
225+
override open func visit(_ node: MoveExprSyntax) -> SyntaxVisitorContinueKind {
226+
return visitAny(node._syntaxNode)
227+
}
228+
229+
override open func visitPost(_ node: MoveExprSyntax) {
230+
visitAnyPost(node._syntaxNode)
231+
}
225232
override open func visit(_ node: DeclNameArgumentSyntax) -> SyntaxVisitorContinueKind {
226233
return visitAny(node._syntaxNode)
227234
}

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, .moveExpr, .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:
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, .moveExpr, .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:
182182
break
183183
default:
184184
fatalError("Unable to create ExprSyntax from \(data.raw.kind)")

Sources/SwiftSyntax/gyb_generated/SyntaxBuilders.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,52 @@ extension AwaitExprSyntax {
302302
}
303303
}
304304

305+
public struct MoveExprSyntaxBuilder {
306+
private var layout =
307+
Array<RawSyntax?>(repeating: nil, count: 4)
308+
309+
internal init() {}
310+
311+
public mutating func useMoveKeyword(_ node: TokenSyntax) {
312+
let idx = MoveExprSyntax.Cursor.moveKeyword.rawValue
313+
layout[idx] = node.raw
314+
}
315+
316+
public mutating func useExpression(_ node: ExprSyntax) {
317+
let idx = MoveExprSyntax.Cursor.expression.rawValue
318+
layout[idx] = node.raw
319+
}
320+
321+
internal mutating func buildData() -> SyntaxData {
322+
if (layout[1] == nil) {
323+
layout[1] = RawSyntax.missingToken(TokenKind.contextualKeyword(""))
324+
}
325+
if (layout[3] == nil) {
326+
layout[3] = RawSyntax.missing(SyntaxKind.missingExpr)
327+
}
328+
329+
return .forRoot(RawSyntax.createAndCalcLength(kind: .moveExpr,
330+
layout: layout, presence: .present))
331+
}
332+
}
333+
334+
extension MoveExprSyntax {
335+
/// Creates a `MoveExprSyntax` using the provided build function.
336+
/// - Parameter:
337+
/// - build: A closure that will be invoked in order to initialize
338+
/// the fields of the syntax node.
339+
/// This closure is passed a `MoveExprSyntaxBuilder` which you can use to
340+
/// incrementally build the structure of the node.
341+
/// - Returns: A `MoveExprSyntax` with all the fields populated in the builder
342+
/// closure.
343+
public init(_ build: (inout MoveExprSyntaxBuilder) -> Void) {
344+
var builder = MoveExprSyntaxBuilder()
345+
build(&builder)
346+
let data = builder.buildData()
347+
self.init(data)
348+
}
349+
}
350+
305351
public struct DeclNameArgumentSyntaxBuilder {
306352
private var layout =
307353
Array<RawSyntax?>(repeating: nil, count: 4)

Sources/SwiftSyntax/gyb_generated/SyntaxEnum.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public enum SyntaxEnum {
3939
case stringLiteralSegments(StringLiteralSegmentsSyntax)
4040
case tryExpr(TryExprSyntax)
4141
case awaitExpr(AwaitExprSyntax)
42+
case moveExpr(MoveExprSyntax)
4243
case declNameArgument(DeclNameArgumentSyntax)
4344
case declNameArgumentList(DeclNameArgumentListSyntax)
4445
case declNameArguments(DeclNameArgumentsSyntax)
@@ -330,6 +331,8 @@ public extension Syntax {
330331
return .tryExpr(TryExprSyntax(self)!)
331332
case .awaitExpr:
332333
return .awaitExpr(AwaitExprSyntax(self)!)
334+
case .moveExpr:
335+
return .moveExpr(MoveExprSyntax(self)!)
333336
case .declNameArgument:
334337
return .declNameArgument(DeclNameArgumentSyntax(self)!)
335338
case .declNameArgumentList:

Sources/SwiftSyntax/gyb_generated/SyntaxFactory.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,29 @@ public enum SyntaxFactory {
353353
], length: .zero, presence: presence))
354354
return AwaitExprSyntax(data)
355355
}
356+
public static func makeMoveExpr(_ garbageBeforeMoveKeyword: GarbageNodesSyntax? = nil, moveKeyword: TokenSyntax, _ garbageBetweenMoveKeywordAndExpression: GarbageNodesSyntax? = nil, expression: ExprSyntax) -> MoveExprSyntax {
357+
let layout: [RawSyntax?] = [
358+
garbageBeforeMoveKeyword?.raw,
359+
moveKeyword.raw,
360+
garbageBetweenMoveKeywordAndExpression?.raw,
361+
expression.raw,
362+
]
363+
let raw = RawSyntax.createAndCalcLength(kind: SyntaxKind.moveExpr,
364+
layout: layout, presence: SourcePresence.present)
365+
let data = SyntaxData.forRoot(raw)
366+
return MoveExprSyntax(data)
367+
}
368+
369+
public static func makeBlankMoveExpr(presence: SourcePresence = .present) -> MoveExprSyntax {
370+
let data = SyntaxData.forRoot(RawSyntax.create(kind: .moveExpr,
371+
layout: [
372+
nil,
373+
RawSyntax.missingToken(TokenKind.contextualKeyword("")),
374+
nil,
375+
RawSyntax.missing(SyntaxKind.missingExpr),
376+
], length: .zero, presence: presence))
377+
return MoveExprSyntax(data)
378+
}
356379
public static func makeDeclNameArgument(_ garbageBeforeName: GarbageNodesSyntax? = nil, name: TokenSyntax, _ garbageBetweenNameAndColon: GarbageNodesSyntax? = nil, colon: TokenSyntax) -> DeclNameArgumentSyntax {
357380
let layout: [RawSyntax?] = [
358381
garbageBeforeName?.raw,

Sources/SwiftSyntax/gyb_generated/SyntaxKind.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ internal enum SyntaxKind: CSyntaxKind {
3939
case stringLiteralSegments = 168
4040
case tryExpr = 27
4141
case awaitExpr = 249
42+
case moveExpr = 268
4243
case declNameArgument = 94
4344
case declNameArgumentList = 169
4445
case declNameArguments = 95

Sources/SwiftSyntax/gyb_generated/SyntaxRewriter.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ open class SyntaxRewriter {
184184
return ExprSyntax(visitChildren(node))
185185
}
186186

187+
/// Visit a `MoveExprSyntax`.
188+
/// - Parameter node: the node that is being visited
189+
/// - Returns: the rewritten node
190+
open func visit(_ node: MoveExprSyntax) -> ExprSyntax {
191+
return ExprSyntax(visitChildren(node))
192+
}
193+
187194
/// Visit a `DeclNameArgumentSyntax`.
188195
/// - Parameter node: the node that is being visited
189196
/// - Returns: the rewritten node
@@ -2150,6 +2157,16 @@ open class SyntaxRewriter {
21502157
return Syntax(visit(node))
21512158
}
21522159

2160+
/// Implementation detail of visit(_:). Do not call directly.
2161+
private func visitImplMoveExprSyntax(_ data: SyntaxData) -> Syntax {
2162+
let node = MoveExprSyntax(data)
2163+
// Accessing _syntaxNode directly is faster than calling Syntax(node)
2164+
visitPre(node._syntaxNode)
2165+
defer { visitPost(node._syntaxNode) }
2166+
if let newNode = visitAny(node._syntaxNode) { return newNode }
2167+
return Syntax(visit(node))
2168+
}
2169+
21532170
/// Implementation detail of visit(_:). Do not call directly.
21542171
private func visitImplDeclNameArgumentSyntax(_ data: SyntaxData) -> Syntax {
21552172
let node = DeclNameArgumentSyntax(data)
@@ -4598,6 +4615,8 @@ open class SyntaxRewriter {
45984615
return visitImplTryExprSyntax
45994616
case .awaitExpr:
46004617
return visitImplAwaitExprSyntax
4618+
case .moveExpr:
4619+
return visitImplMoveExprSyntax
46014620
case .declNameArgument:
46024621
return visitImplDeclNameArgumentSyntax
46034622
case .declNameArgumentList:
@@ -5129,6 +5148,8 @@ open class SyntaxRewriter {
51295148
return visitImplTryExprSyntax(data)
51305149
case .awaitExpr:
51315150
return visitImplAwaitExprSyntax(data)
5151+
case .moveExpr:
5152+
return visitImplMoveExprSyntax(data)
51325153
case .declNameArgument:
51335154
return visitImplDeclNameArgumentSyntax(data)
51345155
case .declNameArgumentList:

Sources/SwiftSyntax/gyb_generated/SyntaxVisitor.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ open class SyntaxVisitor {
271271
/// The function called after visiting `AwaitExprSyntax` and its descendents.
272272
/// - node: the node we just finished visiting.
273273
open func visitPost(_ node: AwaitExprSyntax) {}
274+
/// Visiting `MoveExprSyntax` specifically.
275+
/// - Parameter node: the node we are visiting.
276+
/// - Returns: how should we continue visiting.
277+
open func visit(_ node: MoveExprSyntax) -> SyntaxVisitorContinueKind {
278+
return .visitChildren
279+
}
280+
281+
/// The function called after visiting `MoveExprSyntax` and its descendents.
282+
/// - node: the node we just finished visiting.
283+
open func visitPost(_ node: MoveExprSyntax) {}
274284
/// Visiting `DeclNameArgumentSyntax` specifically.
275285
/// - Parameter node: the node we are visiting.
276286
/// - Returns: how should we continue visiting.
@@ -2952,6 +2962,17 @@ open class SyntaxVisitor {
29522962
visitPost(node)
29532963
}
29542964

2965+
/// Implementation detail of doVisit(_:_:). Do not call directly.
2966+
private func visitImplMoveExprSyntax(_ data: SyntaxData) {
2967+
let node = MoveExprSyntax(data)
2968+
let needsChildren = (visit(node) == .visitChildren)
2969+
// Avoid calling into visitChildren if possible.
2970+
if needsChildren && node.raw.numberOfChildren > 0 {
2971+
visitChildren(node)
2972+
}
2973+
visitPost(node)
2974+
}
2975+
29552976
/// Implementation detail of doVisit(_:_:). Do not call directly.
29562977
private func visitImplDeclNameArgumentSyntax(_ data: SyntaxData) {
29572978
let node = DeclNameArgumentSyntax(data)
@@ -5603,6 +5624,8 @@ open class SyntaxVisitor {
56035624
visitImplTryExprSyntax(data)
56045625
case .awaitExpr:
56055626
visitImplAwaitExprSyntax(data)
5627+
case .moveExpr:
5628+
visitImplMoveExprSyntax(data)
56065629
case .declNameArgument:
56075630
visitImplDeclNameArgumentSyntax(data)
56085631
case .declNameArgumentList:

0 commit comments

Comments
 (0)