Skip to content

Commit e307190

Browse files
committed
format
1 parent 6d260bc commit e307190

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,20 +1520,21 @@ extension Parser {
15201520
) -> RawVariableDeclSyntax {
15211521
let (unexpectedBeforeIntroducer, introducer) = self.eat(handle)
15221522
let hasTryBeforeIntroducer = unexpectedBeforeIntroducer?.containsToken(where: { TokenSpec(.try) ~= $0 }) ?? false
1523-
1523+
15241524
var unexpectedBetweenBindingKeywordAndBindings: RawUnexpectedNodesSyntax?
15251525
var attrs = attrs
15261526
var elements = [RawPatternBindingSyntax]()
15271527
do {
15281528
var keepGoing: RawTokenSyntax? = nil
15291529
var loopProgress = LoopProgressCondition()
15301530
repeat {
1531-
1531+
15321532
if self.at(.atSign),
1533-
attrs.attributes?.isEmpty ?? true,
1534-
let recoveredAttributes = self.parseAttributeList() {
1533+
attrs.attributes?.isEmpty ?? true,
1534+
let recoveredAttributes = self.parseAttributeList()
1535+
{
15351536
unexpectedBetweenBindingKeywordAndBindings = RawUnexpectedNodesSyntax([recoveredAttributes], arena: self.arena)
1536-
1537+
15371538
class TokenMissingMaker: SyntaxRewriter {
15381539
override func visit(_ token: TokenSyntax) -> TokenSyntax {
15391540
return .init(token.tokenKind, presence: .missing)
@@ -1543,8 +1544,6 @@ extension Parser {
15431544
let missingAttributes = tokenMissingMaker.visit(Syntax(raw: recoveredAttributes.raw)).raw
15441545
attrs.attributes = RawAttributeListSyntax(missingAttributes)
15451546

1546-
1547-
15481547
}
15491548

15501549
var (pattern, typeAnnotation) = self.parseTypedPattern()

Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,24 +1170,29 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
11701170
moveFixIt: { MoveTokensAfterFixIt(movedTokens: $0, after: .equal) },
11711171
removeRedundantFixIt: { RemoveRedundantFixIt(removeTokens: $0) }
11721172
)
1173-
1173+
11741174
if let attributes = node.attributes,
1175-
attributes.isMissingAllTokens,
1176-
let unexpected = node.unexpectedBetweenBindingKeywordAndBindings {
1177-
1178-
let fixit = FixIt(message: MoveNodesInFrontOfFixIt(movedNodes: [unexpected], inFrontOf: node.bindingKeyword.tokenKind),
1179-
changes: [
1180-
.makeMissing(unexpected),
1181-
.makePresent(attributes, trailingTrivia: .space)
1182-
])
1183-
1184-
addDiagnostic(unexpected,
1185-
.misplacedAttributeInVarDecl,
1186-
fixIts: [fixit],
1187-
handledNodes: [attributes.id, unexpected.id])
1188-
1189-
}
1190-
1175+
attributes.isMissingAllTokens,
1176+
let unexpected = node.unexpectedBetweenBindingKeywordAndBindings
1177+
{
1178+
1179+
let fixit = FixIt(
1180+
message: MoveNodesInFrontOfFixIt(movedNodes: [unexpected], inFrontOf: node.bindingKeyword.tokenKind),
1181+
changes: [
1182+
.makeMissing(unexpected),
1183+
.makePresent(attributes, trailingTrivia: .space),
1184+
]
1185+
)
1186+
1187+
addDiagnostic(
1188+
unexpected,
1189+
.misplacedAttributeInVarDecl,
1190+
fixIts: [fixit],
1191+
handledNodes: [attributes.id, unexpected.id]
1192+
)
1193+
1194+
}
1195+
11911196
return .visitChildren
11921197
}
11931198

Tests/SwiftParserTest/AttributeTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ final class AttributeTests: XCTestCase {
570570
"""
571571
)
572572
}
573-
573+
574574
func testMisplacedAttributeInVariableDecl() {
575575
AssertParse(
576576
"""
@@ -579,7 +579,7 @@ final class AttributeTests: XCTestCase {
579579
}
580580
""",
581581
diagnostics: [
582-
DiagnosticSpec(message: "misplaced attribute in variable declaration", fixIts: ["move attributes in front of 'var'"]),
582+
DiagnosticSpec(message: "misplaced attribute in variable declaration", fixIts: ["move attributes in front of 'var'"])
583583
],
584584
fixedSource:
585585
"""

0 commit comments

Comments
 (0)