/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); if (TidyControl.RunningTidy != null) { TidyControl.RunningTidy.Cancel(); m_output.Write(Resources.Cancelled + "\n"); return; } m_output = new ExtensionOutput(package, "CLang Output", ExtensionOutput.DefaultOutputWindowGuid); var mySettings = new Settings <PropertyPage.PropertyPage>(package); var clangPath = mySettings.GetPage().CLangTidy; var compileCommand = mySettings.GetPage().CompileCommand; if (clangPath == null || clangPath.Length == 0 || compileCommand == null || compileCommand.Length == 0) { TidyControl.CancelAndShowHelp(package); return; } var clangOptions = mySettings.GetPage().AnalysisOptions; if (clangOptions == null) { clangOptions = ""; } var selection = m_cppProject.GetVCFilesFromSelected(); Dictionary <string, List <string> > projectsToFiles = new Dictionary <string, List <string> >(); foreach (var(vcFile, project) in selection) { var compileDatabaseDirectory = new FileInfo(project.FileName).DirectoryName; var file = vcFile.FullPath; if (!projectsToFiles.ContainsKey(compileDatabaseDirectory)) { projectsToFiles.Add(compileDatabaseDirectory, new List <string>()); } if (!new FileInfo(CLangHelpers.GetCompileDatabasePath(compileDatabaseDirectory)).Exists) { CLangHelpers.CreateCompilationDatabase(package, compileCommand); } projectsToFiles[compileDatabaseDirectory].Add(file); } TidyControl.RunningTidy = new CancellationTokenSource(); var cancel = TidyControl.RunningTidy.Token; var errorProvider = new AnalysisOutputParser(selection.Count); var executeShell = new ExecuteShellCommand(m_output, errorProvider); _ = ExecuteTidySetAsync(executeShell, clangPath, projectsToFiles, clangOptions, cancel); }
/// <summary> /// Initializes a new instance of the <see cref="RunTidy"/> class. /// Adds our command handlers for menu (commands must exist in the command table file) /// </summary> /// <param name="package">Owner package, not null.</param> /// <param name="commandService">Command service to add command to, not null.</param> private RunTidy(AsyncPackage package, OleMenuCommandService commandService, IMessageGenerator errorService) { this.package = package ?? throw new ArgumentNullException(nameof(package)); commandService = commandService ?? throw new ArgumentNullException(nameof(commandService)); m_output = new ExtensionOutput(package, "CLang Output", ExtensionOutput.DefaultOutputWindowGuid); var menuCommandID = new CommandID(CommandSet, CommandId); menuItem = new OleMenuCommand(this.Execute, menuCommandID); menuItem.BeforeQueryStatus += new EventHandler(OnBeforeQueryStatus); commandService.AddCommand(menuItem); m_errorService = errorService; var dteService = package.GetService <EnvDTE.DTE, EnvDTE.DTE>(); m_cppSupport = new CppProject(dteService); }
void listPropertySheetCollection(ExtensionOutput output, dynamic collection, int i) { ThreadHelper.ThrowIfNotOnUIThread(); foreach (var property in collection) { if (property is VCPropertySheet sheet) { for (int step = 0; step < i; ++step) { output.Write(" "); } output.Write("Property Sheet " + sheet.Name + "\n"); if (sheet.PropertySheets != null) { listPropertySheetCollection(output, sheet.PropertySheets, i + 1); } if (sheet.Tools != null) { listPropertySheetCollection(output, sheet.Tools, i + 1); } } } }
public CollectProjectFilesVisitor(ExtensionOutput output, CppProject project) { m_output = output; m_project = project; }