From 4ae7690ef08e177eede2f8a6570ac5074da4feab Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Wed, 22 Feb 2023 16:14:05 -0800 Subject: [PATCH] [reference-bindings] Change letOrVarKeyword -> bindingKeyword. --- Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift | 8 ++++---- Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift | 4 ++-- Sources/SwiftFormatRules/UseShorthandTypeNames.swift | 2 +- Sources/SwiftFormatRules/UseSynthesizedInitializer.swift | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift index 28c4e9850..5fc50c76f 100644 --- a/Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift @@ -1909,14 +1909,14 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { if node.bindings.count == 1 { // If there is only a single binding, don't allow a break between the `let/var` keyword and // the identifier; there are better places to break later on. - after(node.letOrVarKeyword, tokens: .space) + after(node.bindingKeyword, tokens: .space) } else { // If there is more than one binding, we permit an open-break after `let/var` so that each of // the comma-delimited items will potentially receive indentation. We also add a group around // the individual bindings to bind them together better. (This is done here, not in // `visit(_: PatternBindingSyntax)`, because we only want that behavior when there are // multiple bindings.) - after(node.letOrVarKeyword, tokens: .break(.open)) + after(node.bindingKeyword, tokens: .break(.open)) for binding in node.bindings { before(binding.firstToken, tokens: .open) @@ -2106,7 +2106,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { } override func visit(_ node: ValueBindingPatternSyntax) -> SyntaxVisitorContinueKind { - after(node.letOrVarKeyword, tokens: .break) + after(node.bindingKeyword, tokens: .break) return .visitChildren } @@ -2290,7 +2290,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { } override func visit(_ node: OptionalBindingConditionSyntax) -> SyntaxVisitorContinueKind { - after(node.letOrVarKeyword, tokens: .break) + after(node.bindingKeyword, tokens: .break) if let typeAnnotation = node.typeAnnotation { after( diff --git a/Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift b/Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift index 3bfbdbf17..b65f38bdc 100644 --- a/Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift +++ b/Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift @@ -173,9 +173,9 @@ fileprivate func identifierDescription(for node: NodeT case .enumCaseElement: return "enum case" case .functionDecl: return "function" case .optionalBindingCondition(let binding): - return binding.letOrVarKeyword.tokenKind == .keyword(.var) ? "variable" : "constant" + return binding.bindingKeyword.tokenKind == .keyword(.var) ? "variable" : "constant" case .variableDecl(let variableDecl): - return variableDecl.letOrVarKeyword.tokenKind == .keyword(.var) ? "variable" : "constant" + return variableDecl.bindingKeyword.tokenKind == .keyword(.var) ? "variable" : "constant" default: return "identifier" } diff --git a/Sources/SwiftFormatRules/UseShorthandTypeNames.swift b/Sources/SwiftFormatRules/UseShorthandTypeNames.swift index 30d10e949..0f38e4be6 100644 --- a/Sources/SwiftFormatRules/UseShorthandTypeNames.swift +++ b/Sources/SwiftFormatRules/UseShorthandTypeNames.swift @@ -542,7 +542,7 @@ public final class UseShorthandTypeNames: SyntaxFormatRule { isStoredProperty(patternBinding), patternBinding.initializer == nil, let variableDecl = nearestAncestor(of: patternBinding, type: VariableDeclSyntax.self), - variableDecl.letOrVarKeyword.tokenKind == .keyword(.var) + variableDecl.bindingKeyword.tokenKind == .keyword(.var) { return true } diff --git a/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift b/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift index 9915258ab..4233aafd6 100644 --- a/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift +++ b/Sources/SwiftFormatRules/UseSynthesizedInitializer.swift @@ -116,7 +116,7 @@ public final class UseSynthesizedInitializer: SyntaxLintRule { // Ensure that parameters that correspond to properties declared using 'var' have a default // argument that is identical to the property's default value. Otherwise, a default argument // doesn't match the memberwise initializer. - let isVarDecl = property.letOrVarKeyword.tokenKind == .keyword(.var) + let isVarDecl = property.bindingKeyword.tokenKind == .keyword(.var) if isVarDecl, let initializer = property.firstInitializer { guard let defaultArg = parameter.defaultArgument else { return false } guard initializer.value.description == defaultArg.value.description else { return false }