Skip to content

Commit efa311a

Browse files
committed
Use newer equivalents of deprecated node names
1 parent ad05b7c commit efa311a

12 files changed

+89
-89
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
248248

249249
arrangeAttributeList(node.attributes)
250250

251-
let hasArguments = !node.signature.input.parameterList.isEmpty
251+
let hasArguments = !node.signature.parameterClause.parameterList.isEmpty
252252

253253
// Prioritize keeping ") -> <return_type>" together. We can only do this if the macro has
254254
// arguments.
@@ -257,8 +257,8 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
257257
after(node.signature.lastToken(viewMode: .sourceAccurate), tokens: .close)
258258
}
259259

260-
let mustBreak = node.signature.output != nil || node.definition != nil
261-
arrangeParameterClause(node.signature.input, forcesBreakBeforeRightParen: mustBreak)
260+
let mustBreak = node.signature.returnClause != nil || node.definition != nil
261+
arrangeParameterClause(node.signature.parameterClause, forcesBreakBeforeRightParen: mustBreak)
262262

263263
// Prioritize keeping "<modifiers> macro <name>(" together. Also include the ")" if the
264264
// parameter list is empty.
@@ -267,9 +267,9 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
267267
before(firstTokenAfterAttributes, tokens: .open)
268268
after(node.macroKeyword, tokens: .break)
269269
if hasArguments || node.genericParameterClause != nil {
270-
after(node.signature.input.leftParen, tokens: .close)
270+
after(node.signature.parameterClause.leftParen, tokens: .close)
271271
} else {
272-
after(node.signature.input.rightParen, tokens: .close)
272+
after(node.signature.parameterClause.rightParen, tokens: .close)
273273
}
274274

275275
if let genericWhereClause = node.genericWhereClause {
@@ -327,7 +327,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
327327
// MARK: - Function and function-like declaration nodes (initializers, deinitializers, subscripts)
328328

329329
override func visit(_ node: FunctionDeclSyntax) -> SyntaxVisitorContinueKind {
330-
let hasArguments = !node.signature.input.parameterList.isEmpty
330+
let hasArguments = !node.signature.parameterClause.parameterList.isEmpty
331331

332332
// Prioritize keeping ") throws -> <return_type>" together. We can only do this if the function
333333
// has arguments.
@@ -336,18 +336,18 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
336336
after(node.signature.lastToken(viewMode: .sourceAccurate), tokens: .close)
337337
}
338338

339-
let mustBreak = node.body != nil || node.signature.output != nil
340-
arrangeParameterClause(node.signature.input, forcesBreakBeforeRightParen: mustBreak)
339+
let mustBreak = node.body != nil || node.signature.returnClause != nil
340+
arrangeParameterClause(node.signature.parameterClause, forcesBreakBeforeRightParen: mustBreak)
341341

342342
// Prioritize keeping "<modifiers> func <name>(" together. Also include the ")" if the parameter
343343
// list is empty.
344344
let firstTokenAfterAttributes = node.modifiers?.firstToken(viewMode: .sourceAccurate) ?? node.funcKeyword
345345
before(firstTokenAfterAttributes, tokens: .open)
346346
after(node.funcKeyword, tokens: .break)
347347
if hasArguments || node.genericParameterClause != nil {
348-
after(node.signature.input.leftParen, tokens: .close)
348+
after(node.signature.parameterClause.leftParen, tokens: .close)
349349
} else {
350-
after(node.signature.input.rightParen, tokens: .close)
350+
after(node.signature.parameterClause.rightParen, tokens: .close)
351351
}
352352

353353
// Add a non-breaking space after the identifier if it's an operator, to separate it visually
@@ -369,7 +369,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
369369
}
370370

371371
override func visit(_ node: InitializerDeclSyntax) -> SyntaxVisitorContinueKind {
372-
let hasArguments = !node.signature.input.parameterList.isEmpty
372+
let hasArguments = !node.signature.parameterClause.parameterList.isEmpty
373373

374374
// Prioritize keeping ") throws" together. We can only do this if the function
375375
// has arguments.
@@ -378,16 +378,16 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
378378
after(node.signature.lastToken(viewMode: .sourceAccurate), tokens: .close)
379379
}
380380

