Skip to content

Commit

Permalink
Use a nil Descriptor list for empty proto files (#2152)
Browse files Browse the repository at this point in the history
### 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.
  • Loading branch information
rnro authored Jan 7, 2025
1 parent 5e92f64 commit 560c6c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ package struct IDLToStructuredSwiftTranslator: Translator {
}
}

let imports: [ImportDescription]
let imports: [ImportDescription]?
if codeGenerationRequest.services.isEmpty {
imports = []
imports = nil
codeBlocks.append(
CodeBlock(comment: .inline("This file contained no services."))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ final class IDLToStructuredSwiftTranslatorSnippetBasedTests: XCTestCase {
"""
/// Some really exciting license header 2023.
// This file contained no services.
"""
try self.assertIDLToStructuredSwiftTranslation(
Expand Down

0 comments on commit 560c6c7

Please sign in to comment.