mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #63223 from DougGregor/colorize-swift-syntax-diagnostics
Colorize swift syntax diagnostics
This commit is contained in:
@@ -244,13 +244,17 @@ public func addQueuedDiagnostic(
|
||||
@_cdecl("swift_ASTGen_renderQueuedDiagnostics")
|
||||
public func renterQueuedDiagnostics(
|
||||
queuedDiagnosticsPtr: UnsafeMutablePointer<UInt8>,
|
||||
contextSize: Int,
|
||||
colorize: Int,
|
||||
renderedPointer: UnsafeMutablePointer<UnsafePointer<UInt8>?>,
|
||||
renderedLength: UnsafeMutablePointer<Int>
|
||||
) {
|
||||
queuedDiagnosticsPtr.withMemoryRebound(to: QueuedDiagnostics.self, capacity: 1) { queuedDiagnostics in
|
||||
let renderedStr = DiagnosticsFormatter.annotatedSource(
|
||||
tree: queuedDiagnostics.pointee.sourceFile,
|
||||
diags: queuedDiagnostics.pointee.diagnostics
|
||||
diags: queuedDiagnostics.pointee.diagnostics,
|
||||
contextSize: contextSize,
|
||||
colorize: colorize != 0
|
||||
)
|
||||
|
||||
(renderedPointer.pointee, renderedLength.pointee) =
|
||||
|
||||
@@ -42,7 +42,8 @@ extern "C" void swift_ASTGen_addQueuedDiagnostic(
|
||||
const void *sourceLoc
|
||||
);
|
||||
extern "C" void swift_ASTGen_renderQueuedDiagnostics(
|
||||
void *queued, char **outBuffer, ptrdiff_t *outBufferLength);
|
||||
void *queued, ptrdiff_t contextSize, ptrdiff_t colorize,
|
||||
char **outBuffer, ptrdiff_t *outBufferLength);
|
||||
|
||||
// FIXME: Hack because we cannot easily get to the already-parsed source
|
||||
// file from here. Fix this egregious oversight!
|
||||
@@ -1106,7 +1107,8 @@ void PrintingDiagnosticConsumer::flush(bool includeTrailingBreak) {
|
||||
char *renderedString = nullptr;
|
||||
ptrdiff_t renderedStringLen = 0;
|
||||
swift_ASTGen_renderQueuedDiagnostics(
|
||||
queuedDiagnostics, &renderedString, &renderedStringLen);
|
||||
queuedDiagnostics, /*contextSize=*/2, ForceColors ? 1 : 0,
|
||||
&renderedString, &renderedStringLen);
|
||||
if (renderedString) {
|
||||
Stream.write(renderedString, renderedStringLen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user