381-
arrangeParameterClause(node.signature.input, forcesBreakBeforeRightParen: node.body != nil)
381+
arrangeParameterClause(node.signature.parameterClause, forcesBreakBeforeRightParen: node.body != nil)
382382

383383
// Prioritize keeping "<modifiers> init<punctuation>" together.
384384
let firstTokenAfterAttributes = node.modifiers?.firstToken(viewMode: .sourceAccurate) ?? node.initKeyword
385385
before(firstTokenAfterAttributes, tokens: .open)
386386

387387
if hasArguments || node.genericParameterClause != nil {
388-
after(node.signature.input.leftParen, tokens: .close)
388+
after(node.signature.parameterClause.leftParen, tokens: .close)
389389
} else {
390-
after(node.signature.input.rightParen, tokens: .close)
390+
after(node.signature.parameterClause.rightParen, tokens: .close)
391391
}
392392

393393
arrangeFunctionLikeDecl(
@@ -411,7 +411,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
411411
}
412412

413413
override func visit(_ node: SubscriptDeclSyntax) -> SyntaxVisitorContinueKind {
414-
let hasArguments = !node.indices.parameterList.isEmpty
414+
let hasArguments = !node.parameterClause.parameterList.isEmpty
415415

416416
before(node.firstToken(viewMode: .sourceAccurate), tokens: .open)
417417

@@ -420,17 +420,17 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
420420
before(firstModifierToken, tokens: .open)
421421

422422
if hasArguments || node.genericParameterClause != nil {
423-
after(node.indices.leftParen, tokens: .close)
423+
after(node.parameterClause.leftParen, tokens: .close)
424424
} else {
425-
after(node.indices.rightParen, tokens: .close)
425+
after(node.parameterClause.rightParen, tokens: .close)
426426
}
427427
}
428428

429429
// Prioritize keeping ") -> <return_type>" together. We can only do this if the subscript has
430430
// arguments.
431431
if hasArguments && config.prioritizeKeepingFunctionOutputTogether {
432432
// Due to visitation order, the matching .open break is added in ParameterClauseSyntax.
433-
after(node.result.lastToken(viewMode: .sourceAccurate), tokens: .close)
433+
after(node.returnClause.lastToken(viewMode: .sourceAccurate), tokens: .close)
434434
}
435435

436436
arrangeAttributeList(node.attributes)
@@ -440,7 +440,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
440440
after(genericWhereClause.lastToken(viewMode: .sourceAccurate), tokens: .close)
441441
}
442442

443-
before(node.result.firstToken(viewMode: .sourceAccurate), tokens: .break)
443+
before(node.returnClause.firstToken(viewMode: .sourceAccurate), tokens: .break)
444444

445445
if let accessorOrCodeBlock = node.accessor {
446446
switch accessorOrCodeBlock {
@@ -453,7 +453,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
453453

454454
after(node.lastToken(viewMode: .sourceAccurate), tokens: .close)
455455

456-
arrangeParameterClause(node.indices, forcesBreakBeforeRightParen: true)
456+
arrangeParameterClause(node.parameterClause, forcesBreakBeforeRightParen: true)
457457

458458
return .visitChildren
459459
}
@@ -1185,22 +1185,22 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
11851185
before(node.firstToken(viewMode: .sourceAccurate), tokens: .open)
11861186

11871187
arrangeAttributeList(
1188-
node.attributes, suppressFinalBreak: node.input == nil && node.capture == nil)
1188+
node.attributes, suppressFinalBreak: node.parameterClause == nil && node.capture == nil)
11891189

