Skip to content

Commit 28dfb1b

Browse files
Applied formatting
1 parent 4e08917 commit 28dfb1b

File tree

6 files changed

+89
-87
lines changed

6 files changed

+89
-87
lines changed

CodeGeneration/Sources/SyntaxSupport/CommonNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public let COMMON_NODES: [Node] = [
124124
),
125125
]
126126
),
127-
127+
128128
// deinit-effect-specifiers -> async?
129129
Node(
130130
kind: .deinitEffectSpecifiers,

Sources/SwiftParser/Declarations.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,14 +1120,14 @@ extension Parser {
11201120
_ handle: RecoveryConsumptionHandle
11211121
) -> RawDeinitializerDeclSyntax {
11221122
let (unexpectedBeforeDeinitKeyword, deinitKeyword) = self.eat(handle)
1123-
1123+
11241124
var unexpectedNameAndSignature: [RawSyntax?] = []
11251125
var unexpectedAfterAsync: [RawSyntax?] = []
11261126

11271127
// async is a contextual keyword
11281128
// must be parsed before attempting to parse identifier
11291129
var effectSpecifiers = parseDeinitEffectSpecifiers()
1130-
1130+
11311131
if effectSpecifiers == nil {
11321132
if let identifier = self.consume(if: TokenSpec(.identifier, allowAtStartOfLine: false)).map(RawSyntax.init) {
11331133
unexpectedNameAndSignature.append(identifier)
@@ -1151,7 +1151,7 @@ extension Parser {
11511151
}
11521152
unexpectedAfterAsync.append(contentsOf: sig.unexpectedBetweenEffectSpecifiersAndOutput?.elements ?? [])
11531153
if let output = sig.output {
1154-
unexpectedAfterAsync.append(RawSyntax(output))
1154+
unexpectedAfterAsync.append(RawSyntax(output))
11551155
}
11561156
}
11571157
let items = self.parseOptionalCodeBlock()

Sources/SwiftParser/Specifiers.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ extension RawAccessorEffectSpecifiersSyntax: RawEffectSpecifiersTrait {
418418
}
419419

420420
extension RawDeinitEffectSpecifiersSyntax {
421-
enum MisspelledAsyncSpecifiers: TokenSpecSet {
421+
enum MisspelledAsyncTokenKinds: TokenSpecSet {
422422
case await
423423
case reasync
424424

@@ -437,33 +437,33 @@ extension RawDeinitEffectSpecifiersSyntax {
437437
}
438438
}
439439
}
440-
440+
441441
enum MisspelledThrowsTokenKinds: TokenSpecSet {
442-
case `try`
443-
case `throw`
444442
case `rethrows`
443+
case `throw`
445444
case `throws`
445+
case `try`
446446

447447
init?(lexeme: Lexer.Lexeme) {
448448
switch PrepareForKeywordMatch(lexeme) {
449-
case TokenSpec(.try, allowAtStartOfLine: false): self = .try
450-
case TokenSpec(.throw, allowAtStartOfLine: false): self = .throw
451449
case TokenSpec(.rethrows): self = .rethrows
450+
case TokenSpec(.throw, allowAtStartOfLine: false): self = .throw
452451
case TokenSpec(.throws): self = .throws
452+
case TokenSpec(.try, allowAtStartOfLine: false): self = .try
453453
default: return nil
454454
}
455455
}
456456

457457
var spec: TokenSpec {
458458
switch self {
459-
case .try: return TokenSpec(.try, allowAtStartOfLine: false)
460-
case .throw: return TokenSpec(.throw, allowAtStartOfLine: false)
461459
case .rethrows: return .keyword(.rethrows)
460+
case .throw: return TokenSpec(.throw, allowAtStartOfLine: false)
462461
case .throws: return .keyword(.throws)
462+
case .try: return TokenSpec(.try, allowAtStartOfLine: false)
463463
}
464464
}
465465
}
466-
466+
467467
public init(
468468
_ unexpectedBeforeAsyncSpecifier: RawUnexpectedNodesSyntax? = nil,
469469
asyncSpecifier: RawTokenSyntax?,
@@ -477,7 +477,7 @@ extension RawDeinitEffectSpecifiersSyntax {
477477
var unexpectedBeforeAsync: [RawSyntax?] = []
478478
var asyncKeyword: RawTokenSyntax? = asyncSpecifier?.raw.as(RawTokenSyntax.self)
479479
var unexpectedAfterAsync: [RawSyntax?] = []
480-
480+
481481
unexpectedBeforeAsync.append(contentsOf: unexpectedBeforeAsyncSpecifier?.elements ?? [])
482482
unexpectedBeforeAsync.append(contentsOf: unexpectedBetweenAsyncSpecifierAndThrowsSpecifier?.elements ?? [])
483483
if let throwsKeyword = throwsSpecifier, !throwsKeyword.isMissing {
@@ -520,7 +520,7 @@ extension RawDeinitEffectSpecifiersSyntax {
520520
unexpectedAfterAsync = unexpectedBetweenAsyncSpecifierAndThrowsSpecifier
521521
}
522522
}
523-
523+
524524
self.init(
525525
unexpectedBeforeAsyncSpecifier,
526526
asyncSpecifier: asyncSpecifier,
@@ -633,19 +633,19 @@ extension Parser {
633633
mutating func parseAccessorEffectSpecifiers() -> RawAccessorEffectSpecifiersSyntax? {
634634
return parseEffectSpecifiers(RawAccessorEffectSpecifiersSyntax.self)
635635
}
636-
636+
637637
mutating func parseDeinitEffectSpecifiers() -> RawDeinitEffectSpecifiersSyntax? {
638638
// Note that parseEffectSpecifiers() consumes deinit name as unexpected token
639639
// But we want it to be handled on the higher level.
640640
// So we parseEffectSpecifiers() is not reused here.
641-
641+
642642
var unexpectedBeforeAsync: [RawSyntax?] = []
643643
var asyncKeyword: RawTokenSyntax?
644644
var unexpectedAfterAsync: [RawSyntax?] = []
645-
645+
646646
while true {
647647
var progressed: Bool = false
648-
648+
649649
if let realAsync = self.consume(if: .keyword(.async)) {
650650
progressed = true
651651
if asyncKeyword?.isMissing ?? true {
@@ -654,8 +654,8 @@ extension Parser {
654654
unexpectedAfterAsync.append(realAsync.raw)
655655
}
656656
}
657-
658-
while let badAsync = self.consume(ifAnyIn: RawDeinitEffectSpecifiersSyntax.MisspelledAsyncSpecifiers.self) {
657+
658+
while let badAsync = self.consume(ifAnyIn: RawDeinitEffectSpecifiersSyntax.MisspelledAsyncTokenKinds.self) {
659659
progressed = true
660660
if asyncKeyword?.isMissing ?? true {
661661
unexpectedBeforeAsync.append(badAsync.raw)
@@ -668,7 +668,7 @@ extension Parser {
668668
asyncKeyword = missingToken(.keyword(.async))
669669
}
670670
}
671-
671+
672672
while let badThrows = self.consume(ifAnyIn: RawDeinitEffectSpecifiersSyntax.MisspelledThrowsTokenKinds.self) {
673673
progressed = true
674674
if asyncKeyword?.isMissing ?? true {
@@ -677,10 +677,10 @@ extension Parser {
677677
unexpectedAfterAsync.append(badThrows.raw)
678678
}
679679
}
680-
680+
681681
if !progressed { break }
682682
}
683-
683+
684684
if unexpectedBeforeAsync.isEmpty && asyncKeyword == nil && unexpectedAfterAsync.isEmpty {
685685
return nil
686686
}

Sources/SwiftParserDiagnostics/ParseDiagnosticsGenerator.swift

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,10 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
797797
handledNodes: [params.id]
798798
)
799799
}
800-
800+
801801
return .visitChildren
802802
}
803-
803+
804804
public override func visit(_ node: DeinitEffectSpecifiersSyntax) -> SyntaxVisitorContinueKind {
805805
let throwsTokens: [TokenKind] = [
806806
.keyword(.throws),
@@ -814,19 +814,20 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
814814
if throwsTokens.contains(token.tokenKind) { return token }
815815
return nil
816816
}
817-
818-
let unexpectedThrows = (node.unexpectedBeforeAsyncSpecifier?.compactMap(asThrowingToken) ?? []) + (node.unexpectedAfterAsyncSpecifier?.compactMap(asThrowingToken) ?? [])
817+
818+
let unexpectedThrows =
819+
(node.unexpectedBeforeAsyncSpecifier?.compactMap(asThrowingToken) ?? []) + (node.unexpectedAfterAsyncSpecifier?.compactMap(asThrowingToken) ?? [])
819820
if let throwsKeyword = unexpectedThrows.first {
820-
addDiagnostic(
821-
throwsKeyword,
822-
.deinitCannotThrow,
823-
fixIts: [
824-
FixIt(message: RemoveNodesFixIt(unexpectedThrows), changes: .makeMissing(unexpectedThrows))
825-
],
826-
handledNodes: unexpectedThrows.map(\.id)
827-
)
821+
addDiagnostic(
822+
throwsKeyword,
823+
.deinitCannotThrow,
824+
fixIts: [
825+
FixIt(message: RemoveNodesFixIt(unexpectedThrows), changes: .makeMissing(unexpectedThrows))
826+
],
827+
handledNodes: unexpectedThrows.map(\.id)
828+
)
828829
}
829-
830+
830831
let isOfSameKind = { AsyncEffectSpecifier(token: $0) != nil }
831832
if let asyncSpecifier = node.asyncSpecifier {
832833
let unexpectedNodes = [node.unexpectedBeforeAsyncSpecifier, node.unexpectedAfterAsyncSpecifier]
@@ -840,7 +841,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
840841
removeRedundantFixIt: { RemoveRedundantFixIt(removeTokens: $0) }
841842
)
842843
}
843-
844+
844845
if asyncSpecifier.isPresent {
845846
for case .some(let unexpected) in unexpectedNodes {
846847
for duplicateSpecifier in unexpected.presentTokens(satisfying: isOfSameKind) {
@@ -855,7 +856,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
855856
}
856857
}
857858
}
858-
859+
859860
return .visitChildren
860861
}
861862

Tests/SwiftParserTest/translated/AsyncTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ final class AsyncTests: XCTestCase {
149149
}
150150
""",
151151
diagnostics: [
152-
DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code 'async' in subscript"),
152+
DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code 'async' in subscript")
153153
]
154154
)
155155
}

0 commit comments

Comments
 (0)