Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit a4fcb3d

Browse files
committed
fixed warnings not showing properly after latest update
1 parent d7bb081 commit a4fcb3d

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

UI/MainWindow/MainWindowSPCompiler.cs

+21-22
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private async void Compile_SPScripts(bool compileAll = true)
5151
{
5252
// Checks if the program is compiling to avoid doing it again, and checks if the editor is from the templates window
5353
var ee = GetCurrentEditorElement();
54-
if (InCompiling || (ee != null && ee.IsTemplateEditor))
54+
if (ee == null || InCompiling || ee.IsTemplateEditor)
5555
{
5656
return;
5757
}
@@ -229,9 +229,20 @@ await this.ShowMessageAsync(Translate("SPCompNotStarted"),
229229

230230
switch (process.ExitCode)
231231
{
232-
// Successful compilation
232+
// Successful compilation (could have warnings)
233233
case 0:
234234
{
235+
var matches = _errorFilterRegex.Matches(sb.ToString());
236+
foreach (Match match in matches)
237+
{
238+
TotalWarnings++;
239+
var item = new ErrorDataGridRow(match);
240+
if (!HideWarnings)
241+
{
242+
ErrorResultGrid.Items.Add(item);
243+
}
244+
CurrentWarnings.Add(item);
245+
}
235246
LoggingControl.LogAction($"{fileInfo.Name}{(TotalWarnings > 0 ? $" ({TotalWarnings} warnings)" : "")}");
236247
compiledSuccess++;
237248
break;
@@ -244,32 +255,19 @@ await this.ShowMessageAsync(Translate("SPCompNotStarted"),
244255
var matches = _errorFilterRegex.Matches(sb.ToString());
245256
foreach (Match match in matches)
246257
{
247-
if (match.Groups["Type"].Value.Contains("error"))
258+
var item = new ErrorDataGridRow(match);
259+
if (item.IsError)
248260
{
249261
TotalErrors++;
250-
var item = new ErrorDataGridRow
251-
{
252-
File = match.Groups["File"].Value.Trim(),
253-
Line = match.Groups["Line"].Value.Trim(),
254-
Type = match.Groups["Type"].Value.Trim(),
255-
Details = match.Groups["Details"].Value.Trim()
256-
};
257262
if (!HideErrors)
258263
{
259264
ErrorResultGrid.Items.Add(item);
260265
}
261266
CurrentErrors.Add(item);
262267
}
263-
if (match.Groups["Type"].Value.Contains("warning"))
268+
if (item.IsWarning)
264269
{
265270
TotalWarnings++;
266-
var item = new ErrorDataGridRow
267-
{
268-
File = match.Groups["File"].Value.Trim(),
269-
Line = match.Groups["Line"].Value.Trim(),
270-
Type = match.Groups["Type"].Value.Trim(),
271-
Details = match.Groups["Details"].Value.Trim()
272-
};
273271
if (!HideWarnings)
274272
{
275273
ErrorResultGrid.Items.Add(item);
@@ -348,10 +346,11 @@ await this.ShowMessageAsync(Translate("Error"),
348346
ProgressTask.SetProgress(1.0);
349347
}
350348

351-
if (CompileOutputRow.Height.Value < 11.0)
352-
{
353-
CompileOutputRow.Height = new GridLength(200.0);
354-
}
349+
}
350+
351+
if (CompileOutputRow.Height.Value < 11.0)
352+
{
353+
CompileOutputRow.Height = new GridLength(200.0);
355354
}
356355

357356
await ProgressTask.CloseAsync();

Utils/Models/ErrorDataGridRow.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
namespace SPCode.Utils
1+
using System.Text.RegularExpressions;
2+
3+
namespace SPCode.Utils
24
{
35
public class ErrorDataGridRow
46
{
5-
public string File { set; get; }
6-
public string Line { set; get; }
7-
public string Type { set; get; }
8-
public string Details { set; get; }
7+
public bool IsError => Type.Contains("error");
8+
public bool IsWarning => Type.Contains("warning");
9+
10+
public string File { get; }
11+
public string Line { get; }
12+
public string Type { get; }
13+
public string Details { get; }
14+
15+
public ErrorDataGridRow(Match match)
16+
{
17+
File = match.Groups["File"].Value.Trim();
18+
Line = match.Groups["Line"].Value.Trim();
19+
Type = match.Groups["Type"].Value.Trim();
20+
Details = match.Groups["Details"].Value.Trim();
21+
}
922
}
1023
}

0 commit comments

Comments
 (0)