protected void RunScript(string aCommandName, ClangTidyOptionsView mTidyOptions = null, ClangTidyPredefinedChecksOptionsView mTidyChecks = null, ClangTidyCustomChecksOptionsView mTidyCustomChecks = null, ClangFormatOptionsView aClangFormatView = null) { try { mCompileTidyScriptBuilder = new ClangCompileTidyScript(); mCompileTidyScriptBuilder.ConstructParameters(mGeneralOptions, mTidyOptions, mTidyChecks, mTidyCustomChecks, aClangFormatView, DTEObj, VsEdition, VsVersion); string solutionPath = DTEObj.Solution.FullName; mOutputManager = new OutputManager(DTEObj); InitPowerShell(); ClearWindows(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kStart} {aCommandName}\n"); StatusBarHandler.Status(aCommandName + " started...", 1, vsStatusAnimation.vsStatusAnimationBuild, 1); foreach (var item in mItemsCollector.GetItems) { var script = mCompileTidyScriptBuilder.GetScript(item, solutionPath); if (!mCommandsController.Running) { break; } mOutputManager.Hierarchy = AutomationUtil.GetItemHierarchy(ServiceProvider, item); var process = mPowerShell.Invoke(script, mRunningProcesses); if (mOutputManager.MissingLlvm) { mOutputManager.AddMessage(ErrorParserConstants.kMissingLlvmMessage); break; } } if (!mOutputManager.EmptyBuffer) { mOutputManager.AddMessage(String.Join("\n", mOutputManager.Buffer)); } if (!mOutputManager.MissingLlvm) { mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kDone} {aCommandName}\n"); } if (mOutputManager.HasErrors) { ErrorManager.Instance.AddErrors(mOutputManager.Errors); } } catch (Exception) { mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kDone} {aCommandName}\n"); } finally { StatusBarHandler.Status(aCommandName + " finished", 0, vsStatusAnimation.vsStatusAnimationBuild, 0); } }
protected void RunScript(string aCommandName, TidyOptions mTidyOptions = null, TidyChecks mTidyChecks = null, TidyCustomChecks mTidyCustomChecks = null, ClangFormatPage aClangFormat = null) { try { mCompileTidyScriptBuilder = new ClangCompileTidyScript(); mCompileTidyScriptBuilder.ConstructParameters(mGeneralOptions, mTidyOptions, mTidyChecks, mTidyCustomChecks, aClangFormat, DTEObj, VsEdition, VsVersion); string solutionPath = DTEObj.Solution.FullName; mOutputManager = new OutputManager(DTEObj); InitPowerShell(); ClearWindows(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kStart} {aCommandName}\n"); foreach (var item in mItemsCollector.GetItems) { var script = mCompileTidyScriptBuilder.GetScript(item, solutionPath); if (!mCommandsController.Running) { break; } var process = mPowerShell.Invoke(script, mRunningProcesses); if (mOutputManager.MissingLlvm) { mOutputManager.AddMessage(ErrorParserConstants.kMissingLlvmMessage); break; } } if (!mOutputManager.EmptyBuffer) { mOutputManager.AddMessage(String.Join("\n", mOutputManager.Buffer)); } if (!mOutputManager.MissingLlvm) { mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kDone} {aCommandName}\n"); } if (mOutputManager.HasErrors) { mErrorsManager.AddErrors(mOutputManager.Errors); } } catch (Exception) { mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kDone} {aCommandName}\n"); } }
public int OnAfterOpenSolution(object aPUnkReserved, int aFNewSolution) { try { var dte = GetService(typeof(DTE)) as DTE2; mCommandsController = new CommandsController(this, dte); if (null == mTidyCmd) { mTidyCmd = new TidyCommand(this, CommandSet, CommandIds.kTidyId, mCommandsController); } if (null == mCompileCmd) { mCompileCmd = new CompileCommand(this, CommandSet, CommandIds.kCompileId, mCommandsController); } if (null == mClangFormatCmd) { mClangFormatCmd = new ClangFormatCommand(this, CommandSet, CommandIds.kClangFormat, mCommandsController); } if (null == mStopClangCmd) { mStopClangCmd = new StopClang(this, CommandSet, CommandIds.kStopClang, mCommandsController); } var generalOptions = (GeneralOptions)this.GetDialogPage(typeof(GeneralOptions)); var currentVersion = GetPackageVersion(); if (0 != string.Compare(generalOptions.Version, currentVersion)) { OutputManager outputManager = new OutputManager(dte); outputManager.Show(); outputManager.AddMessage($"🎉\tClang Power Tools was upgraded to v{currentVersion}\n" + $"\tCheck out what's new at http://www.clangpowertools.com/CHANGELOG"); generalOptions.Version = currentVersion; generalOptions.SaveSettingsToStorage(); } mBuildEvents.OnBuildBegin += mCommandsController.OnBuildBegin; mBuildEvents.OnBuildDone += mCommandsController.OnBuildDone; mBuildEvents.OnBuildDone += mCompileCmd.OnBuildDone; mCommandEvents.BeforeExecute += mCompileCmd.CommandEventsBeforeExecute; mCommandEvents.BeforeExecute += mTidyCmd.CommandEventsBeforeExecute; mRunningDocTableEvents.BeforeSave += mTidyCmd.OnBeforeSave; mRunningDocTableEvents.BeforeSave += mClangFormatCmd.OnBeforeSave; } catch (Exception) { } return(VSConstants.S_OK); }
public int OnAfterOpenSolution(object aPUnkReserved, int aFNewSolution) { try { mCommandsController = new CommandsController(this, mDte); InitializeCommands(); StatusBarHandler.Initialize(this); ErrorManager.Initialize(this); var generalOptions = (ClangGeneralOptionsView)this.GetDialogPage(typeof(ClangGeneralOptionsView)); var currentVersion = GetPackageVersion(); if (0 != string.Compare(generalOptions.Version, currentVersion)) { OutputManager outputManager = new OutputManager(mDte); outputManager.Show(); outputManager.AddMessage($"🎉\tClang Power Tools was upgraded to v{currentVersion}\n" + $"\tCheck out what's new at http://www.clangpowertools.com/CHANGELOG"); generalOptions.Version = currentVersion; generalOptions.SaveSettingsToStorage(); } mBuildEvents.OnBuildBegin += ErrorManager.Instance.OnBuildBegin; mBuildEvents.OnBuildBegin += mCommandsController.OnBuildBegin; mBuildEvents.OnBuildDone += mCommandsController.OnBuildDone; mBuildEvents.OnBuildDone += mCompileCmd.OnBuildDone; mCommandEvents.BeforeExecute += mCompileCmd.CommandEventsBeforeExecute; mCommandEvents.BeforeExecute += mTidyCmd.CommandEventsBeforeExecute; mRunningDocTableEvents.BeforeSave += mTidyCmd.OnBeforeSave; mRunningDocTableEvents.BeforeSave += mClangFormatCmd.OnBeforeSave; } catch (Exception) { } return(VSConstants.S_OK); }
public int OnAfterOpenSolution(object pUnkReserved, int fNewSolution) { //Load the rest of the commands when a solution is loaded if (null == mTidyCmd) { mTidyCmd = new TidyCommand(this, CommandSet, CommandIds.kTidyId); } if (null == mCompileCmd) { mCompileCmd = new CompileCommand(this, CommandSet, CommandIds.kCompileId); } if (null == mStopClang) { mStopClang = new StopClang(this, CommandSet, CommandIds.kStopClang); } var generalOptions = (GeneralOptions)this.GetDialogPage(typeof(GeneralOptions)); var currentVersion = GetPackageVersion(); if (0 != string.Compare(generalOptions.Version, currentVersion)) { var dte = GetService(typeof(DTE)) as DTE2; OutputManager outputManager = new OutputManager(dte); outputManager.Show(); outputManager.AddMessage($"🎉\tClang Power Tools was upgraded to v{currentVersion}\n" + $"\tCheck out what's new at http://www.clangpowertools.com/CHANGELOG"); generalOptions.Version = currentVersion; generalOptions.SaveSettingsToStorage(); } return(VSConstants.S_OK); }
private void ClearWindows() { mErrorsManager.Clear(); mOutputManager.Clear(); mOutputManager.Show(); }
/// <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 MenuItemCallback(object sender, EventArgs e) { //mCommandsController.Running = true; System.Threading.Tasks.Task.Run(() => { GeneralOptions generalOptions = (GeneralOptions)mPackage.GetDialogPage(typeof(GeneralOptions)); TidyOptions tidyPage = (TidyOptions)mPackage.GetDialogPage(typeof(TidyOptions)); ScriptBuiler scriptBuilder = new ScriptBuiler(); scriptBuilder.ConstructParameters(generalOptions, tidyPage, mVsEdition, mVsVersion); mItemsCollector = new ItemsCollector(mPackage); mItemsCollector.CollectSelectedFiles(mDte); mOutputManager = new OutputManager(mDte); PowerShellWrapper powerShell = new PowerShellWrapper(); powerShell.DataHandler += mOutputManager.OutputDataReceived; powerShell.DataErrorHandler += mOutputManager.OutputDataErrorReceived; mFileWatcher = new FileChangerWatcher(); try { mDte.Documents.SaveAll(); if (kVs15Version == mVsVersion) { Vs15SolutionLoader solutionLoader = new Vs15SolutionLoader(mPackage); solutionLoader.EnsureSolutionProjectsAreLoaded(); } using (var guard = new SilentFileChangerGuard()) { if (tidyPage.Fix) { WatchFiles(); SilentFiles(guard); } mOutputManager.Clear(); mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kStart} {OutputWindowConstants.kTidyCodeCommand}\n"); foreach (var item in mItemsCollector.GetItems) { string script = scriptBuilder.GetScript(item.Item1, item.Item1.GetName()); powerShell.Invoke(script); if (mOutputManager.MissingLlvm) { mOutputManager.AddMessage(ErrorParserConstants.kMissingLlvmMessage); break; } } if (!mOutputManager.EmptyBuffer) { mOutputManager.AddMessage(String.Join("\n", mOutputManager.Buffer)); } if (!mOutputManager.MissingLlvm) { mOutputManager.Show(); mOutputManager.AddMessage($"\n{OutputWindowConstants.kDone} {OutputWindowConstants.kTidyCodeCommand}\n"); } if (mOutputManager.HasErrors) { mErrorsManager.AddErrors(mOutputManager.Errors); } } } catch (Exception exception) { VsShellUtilities.ShowMessageBox(mPackage, exception.Message, "Error", OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } });//.ContinueWith(tsk => mCommandsController.AfterExecute()); ; }
private void ClearWindows() { ErrorManager.Instance.Clear(); mOutputManager.Clear(); mOutputManager.Show(); }
private void ClearWindows(string aCommandName) { mErrorsManager.Clear(); mOutputManager.Clear(); mOutputManager.Show(); }