@@ -262,7 +262,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
262262 unexpectedTokenCondition: { EffectSpecifier ( token: $0) != nil } ,
263263 correctTokens: [ effectSpecifiers? . asyncSpecifier, effectSpecifiers? . throwsClause? . throwsSpecifier] ,
264264 message: { EffectsSpecifierAfterArrow ( effectsSpecifiersAfterArrow: $0) } ,
265- moveFixIt: { MoveTokensInFrontOfFixIt ( movedTokens : $0, inFrontOf: . arrow) } ,
265+ moveFixIt: { MoveNodesInFrontOfFixIt ( movedNodes : $0, inFrontOf: . arrow) } ,
266266 removeRedundantFixIt: { RemoveRedundantFixIt ( removeTokens: $0) }
267267 )
268268 }
@@ -324,7 +324,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
324324 unexpectedTokenCondition: { AsyncEffectSpecifier ( token: $0) != nil } ,
325325 correctTokens: [ node. asyncSpecifier] ,
326326 message: { AsyncMustPrecedeThrows ( asyncKeywords: $0, throwsKeyword: throwsClause. throwsSpecifier) } ,
327- moveFixIt: { MoveTokensInFrontOfFixIt ( movedTokens : $0, inFrontOf: throwsClause. throwsSpecifier. tokenKind) } ,
327+ moveFixIt: { MoveNodesInFrontOfFixIt ( movedNodes : $0, inFrontOf: throwsClause. throwsSpecifier. tokenKind) } ,
328328 removeRedundantFixIt: { RemoveRedundantFixIt ( removeTokens: $0) }
329329 )
330330 }
@@ -2052,6 +2052,27 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
20522052 moveFixIt: { MoveTokensAfterFixIt ( movedTokens: $0, after: . equal) } ,
20532053 removeRedundantFixIt: { RemoveRedundantFixIt ( removeTokens: $0) }
20542054 )
2055+
2056+ if node. attributes. isMissingAllTokens,
2057+ let unexpected = node. bindings. compactMap ( { $0. unexpectedBeforePattern } ) . first,
2058+ unexpected. only? . is ( AttributeListSyntax . self) ?? false
2059+ {
2060+ let fixIt = FixIt (
2061+ message: MoveNodesInFrontOfFixIt ( movedNodes: [ unexpected] , inFrontOf: node. bindingSpecifier. tokenKind) ,
2062+ changes: [
2063+ . makeMissing( unexpected) ,
2064+ . makePresent( node. attributes, trailingTrivia: . space) ,
2065+ ]
2066+ )
2067+
2068+ addDiagnostic (
2069+ unexpected,
2070+ . misplacedAttributeInVarDecl,
2071+ fixIts: [ fixIt] ,
2072+ handledNodes: [ node. attributes. id, unexpected. id]
2073+ )
2074+ }
2075+
20552076 return . visitChildren
20562077 }
20572078
0 commit comments