Better compiler error reporting

This commit is contained in:
Yoshi Askharoun
2024-07-07 15:37:27 -05:00
parent 53a150f15d
commit ee522bfc87
2 changed files with 22 additions and 11 deletions
+19 -9
View File
@@ -44,18 +44,26 @@ public class CompileCommand : Command<CompileCommand.Settings>
{ {
foreach (ErrorRecord error in errors) foreach (ErrorRecord error in errors)
{ {
var l = Math.Max(0, error.Line); var l = error.Line;
var c = Math.Max(0, error.Column); var c = error.Column;
var msg = error.Message; var msg = error.Message;
var ctx = error.Context; var ctx = error.Context ?? "";
const string compilerError = "Iris error"; var diagnostic = error.Warning
var diagnostic = error.Warning ? Diagnostic.Warning(compilerError) : Diagnostic.Error(compilerError); ? Diagnostic.Warning(msg)
: Diagnostic.Error(msg);
report.AddDiagnostic(diagnostic if (ctx is not null && error.Line >= 0 && error.Column >= 0)
.WithCode("UIX0000") {
.WithLabel(new(ctx, new Location(l, c), msg)) Label label = new(ctx, new Location(l, c), "")
); {
Color = error.Warning ? Color.Yellow : Color.Red
};
diagnostic = diagnostic.WithLabel(label);
}
report.AddDiagnostic(diagnostic);
} }
}; };
TraceSettings.Current.SetCategoryLevel(TraceCategory.Markup, byte.MaxValue); TraceSettings.Current.SetCategoryLevel(TraceCategory.Markup, byte.MaxValue);
@@ -70,6 +78,8 @@ public class CompileCommand : Command<CompileCommand.Settings>
var success = MarkupCompiler.Compile(compilands, dataTableInput); var success = MarkupCompiler.Compile(compilands, dataTableInput);
report.Render(AnsiConsole.Console);
if (!success) if (!success)
{ {
AnsiConsole.MarkupLine("[red]Compilation failed.[/]"); AnsiConsole.MarkupLine("[red]Compilation failed.[/]");
+3 -2
View File
@@ -1,8 +1,9 @@
{ {
"profiles": { "profiles": {
"UIXC": { "UIXC": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "decompile CONTEXTMENU.UIX --verbose -A UIXControls.dll -I D:\\Documents\\REProj\\Zune\\UIXControls48" "commandLineArgs": "compile \"D:\\Documents\\REProj\\Zune\\UIXA\\UIXControls!ComboBox.uixa\" -A ZuneShell.dll -A UIXControls.dll -A ZuneDBApi.dll -o D:\\Documents\\REProj\\Zune\\UIXA",
"workingDirectory": "C:\\Program Files\\Zune"
} }
} }
} }