@@ -274,19 +274,13 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
274
274
if shouldSkip ( node) {
275
275
return . skipChildren
276
276
}
277
- if let output = node. output,
278
- let missingThrowsKeyword = node. throwsOrRethrowsKeyword,
279
- missingThrowsKeyword. presence == . missing,
280
- let unexpectedBeforeReturnType = output. unexpectedBetweenArrowAndReturnType,
281
- let throwsInReturnPosition = unexpectedBeforeReturnType. tokens ( withKind: . throwsKeyword) . first {
282
- addDiagnostic ( throwsInReturnPosition, . throwsInReturnPosition, fixIts: [
283
- FixIt ( message: MoveTokensInFrontOfFixIt ( movedTokens: [ missingThrowsKeyword] , inFrontOf: . arrow) , changes: [
284
- . makeMissing( node: throwsInReturnPosition) ,
285
- . makePresent( node: missingThrowsKeyword) ,
286
- ] )
287
- ] , handledNodes: [ unexpectedBeforeReturnType. id, missingThrowsKeyword. id, throwsInReturnPosition. id] )
288
- return . visitChildren
289
- }
277
+ exchangeTokens (
278
+ unexpected: node. output? . unexpectedBetweenArrowAndReturnType,
279
+ unexpectedTokenCondition: { $0. tokenKind == . throwsKeyword } ,
280
+ correctTokens: [ node. throwsOrRethrowsKeyword] ,
281
+ message: { _ in StaticParserError . throwsInReturnPosition } ,
282
+ fixIt: { MoveTokensInFrontOfFixIt ( movedTokens: $0, inFrontOf: . arrow) }
283
+ )
290
284
return . visitChildren
291
285
}
292
286
0 commit comments