1190-
if let input = node.input {
1190+
if let parameterClause = node.parameterClause {
11911191
// We unconditionally put a break before the `in` keyword below, so we should only put a break
11921192
// after the capture list's right bracket if there are arguments following it or we'll end up
11931193
// with an extra space if the line doesn't wrap.
11941194
after(node.capture?.rightSquare, tokens: .break(.same))
11951195

1196-
// When it's parenthesized, the input is a `ParameterClauseSyntax`. Otherwise, it's a
1196+
// When it's parenthesized, the parameterClause is a `ParameterClauseSyntax`. Otherwise, it's a
11971197
// `ClosureParamListSyntax`. The parenthesized version is wrapped in open/close breaks so that
11981198
// the parens create an extra level of indentation.
1199-
if let parameterClause = input.as(ClosureParameterClauseSyntax.self) {
1199+
if let closureParameterClause = parameterClause.as(ClosureParameterClauseSyntax.self) {
12001200
// Whether we should prioritize keeping ") throws -> <return_type>" together. We can only do
12011201
// this if the closure has arguments.
12021202
let keepOutputTogether =
1203-
!parameterClause.parameterList.isEmpty && config.prioritizeKeepingFunctionOutputTogether
1203+
!closureParameterClause.parameterList.isEmpty && config.prioritizeKeepingFunctionOutputTogether
12041204

12051205
// Keep the output together by grouping from the right paren to the end of the output.
12061206
if keepOutputTogether {
@@ -1211,20 +1211,20 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
12111211
} else {
12121212
// Group outside of the parens, so that the argument list together, preferring to break
12131213
// between the argument list and the output.
1214-
before(input.firstToken(viewMode: .sourceAccurate), tokens: .open)
1215-
after(input.lastToken(viewMode: .sourceAccurate), tokens: .close)
1214+
before(parameterClause.firstToken(viewMode: .sourceAccurate), tokens: .open)
1215+
after(parameterClause.lastToken(viewMode: .sourceAccurate), tokens: .close)
12161216
}
12171217

1218-
arrangeClosureParameterClause(parameterClause, forcesBreakBeforeRightParen: true)
1218+
arrangeClosureParameterClause(closureParameterClause, forcesBreakBeforeRightParen: true)
12191219
} else {
12201220
// Group around the arguments, but don't use open/close breaks because there are no parens
12211221
// to create a new scope.
1222-
before(input.firstToken(viewMode: .sourceAccurate), tokens: .open(argumentListConsistency()))
1223-
after(input.lastToken(viewMode: .sourceAccurate), tokens: .close)
1222+
before(parameterClause.firstToken(viewMode: .sourceAccurate), tokens: .open(argumentListConsistency()))
1223+
after(parameterClause.lastToken(viewMode: .sourceAccurate), tokens: .close)
12241224
}
12251225
}
12261226

1227-
before(node.output?.arrow, tokens: .break)
1227+
before(node.returnClause?.arrow, tokens: .break)
12281228
after(node.lastToken(viewMode: .sourceAccurate), tokens: .close)
12291229
before(node.inKeyword, tokens: .break(.same))
12301230
return .visitChildren
@@ -1521,7 +1521,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
15211521
}
15221522

15231523
override func visit(_ node: OperatorDeclSyntax) -> SyntaxVisitorContinueKind {
1524-
after(node.fixity, tokens: .break)
1524+
after(node.fixitySpecifier, tokens: .break)
15251525
after(node.operatorKeyword, tokens: .break)
15261526
return .visitChildren
15271527
}
@@ -1836,7 +1836,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
18361836

18371837
arrangeAttributeList(node.attributes)
18381838
after(node.importKeyword, tokens: .space)
1839-
after(node.importKind, tokens: .space)
1839+
after(node.importKindSpecifier, tokens: .space)
18401840

18411841
after(node.lastToken(viewMode: .sourceAccurate), tokens: .printerControl(kind: .enableBreaking))
18421842
return .visitChildren
@@ -1941,7 +1941,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
19411941
}
19421942

19431943
override func visit(_ node: FunctionSignatureSyntax) -> SyntaxVisitorContinueKind {
1944-
before(node.output?.firstToken(viewMode: .sourceAccurate), tokens: .break)
1944+
before(node.returnClause?.firstToken(viewMode: .sourceAccurate), tokens: .break)
19451945
return .visitChildren
19461946
}
19471947

