@@ -204,7 +204,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
204204 unexpectedTokenCondition: { EffectSpecifier ( token: $0) != nil } ,
205205 correctTokens: [ effectSpecifiers? . throwsSpecifier, effectSpecifiers? . asyncSpecifier] ,
206206 message: { EffectsSpecifierAfterArrow ( effectsSpecifiersAfterArrow: $0) } ,
207- moveFixIt: { MoveTokensInFrontOfFixIt ( movedTokens : $0, inFrontOf: . arrow) } ,
207+ moveFixIt: { MoveNodesInFrontOfFixIt ( movedNodes : $0, inFrontOf: . arrow) } ,
208208 removeRedundantFixIt: { RemoveRedundantFixIt ( removeTokens: $0) }
209209 )
210210 }
@@ -251,7 +251,7 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
251251 unexpectedTokenCondition: { AsyncEffectSpecifier ( token: $0) != nil } ,
252252 correctTokens: [ node. asyncSpecifier] ,
253253 message: { AsyncMustPrecedeThrows ( asyncKeywords: $0, throwsKeyword: throwsSpecifier) } ,
254- moveFixIt: { MoveTokensInFrontOfFixIt ( movedTokens : $0, inFrontOf: throwsSpecifier. tokenKind) } ,
254+ moveFixIt: { MoveNodesInFrontOfFixIt ( movedNodes : $0, inFrontOf: throwsSpecifier. tokenKind) } ,
255255 removeRedundantFixIt: { RemoveRedundantFixIt ( removeTokens: $0) }
256256 )
257257 }
@@ -1170,6 +1170,30 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
11701170 moveFixIt: { MoveTokensAfterFixIt ( movedTokens: $0, after: . equal) } ,
11711171 removeRedundantFixIt: { RemoveRedundantFixIt ( removeTokens: $0) }
11721172 )
1173+
1174+ if let attributes = node. attributes,
1175+ attributes. isMissingAllTokens,
1176+ let unexpected = node. unexpectedBetweenBindingKeywordAndBindings,
1177+ unexpected. only? . is ( AttributeListSyntax . self) ?? false
1178+ {
1179+
1180+ let fixit = FixIt (
1181+ message: MoveNodesInFrontOfFixIt ( movedNodes: [ unexpected] , inFrontOf: node. bindingKeyword. tokenKind) ,
1182+ changes: [
1183+ . makeMissing( unexpected) ,
1184+ . makePresent( attributes, trailingTrivia: . space) ,
1185+ ]
1186+ )
1187+
1188+ addDiagnostic (
1189+ unexpected,
1190+ . misplacedAttributeInVarDecl,
1191+ fixIts: [ fixit] ,
1192+ handledNodes: [ attributes. id, unexpected. id]
1193+ )
1194+
1195+ }
1196+
11731197 return . visitChildren
11741198 }
11751199
0 commit comments