public override void suppressProblem(Problem p, SuppressionScope scope) { if (p == null) return; String simpleFileName = p.FileName; String suppressionLine = null; switch (scope) { case SuppressionScope.suppressAllMessagesThisFileGlobally: case SuppressionScope.suppressAllMessagesThisFileSolutionWide: case SuppressionScope.suppressAllMessagesThisFileProjectWide: suppressionLine = "*:" + simpleFileName; break; case SuppressionScope.suppressThisTypeOfMessageFileWide: suppressionLine = p.MessageId + ":" + simpleFileName; break; case SuppressionScope.suppressThisTypeOfMessagesGlobally: case SuppressionScope.suppressThisTypeOfMessageProjectWide: case SuppressionScope.suppressThisTypeOfMessagesSolutionWide: suppressionLine = p.MessageId; break; case SuppressionScope.suppressThisMessage: case SuppressionScope.suppressThisMessageSolutionWide: case SuppressionScope.suppressThisMessageGlobally: suppressionLine = p.MessageId + ":" + simpleFileName + ":" + p.Line; break; default: throw new InvalidOperationException("Unsupported value: " + scope.ToString()); } String suppressionsFilePath = suppressionsFilePathByScope(scope, p.BaseProjectPath, p.ProjectName); Debug.Assert(suppressionsFilePath != null); SuppressionsInfo suppressionsInfo = new SuppressionsInfo(); suppressionsInfo.LoadFromFile(suppressionsFilePath); suppressionsInfo.AddSuppressionLine(suppressionLine); suppressionsInfo.SaveToFile(suppressionsFilePath); }
protected void addProblemToToolwindow(Problem problem) { if (MainToolWindow.Instance != null && problem != null) MainToolWindow.Instance.displayProblem(problem); }
public abstract void suppressProblem(Problem p, SuppressionScope scope);
protected override List<Problem> parseOutput(String output) { // template={file}|{line}|{severity}|{id}|{message} if (String.IsNullOrWhiteSpace(output)) return null; try { Match progressValueMatch = Regex.Match(output, @"([0-9]+)% done"); if (progressValueMatch.Success) { // This is a progress update int progress = Convert.ToInt32(progressValueMatch.Groups[1].Value.Replace("% done", "")); int filesChecked = 0, totalFiles = 0; Match filesProgressMatch = Regex.Match(output, @"([0-9]+)/([0-9]+) files checked"); if (filesProgressMatch.Success) { filesChecked = Convert.ToInt32(filesProgressMatch.Groups[1].ToString()); totalFiles = Convert.ToInt32(filesProgressMatch.Groups[2].ToString()); } onProgressUpdated(progress, filesChecked, totalFiles); if (_unfinishedProblem == null) { return null; } List<Problem> list = new List<Problem>(); list.Add(_unfinishedProblem); // Done with the current message _unfinishedProblem = null; return list; } } catch (System.Exception) {} if (output.StartsWith("Checking ")) { if (_unfinishedProblem == null) { return null; } List<Problem> list = new List<Problem>(); list.Add(_unfinishedProblem); // Done with the current message _unfinishedProblem = null; return list; } else if (!output.Contains("|")) // This line does not represent a new defect found by cppcheck; could be continuation of a multi-line issue description { if (_unfinishedProblem != null) _unfinishedProblem.Message += "\n" + output; return null; // Not done with the current message yet } String[] parsed = output.Split('|'); if (parsed.Length != 5) return null; // New issue found - finalize the previous one List<Problem> result = new List<Problem>(); if (_unfinishedProblem != null) result.Add(_unfinishedProblem); Problem.SeverityLevel severity = Problem.SeverityLevel.info; if (parsed[2] == "error") severity = Problem.SeverityLevel.error; else if (parsed[2] == "warning") severity = Problem.SeverityLevel.warning; _unfinishedProblem = new Problem(this, severity, parsed[3], parsed[4], parsed[0], String.IsNullOrWhiteSpace(parsed[1]) ? 0 : Int32.Parse(parsed[1]), _projectBasePath, _projectName); MainToolWindow.Instance.bringToFront(); return result; }
public void displayProblem(Problem problem) { Application.Current.Dispatcher.BeginInvoke(new Action(()=> { _listView.Items.Add(new MainToolWindowUI.ProblemsListItem(problem)); AutoSizeColumns(); })); }
public abstract void suppressProblem(Problem p, SuppressionScope scope);
protected override List <Problem> parseOutput(String output) { // template={file}|{line}|{severity}|{id}|{message} if (String.IsNullOrWhiteSpace(output)) { return(null); } try { Match progressValueMatch = Regex.Match(output, @"([0-9]+)% done"); if (progressValueMatch.Success) { // This is a progress update int progress = Convert.ToInt32(progressValueMatch.Groups[1].Value.Replace("% done", "")); int filesChecked = 0, totalFiles = 0; Match filesProgressMatch = Regex.Match(output, @"([0-9]+)/([0-9]+) files checked"); if (filesProgressMatch.Success) { filesChecked = Convert.ToInt32(filesProgressMatch.Groups[1].ToString()); totalFiles = Convert.ToInt32(filesProgressMatch.Groups[2].ToString()); } onProgressUpdated(progress, filesChecked, totalFiles); if (_unfinishedProblem == null) { return(null); } List <Problem> list = new List <Problem>(); list.Add(_unfinishedProblem); // Done with the current message _unfinishedProblem = null; return(list); } } catch (System.Exception) { } if (output.StartsWith("Checking ")) { if (_unfinishedProblem == null) { return(null); } List <Problem> list = new List <Problem>(); list.Add(_unfinishedProblem); // Done with the current message _unfinishedProblem = null; return(list); } else if (!output.Contains("|")) // This line does not represent a new defect found by cppcheck; could be continuation of a multi-line issue description { if (_unfinishedProblem != null) { _unfinishedProblem.Message += "\n" + output; } return(null); // Not done with the current message yet } String[] parsed = output.Split('|'); if (parsed.Length != 5) { return(null); } // New issue found - finalize the previous one List <Problem> result = new List <Problem>(); if (_unfinishedProblem != null) { result.Add(_unfinishedProblem); } Problem.SeverityLevel severity = Problem.SeverityLevel.info; if (parsed[2] == "error") { severity = Problem.SeverityLevel.error; } else if (parsed[2] == "warning") { severity = Problem.SeverityLevel.warning; } _unfinishedProblem = new Problem(this, severity, parsed[3], parsed[4], parsed[0], String.IsNullOrWhiteSpace(parsed[1]) ? 0 : Int32.Parse(parsed[1]), _projectBasePath, _projectName); MainToolWindow.Instance.bringToFront(); return(result); }