Skip to content

Commit

Permalink
Merge pull request #485 from gottesmm/pr-75fc86c01aedaf6fda5f5fdbefc4…
Browse files Browse the repository at this point in the history
…787f08f64eb9

[reference-bindings] Change letOrVarKeyword -> bindingKeyword.
  • Loading branch information
gottesmm authored Feb 23, 2023
2 parents 3cd655f + 4ae7690 commit f2b3e6c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftFormatRules/AlwaysUseLowerCamelCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ fileprivate func identifierDescription<NodeType: SyntaxProtocol>(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"
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftFormatRules/UseShorthandTypeNames.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftFormatRules/UseSynthesizedInitializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit f2b3e6c

Please sign in to comment.