Skip to content

Commit

Permalink
Merge pull request #822 from ahoppen/fix-warning
Browse files Browse the repository at this point in the history
Fix build warnings
  • Loading branch information
ahoppen authored Sep 30, 2024
2 parents 8cb684e + acc3c6c commit 9fb082f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {

override func visit(_ node: GenericParameterSyntax) -> SyntaxVisitorContinueKind {
before(node.firstToken(viewMode: .sourceAccurate), tokens: .open)
after(node.eachKeyword, tokens: .break)
after(node.specifier, tokens: .break)
after(node.colon, tokens: .break)
if let trailingComma = node.trailingComma {
after(trailingComma, tokens: .close, .break(.same))
Expand Down
8 changes: 7 additions & 1 deletion Sources/generate-swift-format/FileGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ protocol FileGenerator {
func write(into handle: FileHandle) throws
}

private struct FailedToCreateFileError: Error {
let url: URL
}

extension FileGenerator {
/// Generates a file at the given URL, overwriting it if it already exists.
func generateFile(at url: URL) throws {
Expand All @@ -27,7 +31,9 @@ extension FileGenerator {
try fm.removeItem(at: url)
}

fm.createFile(atPath: url.path, contents: nil, attributes: nil)
if !fm.createFile(atPath: url.path, contents: nil, attributes: nil) {
throw FailedToCreateFileError(url: url)
}
let handle = try FileHandle(forWritingTo: url)
defer { handle.closeFile() }

Expand Down
7 changes: 6 additions & 1 deletion Tests/swift-formatTests/Utilities/FileIteratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ extension FileIteratorTests {
let fileURL = tmpURL(path)
try FileManager.default.createDirectory(
at: fileURL.deletingLastPathComponent(), withIntermediateDirectories: true)
FileManager.default.createFile(atPath: fileURL.path, contents: Data())
struct FailedToCreateFileError: Error {
let url: URL
}
if !FileManager.default.createFile(atPath: fileURL.path, contents: Data()) {
throw FailedToCreateFileError(url: fileURL)
}
}

/// Create a symlink between files or directories in the test's temporary space.
Expand Down

0 comments on commit 9fb082f

Please sign in to comment.