forked from UbiquityDotNET/Llvm.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorTrackingDiagnostics.cs
More file actions
61 lines (51 loc) · 1.67 KB
/
Copy pathErrorTrackingDiagnostics.cs
File metadata and controls
61 lines (51 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
namespace LlvmBindingsGenerator
{
internal class ErrorTrackingDiagnostics
: IDiagnostics
{
public int ErrorCount { get; private set; }
public DiagnosticKind Level
{
get => InnerDiagnostics.Level;
set => InnerDiagnostics.Level = value;
}
public void Emit( DiagnosticInfo info )
{
try
{
switch( info.Kind )
{
case DiagnosticKind.Debug:
Console.ForegroundColor = ConsoleColor.Cyan;
break;
case DiagnosticKind.Message:
Console.ForegroundColor = ConsoleColor.White;
break;
case DiagnosticKind.Warning:
Console.ForegroundColor = ConsoleColor.Yellow;
break;
case DiagnosticKind.Error:
Console.ForegroundColor = ConsoleColor.Red;
++ErrorCount;
break;
}
InnerDiagnostics.Emit( info );
}
finally
{
Console.ResetColor( );
}
}
public void PopIndent( )
{
InnerDiagnostics.PopIndent( );
}
public void PushIndent( int level = 4 )
{
InnerDiagnostics.PushIndent( level );
}
private readonly ConsoleDiagnostics InnerDiagnostics = new();
}
}