in Sources/MockoloFramework/Templates/IfMacroTemplate.swift [19:59]
func applyMacroTemplate(
context: RenderContext,
arguments: GenerationArguments
) -> String {
var lines = [String]()
for clause in clauses {
// Render the directive line
let directive: String
switch clause.type {
case .if(let condition):
directive = "\(1.tab)#if \(condition)"
case .elseif(let condition):
directive = "\(1.tab)#elseif \(condition)"
case .else:
directive = "\(1.tab)#else"
}
lines.append(directive)
// Render entities in this clause
let rendered = clause.entities
.compactMap { model in
model.1.render(
context: .init(
overloadingResolvedName: model.0,
enclosingType: context.enclosingType,
annotatedTypeKind: context.annotatedTypeKind
),
arguments: arguments
)
}
.joined(separator: "\n")
if !rendered.isEmpty {
lines.append(rendered)
}
}
lines.append("\(1.tab)#endif")
return lines.joined(separator: "\n")
}