@@ -2957,19 +2957,24 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
2957
2957
if let attributes = attributes {
2958
2958
let behavior : NewlineBehavior = separateByLineBreaks ? . hard : . elective
2959
2959
before ( attributes. firstToken ( viewMode: . sourceAccurate) , tokens: . open)
2960
- for element in attributes. dropLast ( ) {
2961
- if let ifConfig = element. as ( IfConfigDeclSyntax . self) {
2960
+ if attributes. dropLast ( ) . isEmpty,
2961
+ let ifConfig = attributes. first? . as ( IfConfigDeclSyntax . self) {
2962
+ for clause in ifConfig. clauses {
2963
+ if let nestedAttributes = AttributeListSyntax ( clause. elements) {
2964
+ arrangeAttributeList ( nestedAttributes, suppressFinalBreak: true , separateByLineBreaks: separateByLineBreaks)
2965
+ }
2966
+ }
2967
+ } else {
2968
+ for element in attributes. dropLast ( ) {
2969
+ if let ifConfig = element. as ( IfConfigDeclSyntax . self) {
2962
2970
for clause in ifConfig. clauses {
2963
- if let nestedAttributes = AttributeListSyntax ( clause. elements) {
2964
- arrangeAttributeList (
2965
- nestedAttributes,
2966
- suppressFinalBreak: true ,
2967
- separateByLineBreaks: separateByLineBreaks
2968
- )
2969
- }
2971
+ if let nestedAttributes = AttributeListSyntax ( clause. elements) {
2972
+ arrangeAttributeList ( nestedAttributes, suppressFinalBreak: true , separateByLineBreaks: separateByLineBreaks)
2973
+ }
2970
2974
}
2971
- } else {
2975
+ } else {
2972
2976
after ( element. lastToken ( viewMode: . sourceAccurate) , tokens: . break( . same, newlines: behavior) )
2977
+ }
2973
2978
}
2974
2979
}
2975
2980
var afterAttributeTokens = [ Token . close]
0 commit comments