Skip to content

Commit 0386af0

Browse files
committed
Re-format code
1 parent cca6483 commit 0386af0

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

Sources/protoc-gen-grpc-swift/Generator-Client+AsyncAwait.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extension Generator {
4949

5050
case .clientStreaming, .bidirectionalStreaming:
5151
arguments = [
52-
"callOptions: \(Types.clientCallOptions)?",
52+
"callOptions: \(Types.clientCallOptions)?"
5353
]
5454
}
5555

@@ -61,7 +61,7 @@ extension Generator {
6161
)
6262
}
6363
}
64-
self.println("}") // protocol
64+
self.println("}") // protocol
6565
}
6666
}
6767

@@ -156,7 +156,8 @@ extension Generator {
156156
let streamsRequests = [.clientStreaming, .bidirectionalStreaming].contains(rpcType)
157157

158158
// (protocol, requires sendable)
159-
let sequenceProtocols: [(String, Bool)?] = streamsRequests
159+
let sequenceProtocols: [(String, Bool)?] =
160+
streamsRequests
160161
? [("Sequence", false), ("AsyncSequence", true)]
161162
: [nil]
162163

@@ -165,12 +166,14 @@ extension Generator {
165166
if i > 0 || j > 0 {
166167
self.println()
167168
}
168-
let functionName = streamsRequests
169+
let functionName =
170+
streamsRequests
169171
? "\(self.methodFunctionName)<RequestStream>"
170172
: self.methodFunctionName
171173
let requestParamName = streamsRequests ? "requests" : "request"
172174
let requestParamType = streamsRequests ? "RequestStream" : self.methodInputName
173-
let returnType = streamsResponses
175+
let returnType =
176+
streamsResponses
174177
? Types.responseStream(of: self.methodOutputName)
175178
: self.methodOutputName
176179
let maybeWhereClause = sequenceProtocol.map { protocolName, mustBeSendable -> String in

Sources/protoc-gen-grpc-swift/Generator-Client.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,14 @@ extension Generator {
8989
self.println("\(functionHead)func \(name)(")
9090
self.withIndentation {
9191
// Add a comma after each argument except the last.
92-
arguments.forEach(beforeLast: {
93-
self.println($0 + ",")
94-
}, onLast: {
95-
self.println($0)
96-
})
92+
arguments.forEach(
93+
beforeLast: {
94+
self.println($0 + ",")
95+
},
96+
onLast: {
97+
self.println($0)
98+
}
99+
)
97100
}
98101
self.println(")\(asyncThrows)\(`return`)\(genericWhere)", newline: !hasBody)
99102
}
@@ -504,7 +507,7 @@ extension Generator {
504507
self.printFunction(
505508
name: "make\(self.method.name)ResponseStream",
506509
arguments: [
507-
"_ requestHandler: @escaping (FakeRequestPart<\(self.methodInputName)>) -> () = { _ in }",
510+
"_ requestHandler: @escaping (FakeRequestPart<\(self.methodInputName)>) -> () = { _ in }"
508511
],
509512
returnType: "\(type)<\(self.methodInputName), \(self.methodOutputName)>",
510513
access: self.access
@@ -569,7 +572,7 @@ extension Generator {
569572
self.printFakeResponseStreams()
570573
}
571574

572-
self.println("}") // end class
575+
self.println("}") // end class
573576
}
574577
}
575578

@@ -664,9 +667,9 @@ extension MethodDescriptor {
664667
let sourceComments = self.protoSourceComments()
665668

666669
if sourceComments.isEmpty {
667-
return "/// \(streamingType.name) call to \(self.name)\n" // comments end with "\n" already.
670+
return "/// \(streamingType.name) call to \(self.name)\n" // comments end with "\n" already.
668671
} else {
669-
return sourceComments // already prefixed with "///"
672+
return sourceComments // already prefixed with "///"
670673
}
671674
}
672675
}

Sources/protoc-gen-grpc-swift/Generator-Server+AsyncAwait.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ extension Generator {
176176
self.println("return nil")
177177
}
178178

179-
self.println("}") // switch
179+
self.println("}") // switch
180180
}
181181
}
182182
}

Sources/protoc-gen-grpc-swift/Generator.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class Generator {
2020
private var printer: CodePrinter
2121

2222
internal var file: FileDescriptor
23-
internal var service: ServiceDescriptor! // context during generation
24-
internal var method: MethodDescriptor! // context during generation
23+
internal var service: ServiceDescriptor! // context during generation
24+
internal var method: MethodDescriptor! // context during generation
2525

2626
internal let protobufNamer: SwiftProtobufNamer
2727

@@ -108,15 +108,17 @@ class Generator {
108108
}
109109

110110
private func printMain() {
111-
self.printer.print("""
112-
//
113-
// DO NOT EDIT.
114-
// swift-format-ignore-file
115-
//
116-
// Generated by the protocol buffer compiler.
117-
// Source: \(self.file.name)
118-
//\n
119-
""")
111+
self.printer.print(
112+
"""
113+
//
114+
// DO NOT EDIT.
115+
// swift-format-ignore-file
116+
//
117+
// Generated by the protocol buffer compiler.
118+
// Source: \(self.file.name)
119+
//\n
120+
"""
121+
)
120122

121123
let moduleNames = [
122124
self.options.gRPCModuleName,

Sources/protoc-gen-grpc-swift/main.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func main(args: [String]) throws {
141141
// Only generate output for services.
142142
for name in request.fileToGenerate {
143143
if let fileDescriptor = descriptorSet.fileDescriptor(named: name) {
144-
if (options.generateReflectionData) {
144+
if options.generateReflectionData {
145145
var binaryFile = Google_Protobuf_Compiler_CodeGeneratorResponse.File()
146146
let binaryFileName = uniqueOutputFileName(
147147
component: "grpc.reflection",
@@ -156,10 +156,7 @@ func main(args: [String]) throws {
156156
binaryFile.content = serializedFileDescriptorProto
157157
response.file.append(binaryFile)
158158
}
159-
if (
160-
!fileDescriptor.services
161-
.isEmpty && (options.generateClient || options.generateServer)
162-
) {
159+
if !fileDescriptor.services.isEmpty && (options.generateClient || options.generateServer) {
163160
var grpcFile = Google_Protobuf_Compiler_CodeGeneratorResponse.File()
164161
let grpcFileName = uniqueOutputFileName(
165162
component: "grpc",

0 commit comments

Comments
 (0)