private void EditProjectSuppressions(object sender, RoutedEventArgs e) { var projectPath = CPPCheckPluginPackage.activeProjectPath(); var projectName = CPPCheckPluginPackage.activeProjectName(); if (projectPath != "" && projectName != "") { var settings = new SuppressionSettingsUI.SuppressionsSettings( ICodeAnalyzer.SuppressionStorage.Project, projectPath, projectName); settings.ShowDialog(); } else { MessageBox.Show("No C++ project selected in the solution explorer."); } }
private void analyzerOutputHandler(object sendingProcess, DataReceivedEventArgs outLine) { if (_thread == null) { // We got here because the environment is shutting down, the current object was disposed and the thread was aborted. return; } String output = outLine.Data; if (!String.IsNullOrEmpty(output)) { addProblemsToToolwindow(parseOutput(output)); try { _ = CPPCheckPluginPackage.AddTextToOutputWindowAsync(output + "\n"); } catch (Exception) { } } }
private void EditProjectSuppressions(object sender, RoutedEventArgs e) { CPPCheckPluginPackage.Instance.JoinableTaskFactory.Run(async() => { var projectPath = await CPPCheckPluginPackage.activeProjectPathAsync(); var projectName = await CPPCheckPluginPackage.activeProjectNameAsync(); if (projectPath != "" && projectName != "") { var settings = new SuppressionSettingsUI.SuppressionsSettings( ICodeAnalyzer.SuppressionStorage.Project, projectPath, projectName); settings.ShowDialog(); } else { MessageBox.Show("No C++ project selected in the solution explorer."); } }); }
public CppcheckSettings() { InitializeComponent(); Activated += onActivated; Closed += OnClosed; if (String.IsNullOrWhiteSpace(Properties.Settings.Default.DefaultArguments)) { Properties.Settings.Default.DefaultArguments = DefaultArguments; } else { Properties.Settings.Default.DefaultArguments = Properties.Settings.Default.DefaultArguments.Replace("--template=vs", "--template=\"{file}|{line}|{severity}|{id}|{message}\""); } Properties.Settings.Default.Save(); if (!Properties.Settings.Default.CheckSavedFilesHasValue) { CPPCheckPluginPackage.askCheckSavedFiles(); } }
private static string solutionSuppressionsFilePath() { return(CPPCheckPluginPackage.solutionPath() + "\\" + CPPCheckPluginPackage.solutionName() + "_solution_suppressions.cfg"); }
private void startAnalyzerProcess(string analyzerExePath, string arguments) { System.Diagnostics.Process process = null; try { Debug.Assert(!String.IsNullOrEmpty(analyzerExePath)); Debug.Assert(!String.IsNullOrEmpty(arguments)); process = new System.Diagnostics.Process(); process.StartInfo.FileName = analyzerExePath; process.StartInfo.WorkingDirectory = Path.GetDirectoryName(analyzerExePath); process.StartInfo.Arguments = arguments; process.StartInfo.CreateNoWindow = true; // Set UseShellExecute to false for output redirection. process.StartInfo.UseShellExecute = false; // Redirect the standard output of the command. process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; // Set our event handler to asynchronously read the sort output. process.OutputDataReceived += new DataReceivedEventHandler(this.analyzerOutputHandler); process.ErrorDataReceived += new DataReceivedEventHandler(this.analyzerOutputHandler); _ = CPPCheckPluginPackage.AddTextToOutputWindowAsync("Starting analyzer with arguments: " + arguments + "\n"); var timer = Stopwatch.StartNew(); // Start the process. process.Start(); try { process.PriorityClass = ProcessPriorityClass.Idle; } catch (System.InvalidOperationException) { } onProgressUpdated(0); // Start the asynchronous read of the sort output stream. process.BeginOutputReadLine(); process.BeginErrorReadLine(); // Wait for analysis completion while (!process.WaitForExit(500)) { if (_terminateThread) { // finally block will run anyway and do the cleanup return; } } timer.Stop(); analysisFinished(arguments); if (process.ExitCode != 0) { _ = CPPCheckPluginPackage.AddTextToOutputWindowAsync(analyzerExePath + " has exited with code " + process.ExitCode.ToString() + "\n"); } else { double timeElapsed = Math.Round(timer.Elapsed.TotalSeconds, 3); _ = CPPCheckPluginPackage.AddTextToOutputWindowAsync("Analysis completed in " + timeElapsed.ToString() + " seconds\n"); } process.Close(); process = null; } catch (Exception ex) { DebugTracer.Trace(ex); } finally { onProgressUpdated(100); if (process != null) { try { process.Kill(); } catch (Exception ex) { DebugTracer.Trace(ex); } process.Dispose(); } } }