Skip to content

Commit c646df3

Browse files
committed
Remap "rethrows" keyword to identifier in "@rethrows"
1 parent 6ba87a8 commit c646df3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Sources/SwiftParser/RawTokenKindSubset.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ enum IdentifierOrRethrowsTokens: RawTokenKindSubset {
473473
case .rethrowsKeyword: return .rethrowsKeyword
474474
}
475475
}
476+
477+
var remappedKind: RawTokenKind? {
478+
switch self {
479+
case .rethrowsKeyword: return .identifier
480+
default: return nil
481+
}
482+
}
483+
476484
}
477485

478486
enum Operator: RawTokenKindSubset {

Tests/SwiftParserTest/Attributes.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ final class AttributeTests: XCTestCase {
7373
func testRethrowsAttribute() {
7474
AssertParse(
7575
"""
76-
@rethrows
76+
@#^NAME^#rethrows
7777
protocol P { }
78-
"""
78+
""",
79+
{ $0.parseDeclaration() },
80+
substructure: Syntax(TokenSyntax.identifier("rethrows")),
81+
substructureAfterMarker: "NAME"
7982
)
8083
}
8184

0 commit comments

Comments
 (0)