We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
joined(separator:)
collapse
1 parent e89d138 commit 8f477f3Copy full SHA for 8f477f3
Sources/SwiftSyntaxMacroExpansion/MacroExpansion.swift
@@ -527,6 +527,16 @@ public func collapse<Node: SyntaxProtocol>(
527
default:
528
break
529
}
530
-
531
- return expansions.joined(separator: separator)
+
+ // Join the expansions ensuring `separator` between them.
532
+ var collapsed = ""
533
+ for expansion in expansions {
534
+ if (collapsed.isEmpty || expansion.hasPrefix(separator)) {
535
+ collapsed.append(expansion)
536
+ } else {
537
+ collapsed.append(separator + expansion)
538
+ }
539
540
541
+ return collapsed
542
0 commit comments