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

Commit

Permalink
fixed warnings not showing properly after latest update
Browse files Browse the repository at this point in the history
  • Loading branch information
maxijabase committed Oct 26, 2022
1 parent d7bb081 commit a4fcb3d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
43 changes: 21 additions & 22 deletions UI/MainWindow/MainWindowSPCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
23 changes: 18 additions & 5 deletions Utils/Models/ErrorDataGridRow.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

0 comments on commit a4fcb3d

Please sign in to comment.