Skip to content

Commit dae4ef8

Browse files
committed
Adjustments for node renames in swift-syntax
1 parent 8507216 commit dae4ef8

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,8 +3360,8 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
33603360
private func maybeGroupAroundSubexpression(
33613361
_ expr: ExprSyntax, combiningOperator operatorExpr: ExprSyntax? = nil
33623362
) {
3363-
switch Syntax(expr).as(SyntaxEnum.self) {
3364-
case .memberAccessExpr, .subscriptExpr:
3363+
switch Syntax(expr).kind {
3364+
case .memberAccessExpr, .subscriptCallExpr:
33653365
before(expr.firstToken(viewMode: .sourceAccurate), tokens: .open)
33663366
after(expr.lastToken(viewMode: .sourceAccurate), tokens: .close)
33673367
default:
@@ -3458,19 +3458,19 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
34583458
return leftmostExpr(of: asExpr.expression, ifMatching: predicate)
34593459
case .isExpr(let isExpr):
34603460
return leftmostExpr(of: isExpr.expression, ifMatching: predicate)
3461-
case .forcedValueExpr(let forcedValueExpr):
3461+
case .forceUnwrapExpr(let forcedValueExpr):
34623462
return leftmostExpr(of: forcedValueExpr.expression, ifMatching: predicate)
34633463
case .optionalChainingExpr(let optionalChainingExpr):
34643464
return leftmostExpr(of: optionalChainingExpr.expression, ifMatching: predicate)
3465-
case .postfixUnaryExpr(let postfixUnaryExpr):
3465+
case .postfixOperatorExpr(let postfixUnaryExpr):
34663466
return leftmostExpr(of: postfixUnaryExpr.expression, ifMatching: predicate)
34673467
case .prefixOperatorExpr(let prefixOperatorExpr):
3468-
return leftmostExpr(of: prefixOperatorExpr.base, ifMatching: predicate)
3468+
return leftmostExpr(of: prefixOperatorExpr.expression, ifMatching: predicate)
34693469
case .ternaryExpr(let ternaryExpr):
34703470
return leftmostExpr(of: ternaryExpr.condition, ifMatching: predicate)
34713471
case .functionCallExpr(let functionCallExpr):
34723472
return leftmostExpr(of: functionCallExpr.calledExpression, ifMatching: predicate)
3473-
case .subscriptExpr(let subscriptExpr):
3473+
case .subscriptCallExpr(let subscriptExpr):
34743474
return leftmostExpr(of: subscriptExpr.calledExpression, ifMatching: predicate)
34753475
case .memberAccessExpr(let memberAccessExpr):
34763476
return memberAccessExpr.base.flatMap { leftmostExpr(of: $0, ifMatching: predicate) }

Sources/SwiftFormatRules/DontRepeatTypeInStaticProperties.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public final class DontRepeatTypeInStaticProperties: SyntaxLintRule {
4646
let members = node.memberBlock.members
4747

4848
switch Syntax(node.extendedType).as(SyntaxEnum.self) {
49-
case .simpleTypeIdentifier(let simpleType):
49+
case .identifierType(let simpleType):
5050
diagnoseStaticMembers(members, endingWith: simpleType.name.text)
51-
case .memberTypeIdentifier(let memberType):
51+
case .memberType(let memberType):
5252
// We don't need to drill recursively into this structure because types with more than two
5353
// components are constructed left-heavy; that is, `A.B.C.D` is structured as `((A.B).C).D`,
5454
// and the final component of the top type is what we want.

Sources/SwiftFormatRules/FileScopedDeclarationPrivacy.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public final class FileScopedDeclarationPrivacy: SyntaxFormatRule {
9191
modifiers: protocolDecl.modifiers,
9292
factory: { protocolDecl.with(\.modifiers, $0) }))
9393

94-
case .typealiasDecl(let typealiasDecl):
94+
case .typeAliasDecl(let typealiasDecl):
9595
return DeclSyntax(rewrittenDecl(
9696
typealiasDecl,
9797
modifiers: typealiasDecl.modifiers,

Sources/SwiftFormatRules/UseShorthandTypeNames.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule {
241241
// otherwise the "?" applies to the return type instead of the function type. Attach the
242242
// leading trivia to the left-paren that we're adding in this case.
243243
let tupleTypeElement = TupleTypeElementSyntax(
244-
inoutKeyword: nil, name: nil, secondName: nil, colon: nil, type: TypeSyntax(functionType),
244+
inoutKeyword: nil, firstName: nil, secondName: nil, colon: nil, type: TypeSyntax(functionType),
245245
ellipsis: nil, initializer: nil, trailingComma: nil)
246246
let tupleTypeElementList = TupleTypeElementListSyntax([tupleTypeElement])
247247
let tupleType = TupleTypeSyntax(
@@ -360,7 +360,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule {
360360
/// written `Array<Int>.Index` to compile correctly.
361361
private func expressionRepresentation(of type: TypeSyntax) -> ExprSyntax? {
362362
switch Syntax(type).as(SyntaxEnum.self) {
363-
case .simpleTypeIdentifier(let simpleTypeIdentifier):
363+
case .identifierType(let simpleTypeIdentifier):
364364
let identifierExpr = IdentifierExprSyntax(
365365
identifier: simpleTypeIdentifier.name,
366366
declNameArguments: nil)
@@ -378,7 +378,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule {
378378
return ExprSyntax(identifierExpr)
379379
}
380380

381-
case .memberTypeIdentifier(let memberTypeIdentifier):
381+
case .memberType(let memberTypeIdentifier):
382382
guard let baseType = expressionRepresentation(of: memberTypeIdentifier.baseType) else {
383383
return nil
384384
}

0 commit comments

Comments
 (0)