File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ class FormatFrontend: Frontend {
39
39
return
40
40
}
41
41
42
- var stdoutStream = FileHandle . standardOutput
42
+ var stdoutStream = FileHandleTextOutputStream ( FileHandle . standardOutput)
43
43
do {
44
44
if inPlace {
45
45
var buffer = " "
Original file line number Diff line number Diff line change 12
12
13
13
import Foundation
14
14
15
- extension FileHandle : TextOutputStream {
16
- public func write( _ string: String ) {
17
- self . write ( string. data ( using: . utf8) !) // Conversion to UTF-8 cannot fail
15
+ /// Wraps a `FileHandle` so that it can be used by APIs that take a `TextOutputStream`-conforming
16
+ /// type as an input.
17
+ struct FileHandleTextOutputStream : TextOutputStream {
18
+ /// The underlying file handle to which the text will be written.
19
+ private var fileHandle : FileHandle
20
+
21
+ /// Creates a new output stream that writes to the given file handle.
22
+ init ( _ fileHandle: FileHandle ) {
23
+ self . fileHandle = fileHandle
24
+ }
25
+
26
+ func write( _ string: String ) {
27
+ fileHandle. write ( string. data ( using: . utf8) !) // Conversion to UTF-8 cannot fail
18
28
}
19
29
}
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ final class StderrDiagnosticPrinter {
64
64
/// Prints a diagnostic to standard error.
65
65
func printDiagnostic( _ diagnostic: TSCBasic . Diagnostic ) {
66
66
printQueue. sync {
67
- let stderr = FileHandle . standardError
67
+ let stderr = FileHandleTextOutputStream ( FileHandle . standardError)
68
68
69
69
stderr. write ( " \( ansiSGR ( . boldWhite) ) \( diagnostic. location) : " )
70
70
You can’t perform that action at this time.
0 commit comments