Skip to content

Commit 64c5a34

Browse files
committed
Update swift-syntax for MoveExpr.
1 parent f8f9100 commit 64c5a34

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 }
@@ -1637,6 +1643,8 @@ extension Syntax {
16371643
return node
16381644
case .awaitExpr(let node):
16391645
return node
1646+
case .moveExpr(let node):
1647+
return node
16401648
case .declNameArgument(let node):
16411649
return node
16421650
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, .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:
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, .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, .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:
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, .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: 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)
@@ -331,6 +332,8 @@ public extension Syntax {
331332
return .tryExpr(TryExprSyntax(self)!)
332333
case .awaitExpr:
333334
return .awaitExpr(AwaitExprSyntax(self)!)
335+
case .moveExpr:
336+
return .moveExpr(MoveExprSyntax(self)!)
334337
case .declNameArgument:
335338
return .declNameArgument(DeclNameArgumentSyntax(self)!)
336339
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 = 269
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
@@ -2157,6 +2164,16 @@ open class SyntaxRewriter {
21572164
return Syntax(visit(node))
21582165
}
21592166

2167+
/// Implementation detail of visit(_:). Do not call directly.
2168+
private func visitImplMoveExprSyntax(_ data: SyntaxData) -> Syntax {
2169+
let node = MoveExprSyntax(data)
2170+
// Accessing _syntaxNode directly is faster than calling Syntax(node)
2171+
visitPre(node._syntaxNode)
2172+
defer { visitPost(node._syntaxNode) }
2173+
if let newNode = visitAny(node._syntaxNode) { return newNode }
2174+
return Syntax(visit(node))
2175+
}
2176+
21602177
/// Implementation detail of visit(_:). Do not call directly.
21612178
private func visitImplDeclNameArgumentSyntax(_ data: SyntaxData) -> Syntax {
21622179
let node = DeclNameArgumentSyntax(data)
@@ -4615,6 +4632,8 @@ open class SyntaxRewriter {
46154632
return visitImplTryExprSyntax
46164633
case .awaitExpr:
46174634
return visitImplAwaitExprSyntax
4635+
case .moveExpr:
4636+
return visitImplMoveExprSyntax
46184637
case .declNameArgument:
46194638
return visitImplDeclNameArgumentSyntax
46204639
case .declNameArgumentList:
@@ -5148,6 +5167,8 @@ open class SyntaxRewriter {
51485167
return visitImplTryExprSyntax(data)
51495168
case .awaitExpr:
51505169
return visitImplAwaitExprSyntax(data)
5170+
case .moveExpr:
5171+
return visitImplMoveExprSyntax(data)
51515172
case .declNameArgument:
51525173
return visitImplDeclNameArgumentSyntax(data)
51535174
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.
@@ -2962,6 +2972,17 @@ open class SyntaxVisitor {
29622972
visitPost(node)
29632973
}
29642974

2975+
/// Implementation detail of doVisit(_:_:). Do not call directly.
2976+
private func visitImplMoveExprSyntax(_ data: SyntaxData) {
2977+
let node = MoveExprSyntax(data)
2978+
let needsChildren = (visit(node) == .visitChildren)
2979+
// Avoid calling into visitChildren if possible.
2980+
if needsChildren && node.raw.numberOfChildren > 0 {
2981+
visitChildren(node)
2982+
}
2983+
visitPost(node)
2984+
}
2985+
29652986
/// Implementation detail of doVisit(_:_:). Do not call directly.
29662987
private func visitImplDeclNameArgumentSyntax(_ data: SyntaxData) {
29672988
let node = DeclNameArgumentSyntax(data)
@@ -5624,6 +5645,8 @@ open class SyntaxVisitor {
56245645
visitImplTryExprSyntax(data)
56255646
case .awaitExpr:
56265647
visitImplAwaitExprSyntax(data)
5648+
case .moveExpr:
5649+
visitImplMoveExprSyntax(data)
56275650
case .declNameArgument:
56285651
visitImplDeclNameArgumentSyntax(data)
56295652
case .declNameArgumentList:

0 commit comments

Comments
 (0)