public void RunClangCompile(int aCommandId) { if (mCommandsController.Running) { return; } mCommandsController.Running = true; var task = System.Threading.Tasks.Task.Run(() => { try { if (VsServiceProvider.TryGetService(typeof(DTE), out object dte)) { DocumentsHandler.SaveActiveDocuments(); AutomationUtil.SaveDirtyProjects((dte as DTE2).Solution); } CollectSelectedItems(false, ScriptConstants.kAcceptedFileExtensions); RunScript(aCommandId); } catch (Exception exception) { VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } }).ContinueWith(tsk => mCommandsController.OnAfterClangCommand()); }
public void RunClangTidy(int aCommandId) { if (mCommandsController.Running) { return; } mCommandsController.Running = true; var task = System.Threading.Tasks.Task.Run(() => { try { DocumentsHandler.SaveActiveDocuments(); if (!VsServiceProvider.TryGetService(typeof(DTE), out object dte)) { return; } var dte2 = dte as DTE2; AutomationUtil.SaveDirtyProjects(dte2.Solution); CollectSelectedItems(false, ScriptConstants.kAcceptedFileExtensions); using (var silentFileController = new SilentFileChangerController()) { using (var fileChangerWatcher = new FileChangerWatcher()) { var tidySettings = SettingsProvider.GetSettingsPage(typeof(ClangTidyOptionsView)) as ClangTidyOptionsView; if (CommandIds.kTidyFixId == aCommandId || tidySettings.AutoTidyOnSave) { fileChangerWatcher.OnChanged += FileOpener.Open; string solutionFolderPath = dte2.Solution.FullName .Substring(0, dte2.Solution.FullName.LastIndexOf('\\')); fileChangerWatcher.Run(solutionFolderPath); FilePathCollector fileCollector = new FilePathCollector(); var filesPath = fileCollector.Collect(mItemsCollector.GetItems).ToList(); silentFileController.SilentFiles(filesPath); silentFileController.SilentFiles(dte2.Documents); } RunScript(aCommandId); } } } catch (Exception exception) { VsShellUtilities.ShowMessageBox(AsyncPackage, exception.Message, "Error", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } }).ContinueWith(tsk => DispatcherHandler.Invoke(() => mCommandsController.OnAfterClangCommand(), DispatcherPriority.Background)); }