From a4fcb3df669ac96538b88cd7908e6c3d89294bd9 Mon Sep 17 00:00:00 2001 From: Maximiliano Jabase Date: Wed, 26 Oct 2022 16:50:08 -0300 Subject: [PATCH] fixed warnings not showing properly after latest update --- UI/MainWindow/MainWindowSPCompiler.cs | 43 +++++++++++++-------------- Utils/Models/ErrorDataGridRow.cs | 23 ++++++++++---- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/UI/MainWindow/MainWindowSPCompiler.cs b/UI/MainWindow/MainWindowSPCompiler.cs index 11e4a97b..bfe272b0 100644 --- a/UI/MainWindow/MainWindowSPCompiler.cs +++ b/UI/MainWindow/MainWindowSPCompiler.cs @@ -51,7 +51,7 @@ private async void Compile_SPScripts(bool compileAll = true) { // Checks if the program is compiling to avoid doing it again, and checks if the editor is from the templates window var ee = GetCurrentEditorElement(); - if (InCompiling || (ee != null && ee.IsTemplateEditor)) + if (ee == null || InCompiling || ee.IsTemplateEditor) { return; } @@ -229,9 +229,20 @@ await this.ShowMessageAsync(Translate("SPCompNotStarted"), switch (process.ExitCode) { - // Successful compilation + // Successful compilation (could have warnings) case 0: { + var matches = _errorFilterRegex.Matches(sb.ToString()); + foreach (Match match in matches) + { + TotalWarnings++; + var item = new ErrorDataGridRow(match); + if (!HideWarnings) + { + ErrorResultGrid.Items.Add(item); + } + CurrentWarnings.Add(item); + } LoggingControl.LogAction($"{fileInfo.Name}{(TotalWarnings > 0 ? $" ({TotalWarnings} warnings)" : "")}"); compiledSuccess++; break; @@ -244,32 +255,19 @@ await this.ShowMessageAsync(Translate("SPCompNotStarted"), var matches = _errorFilterRegex.Matches(sb.ToString()); foreach (Match match in matches) { - if (match.Groups["Type"].Value.Contains("error")) + var item = new ErrorDataGridRow(match); + if (item.IsError) { TotalErrors++; - var item = new ErrorDataGridRow - { - File = match.Groups["File"].Value.Trim(), - Line = match.Groups["Line"].Value.Trim(), - Type = match.Groups["Type"].Value.Trim(), - Details = match.Groups["Details"].Value.Trim() - }; if (!HideErrors) { ErrorResultGrid.Items.Add(item); } CurrentErrors.Add(item); } - if (match.Groups["Type"].Value.Contains("warning")) + if (item.IsWarning) { TotalWarnings++; - var item = new ErrorDataGridRow - { - File = match.Groups["File"].Value.Trim(), - Line = match.Groups["Line"].Value.Trim(), - Type = match.Groups["Type"].Value.Trim(), - Details = match.Groups["Details"].Value.Trim() - }; if (!HideWarnings) { ErrorResultGrid.Items.Add(item); @@ -348,10 +346,11 @@ await this.ShowMessageAsync(Translate("Error"), ProgressTask.SetProgress(1.0); } - if (CompileOutputRow.Height.Value < 11.0) - { - CompileOutputRow.Height = new GridLength(200.0); - } + } + + if (CompileOutputRow.Height.Value < 11.0) + { + CompileOutputRow.Height = new GridLength(200.0); } await ProgressTask.CloseAsync(); diff --git a/Utils/Models/ErrorDataGridRow.cs b/Utils/Models/ErrorDataGridRow.cs index f37b7737..86a226ec 100644 --- a/Utils/Models/ErrorDataGridRow.cs +++ b/Utils/Models/ErrorDataGridRow.cs @@ -1,10 +1,23 @@ -namespace SPCode.Utils +using System.Text.RegularExpressions; + +namespace SPCode.Utils { public class ErrorDataGridRow { - public string File { set; get; } - public string Line { set; get; } - public string Type { set; get; } - public string Details { set; get; } + public bool IsError => Type.Contains("error"); + public bool IsWarning => Type.Contains("warning"); + + public string File { get; } + public string Line { get; } + public string Type { get; } + public string Details { get; } + + public ErrorDataGridRow(Match match) + { + File = match.Groups["File"].Value.Trim(); + Line = match.Groups["Line"].Value.Trim(); + Type = match.Groups["Type"].Value.Trim(); + Details = match.Groups["Details"].Value.Trim(); + } } } \ No newline at end of file