2022-12-03 19:07:55 +01:00
|
|
|
<%
|
|
|
|
func methodDeclaration(_ method: SourceryRuntime.Method, newName: String) -> String {
|
|
|
|
var result = newName
|
|
|
|
if method.throws {
|
|
|
|
result = result + " throws"
|
|
|
|
} else if method.rethrows {
|
|
|
|
result = result + " rethrows"
|
|
|
|
}
|
|
|
|
if method.returnTypeName.isVoid {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
return result + " -> \(method.returnTypeName)"
|
|
|
|
}
|
|
|
|
-%>
|
2022-01-27 14:23:39 +01:00
|
|
|
<% for type in types.implementing["AutoGenerateProtocolDelegate"] {
|
|
|
|
guard let replaceOf = type.annotations["replaceOf"] as? String else { continue }
|
|
|
|
guard let replaceWith = type.annotations["replaceWith"] as? String else { continue }
|
|
|
|
guard let protocolToGenerate = type.annotations["protocolName"] as? String else { continue }
|
|
|
|
guard let aProtocol = types.protocols.first(where: { $0.name == protocolToGenerate }) else { continue } -%>
|
|
|
|
// sourcery:inline:<%= type.name %>.AutoGenerateProtocolDelegate
|
|
|
|
<% for method in aProtocol.methods { -%>
|
2022-12-03 19:07:55 +01:00
|
|
|
<%= methodDeclaration(method, newName: method.name.replacingOccurrences(of: replaceOf, with: replaceWith)) %>
|
2022-01-27 14:23:39 +01:00
|
|
|
<% } -%>
|
|
|
|
// sourcery:end
|
|
|
|
<% } %>
|