Browse Source

A few more formatting improvements as suggested by `swiftformat`.

Daniel Alm 7 years ago
parent
commit
ec953c566f

+ 14 - 15
Examples/Echo/Generated/echo.grpc.swift

@@ -26,7 +26,7 @@ import Dispatch
 import gRPC
 import SwiftProtobuf
 
-internal protocol Echo_EchoGetCall: ClientCallUnary { }
+internal protocol Echo_EchoGetCall: ClientCallUnary {}
 
 fileprivate final class Echo_EchoGetCallBase: ClientCallUnaryBase<Echo_EchoRequest, Echo_EchoResponse>, Echo_EchoGetCall {
   override class var method: String { return "/echo.Echo/Get" }
@@ -50,7 +50,7 @@ class Echo_EchoExpandCallTestStub: ClientCallServerStreamingTestStub<Echo_EchoRe
 internal protocol Echo_EchoCollectCall: ClientCallClientStreaming {
   /// Call this to send each message in the request stream. Nonblocking.
   func send(_ message: Echo_EchoRequest, errorHandler: @escaping (Error) -> Void) throws
-  
+
   /// Call this to close the connection and wait for a response. Blocking.
   func closeAndReceive() throws -> Echo_EchoResponse
   /// Call this to close the connection and wait for a response. Nonblocking.
@@ -72,10 +72,10 @@ internal protocol Echo_EchoUpdateCall: ClientCallBidirectionalStreaming {
   func receive() throws -> Echo_EchoResponse
   /// Call this to wait for a result. Nonblocking.
   func receive(completion: @escaping (Echo_EchoResponse?, ClientError?) -> Void) throws
-  
+
   /// Call this to send each message in the request stream.
   func send(_ message: Echo_EchoRequest, errorHandler: @escaping (Error) -> Void) throws
-  
+
   /// Call this to close the sending connection. Blocking.
   func closeSend() throws
   /// Call this to close the sending connection. Nonblocking.
@@ -122,8 +122,7 @@ internal final class Echo_EchoServiceClient: ServiceClientBase, Echo_EchoService
       .run(request: request, metadata: metadata)
   }
   /// Asynchronous. Unary.
-  internal func get(_ request: Echo_EchoRequest,
-                  completion: @escaping (Echo_EchoResponse?, CallResult) -> Void) throws -> Echo_EchoGetCall {
+  internal func get(_ request: Echo_EchoRequest, completion: @escaping (Echo_EchoResponse?, CallResult) -> Void) throws -> Echo_EchoGetCall {
     return try Echo_EchoGetCallBase(channel)
       .start(request: request, metadata: metadata, completion: completion)
   }
@@ -133,7 +132,7 @@ internal final class Echo_EchoServiceClient: ServiceClientBase, Echo_EchoService
   /// Use methods on the returned object to get streamed responses.
   internal func expand(_ request: Echo_EchoRequest, completion: ((CallResult) -> Void)?) throws -> Echo_EchoExpandCall {
     return try Echo_EchoExpandCallBase(channel)
-      .start(request:request, metadata:metadata, completion:completion)
+      .start(request: request, metadata: metadata, completion: completion)
   }
 
   /// Asynchronous. Client-streaming.
@@ -141,7 +140,7 @@ internal final class Echo_EchoServiceClient: ServiceClientBase, Echo_EchoService
   /// to close the connection and wait for a final response.
   internal func collect(completion: ((CallResult) -> Void)?) throws -> Echo_EchoCollectCall {
     return try Echo_EchoCollectCallBase(channel)
-       .start(metadata: metadata, completion: completion)
+      .start(metadata: metadata, completion: completion)
   }
 
   /// Asynchronous. Bidirectional-streaming.
@@ -169,7 +168,7 @@ class Echo_EchoServiceTestStub: ServiceClientTestStubBase, Echo_EchoService {
   var expandRequests: [Echo_EchoRequest] = []
   var expandCalls: [Echo_EchoExpandCall] = []
   func expand(_ request: Echo_EchoRequest, completion: ((CallResult) -> Void)?) throws -> Echo_EchoExpandCall {
-      expandRequests.append(request)
+    expandRequests.append(request)
     defer { expandCalls.removeFirst() }
     return expandCalls.first!
   }
@@ -191,13 +190,13 @@ class Echo_EchoServiceTestStub: ServiceClientTestStubBase, Echo_EchoService {
 
 /// To build a server, implement a class that conforms to this protocol.
 internal protocol Echo_EchoProvider {
-  func get(request : Echo_EchoRequest, session : Echo_EchoGetSession) throws -> Echo_EchoResponse
-  func expand(request : Echo_EchoRequest, session : Echo_EchoExpandSession) throws
-  func collect(session : Echo_EchoCollectSession) throws
-  func update(session : Echo_EchoUpdateSession) throws
+  func get(request: Echo_EchoRequest, session: Echo_EchoGetSession) throws -> Echo_EchoResponse
+  func expand(request: Echo_EchoRequest, session: Echo_EchoExpandSession) throws
+  func collect(session: Echo_EchoCollectSession) throws
+  func update(session: Echo_EchoUpdateSession) throws
 }
 
-internal protocol Echo_EchoGetSession: ServerSessionUnary { }
+internal protocol Echo_EchoGetSession: ServerSessionUnary {}
 
 fileprivate final class Echo_EchoGetSessionBase: ServerSessionUnaryBase<Echo_EchoRequest, Echo_EchoResponse>, Echo_EchoGetSession {}
 
@@ -230,7 +229,7 @@ internal protocol Echo_EchoUpdateSession: ServerSessionBidirectionalStreaming {
 
   /// Send a message. Nonblocking.
   func send(_ response: Echo_EchoResponse, completion: ((Bool) -> Void)?) throws
-  
+
   /// Close a connection. Blocks until the connection is closed.
   func close() throws
 }

+ 2 - 2
Plugin/Templates/client-call-bidistreaming.swift

@@ -3,10 +3,10 @@
   func receive() throws -> {{ method|output }}
   /// Call this to wait for a result. Nonblocking.
   func receive(completion: @escaping ({{ method|output }}?, ClientError?) -> Void) throws
-  
+
   /// Call this to send each message in the request stream.
   func send(_ message: {{ method|input }}, errorHandler: @escaping (Error) -> Void) throws
-  
+
   /// Call this to close the sending connection. Blocking.
   func closeSend() throws
   /// Call this to close the sending connection. Nonblocking.

+ 1 - 1
Plugin/Templates/client-call-clientstreaming.swift

@@ -1,7 +1,7 @@
 {{ access }} protocol {{ .|call:file,service,method }}: ClientCallClientStreaming {
   /// Call this to send each message in the request stream. Nonblocking.
   func send(_ message: {{ method|input }}, errorHandler: @escaping (Error) -> Void) throws
-  
+
   /// Call this to close the connection and wait for a response. Blocking.
   func closeAndReceive() throws -> {{ method|output }}
   /// Call this to close the connection and wait for a response. Nonblocking.

+ 1 - 1
Plugin/Templates/client-call-unary.swift

@@ -1,4 +1,4 @@
-{{ access }} protocol {{ .|call:file,service,method }}: ClientCallUnary { }
+{{ access }} protocol {{ .|call:file,service,method }}: ClientCallUnary {}
 
 fileprivate final class {{ .|call:file,service,method }}Base: ClientCallUnaryBase<{{ method|input }}, {{ method|output }}>, {{ .|call:file,service,method }} {
   override class var method: String { return "{{ .|path:file,service,method }}" }

+ 4 - 5
Plugin/Templates/client.swift

@@ -55,8 +55,7 @@
       .run(request: request, metadata: metadata)
   }
   /// Asynchronous. Unary.
-  {{ access }} func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }},
-                  completion: @escaping ({{ method|output }}?, CallResult) -> Void) throws -> {{ .|call:file,service,method }} {
+  {{ access }} func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }}, completion: @escaping ({{ method|output }}?, CallResult) -> Void) throws -> {{ .|call:file,service,method }} {
     return try {{ .|call:file,service,method }}Base(channel)
       .start(request: request, metadata: metadata, completion: completion)
   }
@@ -67,7 +66,7 @@
   /// Use methods on the returned object to get streamed responses.
   {{ access }} func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }}, completion: ((CallResult) -> Void)?) throws -> {{ .|call:file,service,method }} {
     return try {{ .|call:file,service,method }}Base(channel)
-      .start(request:request, metadata:metadata, completion:completion)
+      .start(request: request, metadata: metadata, completion: completion)
   }
   //-{% endif %}
   //-{% if method|methodIsClientStreaming %}