@@ -2096,14 +2096,14 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
20962096
if node.bindings.count == 1 {
20972097
// If there is only a single binding, don't allow a break between the `let/var` keyword and
20982098
// the identifier; there are better places to break later on.
2099-
after(node.bindingKeyword, tokens: .space)
2099+
after(node.bindingSpecifier, tokens: .space)
21002100
} else {
21012101
// If there is more than one binding, we permit an open-break after `let/var` so that each of
21022102
// the comma-delimited items will potentially receive indentation. We also add a group around
21032103
// the individual bindings to bind them together better. (This is done here, not in
21042104
// `visit(_: PatternBindingSyntax)`, because we only want that behavior when there are
21052105
// multiple bindings.)
2106-
after(node.bindingKeyword, tokens: .break(.open))
2106+
after(node.bindingSpecifier, tokens: .break(.open))
21072107

21082108
for binding in node.bindings {
21092109
before(binding.firstToken(viewMode: .sourceAccurate), tokens: .open)
@@ -2301,7 +2301,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
23012301
}
23022302

23032303
override func visit(_ node: ValueBindingPatternSyntax) -> SyntaxVisitorContinueKind {
2304-
after(node.bindingKeyword, tokens: .break)
2304+
after(node.bindingSpecifier, tokens: .break)
23052305
return .visitChildren
23062306
}
23072307

@@ -2492,7 +2492,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
24922492
}
24932493

