{
final Service service = Service.class.cast(visitable);
final ServiceContext serviceContext = contextGenerator.serviceFromThrift(service);
for (ThriftMethod method: service.getMethods()) {
final MethodContext methodContext = contextGenerator.methodFromThrift(method);
serviceContext.addMethod(methodContext);
for (final ThriftField field : method.getArguments()) {
methodContext.addParameter(contextGenerator.fieldFromThrift(field));
}
for (final ThriftField field : method.getThrowsFields()) {
methodContext.addException(contextGenerator.exceptionFromThrift(field));
}
if (config.containsTweak(SwiftGeneratorTweak.ADD_THRIFT_EXCEPTION)) {
methodContext.addException(THRIFT_EXCEPTION_CONTEXT);
}
}
render(serviceContext, "service");
}