Skip to content

Commit 00c1498

Browse files
authored
Merge pull request #944 from ahoppen/ahoppen/review-comments-3
Address review comments from merged PRs
2 parents ca1f96f + 108ef25 commit 00c1498

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

Sources/SwiftParser/Diagnostics/MissingNodesError.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ func nodesDescriptionAndCommonParent<SyntaxType: SyntaxProtocol>(_ nodes: [Synta
120120
return (nil, "syntax")
121121
case 1:
122122
return (nil, "\(partDescriptions.first!)")
123+
case 2:
124+
return (nil, "\(partDescriptions.first!) and \(partDescriptions.last!)")
123125
default:
124-
return (nil, "\(partDescriptions[0..<partDescriptions.count - 1].joined(separator: ", ")) and \(partDescriptions.last!)")
126+
return (nil, "\(partDescriptions[0..<partDescriptions.count - 1].joined(separator: ", ")), and \(partDescriptions.last!)")
125127
}
126128
}
127129

Sources/SwiftParser/Diagnostics/ParserDiagnosticMessages.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public enum StaticParserError: String, DiagnosticMessage {
7777
case expectedExpressionAfterTry = "expected expression after 'try'"
7878
case invalidFlagAfterPrecedenceGroupAssignment = "expected 'true' or 'false' after 'assignment'"
7979
case missingColonInTernaryExprDiagnostic = "expected ':' after '? ...' in ternary expression"
80-
case operatorShouldBeDeclaredWithoutBody = "operator should no longer be declared with body"
80+
case operatorShouldBeDeclaredWithoutBody = "operator should not be declared with body"
8181
case standaloneSemicolonStatement = "standalone ';' statements are not allowed"
8282
case subscriptsCannotHaveNames = "subscripts cannot have a name"
8383
case throwsInReturnPosition = "'throws' may only occur before '->'"

Tests/SwiftParserTest/Statements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class StatementTests: XCTestCase {
4545
}
4646
""",
4747
diagnostics: [
48-
DiagnosticSpec(message: "expected expression, '=' and expression in pattern matching"),
48+
DiagnosticSpec(message: "expected expression, '=', and expression in pattern matching"),
4949
DiagnosticSpec(message: "unexpected code '* ! = x' in 'if' statement"),
5050
]
5151
)

Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class DiagnoseDynamicReplacementTests: XCTestCase {
2121
""",
2222
diagnostics: [
2323
// TODO: Old parser expected error on line 1: expected '(' in '_dynamicReplacement' attribute
24-
DiagnosticSpec(message: "expected '(', attribute argument and ')' in attribute"),
24+
DiagnosticSpec(message: "expected '(', attribute argument, and ')' in attribute"),
2525
]
2626
)
2727
}

Tests/SwiftParserTest/translated/OperatorDeclTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final class OperatorDeclTests: XCTestCase {
99
prefix operator +++ 1️⃣{}
1010
""",
1111
diagnostics: [
12-
DiagnosticSpec(message: "operator should no longer be declared with body", fixIts: ["remove operator body"])
12+
DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"])
1313
], fixedSource: "prefix operator +++"
1414
)
1515
}
@@ -20,7 +20,7 @@ final class OperatorDeclTests: XCTestCase {
2020
postfix operator +++ 1️⃣{}
2121
""",
2222
diagnostics: [
23-
DiagnosticSpec(message: "operator should no longer be declared with body")
23+
DiagnosticSpec(message: "operator should not be declared with body")
2424
]
2525
)
2626
}
@@ -31,7 +31,7 @@ final class OperatorDeclTests: XCTestCase {
3131
infix operator +++ 1️⃣{}
3232
""",
3333
diagnostics: [
34-
DiagnosticSpec(message: "operator should no longer be declared with body")
34+
DiagnosticSpec(message: "operator should not be declared with body")
3535
]
3636
)
3737
}
@@ -44,7 +44,7 @@ final class OperatorDeclTests: XCTestCase {
4444
}
4545
""",
4646
diagnostics: [
47-
DiagnosticSpec(message: "operator should no longer be declared with body", fixIts: ["remove operator body"])
47+
DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"])
4848
], fixedSource: """
4949
infix operator +++*
5050
"""
@@ -57,7 +57,7 @@ final class OperatorDeclTests: XCTestCase {
5757
infix operator +++*+ : A 1️⃣{ }
5858
""",
5959
diagnostics: [
60-
DiagnosticSpec(message: "operator should no longer be declared with body")
60+
DiagnosticSpec(message: "operator should not be declared with body")
6161
]
6262
)
6363
}
@@ -69,7 +69,7 @@ final class OperatorDeclTests: XCTestCase {
6969
prefix operator +++** : A 1️⃣{ }
7070
""",
7171
diagnostics: [
72-
DiagnosticSpec(message: "operator should no longer be declared with body")
72+
DiagnosticSpec(message: "operator should not be declared with body")
7373
]
7474
)
7575
}
@@ -88,7 +88,7 @@ final class OperatorDeclTests: XCTestCase {
8888
postfix operator ++*+* : A 1️⃣{ }
8989
""",
9090
diagnostics: [
91-
DiagnosticSpec(message: "operator should no longer be declared with body")
91+
DiagnosticSpec(message: "operator should not be declared with body")
9292
]
9393
)
9494
}
@@ -119,7 +119,7 @@ final class OperatorDeclTests: XCTestCase {
119119
""",
120120
diagnostics: [
121121
// TODO: Old parser expected error on line 1: operator must be declared as 'prefix', 'postfix', or 'infix'
122-
DiagnosticSpec(message: "operator should no longer be declared with body")
122+
DiagnosticSpec(message: "operator should not be declared with body")
123123
]
124124
)
125125
}
@@ -131,7 +131,7 @@ final class OperatorDeclTests: XCTestCase {
131131
""",
132132
diagnostics: [
133133
// TODO: Old parser expected error on line 1: operator must be declared as 'prefix', 'postfix', or 'infix'
134-
DiagnosticSpec(message: "operator should no longer be declared with body")
134+
DiagnosticSpec(message: "operator should not be declared with body")
135135
]
136136
)
137137
}

Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class ToplevelLibraryTests: XCTestCase {
3131
for i1️⃣
3232
""",
3333
diagnostics: [
34-
DiagnosticSpec(message: "expected 'in', expression and body in 'for' statement"),
34+
DiagnosticSpec(message: "expected 'in', expression, and body in 'for' statement"),
3535
]
3636
)
3737
}

0 commit comments

Comments
 (0)