public ErrorMatch Match(ReadOnlyLineBuffer Input) { Match Match; if (Input.TryMatch(@"^(\s*)([a-zA-Z_][a-zA-Z0-9_]*):\s*(Error|Warning|Display): ", out Match)) { int MaxOffset = Input.MatchForwards(0, String.Format(@"^({0} | *$)", Match.Groups[1].Value)); ErrorSeverity Severity; switch (Match.Groups[3].Value) { case "Error": Severity = ErrorSeverity.Error; break; case "Warning": Severity = ErrorSeverity.Warning; break; default: Severity = ErrorSeverity.Silent; break; } ErrorMatch Error = new ErrorMatch(Severity, ErrorPriority.Low, "Log", Input, 0, MaxOffset); Error.Properties["Channel"] = Match.Groups[2].Value; return(Error); } return(null); }
public void OnErrorMatch(ErrorMatch Error) { if (Error.Severity == ErrorSeverity.Error) { // Find the longest sequence of spaces common to every non-empty line int WhitespaceLen = int.MaxValue; foreach (string Line in Error.Lines) { int ThisWhitespaceLen = 0; while (ThisWhitespaceLen < Line.Length && Line[ThisWhitespaceLen] == ' ') { ThisWhitespaceLen++; } if (ThisWhitespaceLen < Line.Length) { WhitespaceLen = Math.Min(WhitespaceLen, ThisWhitespaceLen); } } // Remove the whitespace prefix List <string> Lines = Error.Lines; if (WhitespaceLen < int.MaxValue) { Lines = new List <string>(Lines); for (int Idx = 0; Idx < Lines.Count; Idx++) { string Line = Lines[Idx]; if (Line.Length > WhitespaceLen) { Line = Line.Substring(WhitespaceLen); } else { Line = String.Empty; } Lines[Idx] = Line; } } // Add the output diagnostic InputDiagnostic Diagnostic = new InputDiagnostic(); Diagnostic.Type = "Error"; Diagnostic.Message = String.Join("\n", Lines); if (LineUrl != null) { string Url = LineUrl; Url = Url.Replace("{LINE_START}", Error.MinLineNumber.ToString()); Url = Url.Replace("{LINE_END}", Error.MaxLineNumber.ToString()); Url = Url.Replace("{LINE_COUNT}", (Error.MaxLineNumber + 1 - Error.MinLineNumber).ToString()); Diagnostic.Url = Url; } JobStep.Diagnostics.Add(Diagnostic); } }
/// <summary> /// Called when an error is matched /// </summary> /// <param name="Error">The matched error</param> public void OnErrorMatch(ErrorMatch Error) { lock (LockObject) { NewErrors.Add(Error); } UpdateEvent.Set(); if (BackgroundThread == null) { BackgroundThread = new Thread(() => BackgroundWorker()); BackgroundThread.Start(); } }
/// <summary> /// Called when an error is matched /// </summary> /// <param name="Error">The matched error</param> public void OnErrorMatch(ErrorMatch Error) { Console.WriteLine("Error of type '{0}' at line {1}:", Error.Type, Error.MinLineNumber); foreach (string Line in Error.Lines) { Console.WriteLine("Text: |{0}|", Line); } if (Error.Properties.Count > 0) { Console.WriteLine("Properties:"); foreach (KeyValuePair <string, string> Pair in Error.Properties) { Console.WriteLine(" {0} = {1}", Pair.Key, Pair.Value); } } Console.WriteLine(); }