@@ -76,7 +75,7 @@
   /// to close the connection and wait for a final response.
   {{ access }} func {{ method|methodDescriptorName|lowercase }}(completion: ((CallResult) -> Void)?) throws -> {{ .|call:file,service,method }} {
     return try {{ .|call:file,service,method }}Base(channel)
-       .start(metadata: metadata, completion: completion)
+      .start(metadata: metadata, completion: completion)
   }
   //-{% endif %}
   //-{% if method|methodIsBidiStreaming %}
@@ -111,7 +110,7 @@ class {{ .|serviceclass:file,service }}TestStub: ServiceClientTestStubBase, {{ .
   var {{ method|methodDescriptorName|lowercase }}Requests: [{{ method|input }}] = []
   var {{ method|methodDescriptorName|lowercase }}Calls: [{{ .|call:file,service,method }}] = []
   func {{ method|methodDescriptorName|lowercase }}(_ request: {{ method|input }}, completion: ((CallResult) -> Void)?) throws -> {{ .|call:file,service,method }} {
-      {{ method|methodDescriptorName|lowercase }}Requests.append(request)
+    {{ method|methodDescriptorName|lowercase }}Requests.append(request)
     defer { {{ method|methodDescriptorName|lowercase }}Calls.removeFirst() }
     return {{ method|methodDescriptorName|lowercase }}Calls.first!
   }

+ 1 - 1
Plugin/Templates/server-session-bidistreaming.swift

@@ -4,7 +4,7 @@
 
   /// Send a message. Nonblocking.
   func send(_ response: {{ method|output }}, completion: ((Bool) -> Void)?) throws
-  
+
   /// Close a connection. Blocks until the connection is closed.
   func close() throws
 }

+ 1 - 1
Plugin/Templates/server-session-unary.swift

@@ -1,4 +1,4 @@
-{{ access }} protocol {{ .|session:file,service,method }}: ServerSessionUnary { }
+{{ access }} protocol {{ .|session:file,service,method }}: ServerSessionUnary {}
 
 fileprivate final class {{ .|session:file,service,method }}Base: ServerSessionUnaryBase<{{ method|input }}, {{ method|output }}>, {{ .|session:file,service,method }} {}
 

+ 4 - 4
Plugin/Templates/server.swift

@@ -3,16 +3,16 @@
 {{ access }} protocol {{ .|provider:file,service }} {
   //-{% for method in service.methods %}
   //-{% if method|methodIsUnary %}
-  func {{ method|methodDescriptorName|lowercase }}(request : {{ method|input }}, session : {{ .|session:file,service,method }}) throws -> {{ method|output }}
+  func {{ method|methodDescriptorName|lowercase }}(request: {{ method|input }}, session: {{ .|session:file,service,method }}) throws -> {{ method|output }}
   //-{% endif %}
   //-{% if method|methodIsServerStreaming %}
-  func {{ method|methodDescriptorName|lowercase }}(request : {{ method|input }}, session : {{ .|session:file,service,method }}) throws
+  func {{ method|methodDescriptorName|lowercase }}(request: {{ method|input }}, session: {{ .|session:file,service,method }}) throws
   //-{% endif %}
   //-{% if method|methodIsClientStreaming %}
-  func {{ method|methodDescriptorName|lowercase }}(session : {{ .|session:file,service,method }}) throws
+  func {{ method|methodDescriptorName|lowercase }}(session: {{ .|session:file,service,method }}) throws
   //-{% endif %}
   //-{% if method|methodIsBidiStreaming %}
-  func {{ method|methodDescriptorName|lowercase }}(session : {{ .|session:file,service,method }}) throws
+  func {{ method|methodDescriptorName|lowercase }}(session: {{ .|session:file,service,method }}) throws
   //-{% endif %}
   //-{% endfor %}
 }