Skip to content

Commit 560c6c7

Browse files
authored
Use a nil Descriptor list for empty proto files (#2152)
### Motivation: If a proto file contains no services we include a comment indicating this is expected. At the moment this has two empty lines above it. ### Modifications: Store `nil` instead of an empty array of `Descriptor`s into the `FileDescription`. ### Result: Only one empty line above the comment.
1 parent 5e92f64 commit 560c6c7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

Sources/GRPCCodeGen/Internal/Translator/IDLToStructuredSwiftTranslator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ package struct IDLToStructuredSwiftTranslator: Translator {
7474
}
7575
}
7676

77-
let imports: [ImportDescription]
77+
let imports: [ImportDescription]?
7878
if codeGenerationRequest.services.isEmpty {
79-
imports = []
79+
imports = nil
8080
codeBlocks.append(
8181
CodeBlock(comment: .inline("This file contained no services."))
8282
)

Tests/GRPCCodeGenTests/Internal/Translator/IDLToStructuredSwiftTranslatorSnippetBasedTests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ final class IDLToStructuredSwiftTranslatorSnippetBasedTests: XCTestCase {
145145
"""
146146
/// Some really exciting license header 2023.
147147
148-
149148
// This file contained no services.
150149
"""
151150
try self.assertIDLToStructuredSwiftTranslation(

0 commit comments

Comments
 (0)