24942494
override func visit(_ node: OptionalBindingConditionSyntax) -> SyntaxVisitorContinueKind {
2495-
after(node.bindingKeyword, tokens: .break)
2495+
after(node.bindingSpecifier, tokens: .break)
24962496

24972497
if let typeAnnotation = node.typeAnnotation {
24982498
after(
@@ -2532,20 +2532,20 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
25322532
// This node encapsulates the entire list of arguments in a `@differentiable(...)` attribute.
25332533
var needsBreakBeforeWhereClause = false
25342534

2535-
if let diffParamsComma = node.diffParamsComma {
2536-
after(diffParamsComma, tokens: .break(.same))
2537-
} else if node.diffParams != nil {
2535+
if let parametersComma = node.parametersComma {
2536+
after(parametersComma, tokens: .break(.same))
2537+
} else if node.parameters != nil {
25382538
// If there were diff params but no comma following them, then we have "wrt: foo where ..."
25392539
// and we need a break before the where clause.
25402540
needsBreakBeforeWhereClause = true
25412541
}
25422542

2543-
if let whereClause = node.whereClause {
2543+
if let genericWhereClause = node.genericWhereClause {
25442544
if needsBreakBeforeWhereClause {
2545-
before(whereClause.firstToken(viewMode: .sourceAccurate), tokens: .break(.same))
2545+
before(genericWhereClause.firstToken(viewMode: .sourceAccurate), tokens: .break(.same))
25462546
}
2547-
before(whereClause.firstToken(viewMode: .sourceAccurate), tokens: .open)
2548-
after(whereClause.lastToken(viewMode: .sourceAccurate), tokens: .close)
2547+
before(genericWhereClause.firstToken(viewMode: .sourceAccurate), tokens: .open)
2548+
after(genericWhereClause.lastToken(viewMode: .sourceAccurate), tokens: .close)
25492549
}
25502550
return .visitChildren
25512551
}
@@ -2571,9 +2571,9 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
25712571
// The comma after originalDeclName is optional and is only present if there are diffParams.
25722572
after(node.comma ?? node.originalDeclName.lastToken(viewMode: .sourceAccurate), tokens: .close)
25732573

2574-
if let diffParams = node.diffParams {
2575-
before(diffParams.firstToken(viewMode: .sourceAccurate), tokens: .break(.same), .open)
2576-
after(diffParams.lastToken(viewMode: .sourceAccurate), tokens: .close)
2574+
if let parameters = node.parameters {
2575+
before(parameters.firstToken(viewMode: .sourceAccurate), tokens: .break(.same), .open)
2576+
after(parameters.lastToken(viewMode: .sourceAccurate), tokens: .close)
25772577
}
25782578

25792579
return .visitChildren
@@ -3069,7 +3069,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
30693069
// If we're at the end of the file, determine at which index to stop checking trivia pieces to
30703070
// prevent trailing newlines.
30713071
var cutoffIndex: Int? = nil
3072-
if token.tokenKind == TokenKind.eof {
3072+
if token.tokenKind == TokenKind.endOfFile {
30733073
cutoffIndex = 0
30743074
for (index, piece) in trivia.enumerated() {
30753075
switch piece {

Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,23 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
6767
}
6868

6969
public override func visit(_ node: ClosureSignatureSyntax) -> SyntaxVisitorContinueKind {
70-
if let input = node.input {
71-
if let closureParamList = input.as(ClosureParamListSyntax.self) {
70+
if let parameterClause = node.parameterClause {
71+
if let closureParamList = parameterClause.as(ClosureParamListSyntax.self) {
7272
for param in closureParamList {
7373
diagnoseLowerCamelCaseViolations(
7474
param.name, allowUnderscores: false, description: identifierDescription(for: node))
7575
}
76-
} else if let parameterClause = input.as(ClosureParameterClauseSyntax.self) {
77-
for param in parameterClause.parameterList {
76+
} else if let closureParameterClause = parameterClause.as(ClosureParameterClauseSyntax.self) {
77+
for param in closureParameterClause.parameterList {
7878
diagnoseLowerCamelCaseViolations(
7979
param.firstName, allowUnderscores: false, description: identifierDescription(for: node))
8080
if let secondName = param.secondName {
8181
diagnoseLowerCamelCaseViolations(
8282
secondName, allowUnderscores: false, description: identifierDescription(for: node))
8383
}
8484
}
85-
} else if let parameterClause = input.as(EnumCaseParameterClauseSyntax.self) {
86-
for param in parameterClause.parameterList {
85+
} else if let enumCaseParameterClause = parameterClause.as(EnumCaseParameterClauseSyntax.self) {
86+
for param in enumCaseParameterClause.parameterList {
8787
if let firstName = param.firstName {
8888
diagnoseLowerCamelCaseViolations(
8989
firstName, allowUnderscores: false, description: identifierDescription(for: node))
@@ -93,7 +93,7 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
9393
secondName, allowUnderscores: false, description: identifierDescription(for: node))
9494
}
9595
}
96-
} else if let parameterClause = input.as(ParameterClauseSyntax.self) {
96+
} else if let parameterClause = parameterClause.as(ParameterClauseSyntax.self) {
9797
for param in parameterClause.parameterList {
9898
diagnoseLowerCamelCaseViolations(
9999
param.firstName, allowUnderscores: false, description: identifierDescription(for: node))
@@ -121,7 +121,7 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
121121
diagnoseLowerCamelCaseViolations(
122122
node.identifier, allowUnderscores: allowUnderscores,
123123
description: identifierDescription(for: node))
124-
for param in node.signature.input.parameterList {
124+
for param in node.signature.parameterClause.parameterList {
125125
// These identifiers aren't described using `identifierDescription(for:)` because no single
126126
// node can disambiguate the argument label from the parameter name.
127127
diagnoseLowerCamelCaseViolations(
@@ -158,8 +158,8 @@ public final class AlwaysUseLowerCamelCase: SyntaxLintRule {
158158
// Identify test methods using the same heuristics as XCTest: name starts with "test", has
159159
// no arguments, and returns a void type.
160160
if functionDecl.identifier.text.starts(with: "test")
161-
&& functionDecl.signature.input.parameterList.isEmpty
162-
&& (functionDecl.signature.output.map(\.isVoid) ?? true)
161+
&& functionDecl.signature.parameterClause.parameterList.isEmpty
162+
&& (functionDecl.signature.returnClause.map(\.isVoid) ?? true)
163163
{
164164
set.insert(functionDecl)
165165
}
@@ -189,9 +189,9 @@ fileprivate func identifierDescription<NodeType: SyntaxProtocol>(for node: NodeT
189189
case .enumCaseElement: return "enum case"
190190
case .functionDecl: return "function"
191191
case .optionalBindingCondition(let binding):
192-
return binding.bindingKeyword.tokenKind == .keyword(.var) ? "variable" : "constant"
192+
return binding.bindingSpecifier.tokenKind == .keyword(.var) ? "variable" : "constant"
193193
case .variableDecl(let variableDecl):
194-
return variableDecl.bindingKeyword.tokenKind == .keyword(.var) ? "variable" : "constant"
194+
return variableDecl.bindingSpecifier.tokenKind == .keyword(.var) ? "variable" : "constant"
195195
default:
196196
return "identifier"
197197
}

0 commit comments

Comments
 (0)