Small library for support in place code generation. You can use this module independently from CodegenKit.
Write code as template with markers.
// Visitor.swift
class Visitor {
...
// @codegen(visitImpl)
func visitImpl(call: CallExpr) { ... }
func visitImpl(ident: IdentExpr) { ... }
// @end
}
Load code as template, edit, save.
let file = URL(fileURLWithPath: "Visitor.swift")
var template = try Template(file: file)
template["visitImpl"] = generateVisitImpl()
try template.description.write(to: file, atomically: true, encoding: .utf8)
CodeTemplate just split source file by lines. It doesn't see any syntax like comments, so it's target language agnostic.