File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Sources/SwiftSyntaxMacroExpansion Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -132,21 +132,21 @@ private func expandFreestandingExpr(
132
132
/// Adds the appropriate indentation on expanded code even if it's multi line.
133
133
/// Makes sure original macro expression's trivia is maintained by adding it to expanded code.
134
134
private func adjustIndentationOfFreestandingMacro( expandedCode: String , node: some FreestandingMacroExpansionSyntax ) -> String {
135
-
135
+
136
136
if expandedCode. isEmpty {
137
137
return expandedCode. wrappingInTrivia ( from: node)
138
138
}
139
-
139
+
140
140
let indentationOfFirstLine = node. indentationOfFirstLine
141
141
let indentLength = indentationOfFirstLine. sourceLength. utf8Length
142
-
142
+
143
143
// we are doing 3 step adjustment here
144
144
// step 1: add indentation to each line of expanded code
145
145
// step 2: remove indentation from first line of expaned code
146
146
// step 3: wrap the expanded code into macro expression's trivia. This trivia will contain appropriate existing
147
147
// indentation. Note that if macro expression occurs in middle of the line then there will be no indentation or extra space.
148
148
// Hence we are doing step 2
149
-
149
+
150
150
var indentedSource = expandedCode. indented ( by: indentationOfFirstLine)
151
151
indentedSource. removeFirst ( indentLength)
152
152
indentedSource = indentedSource. wrappingInTrivia ( from: node)
You can’t perform that action at this time.
0 commit comments