private void BeforeExecuteClangCompile(string aGuid, int aId) { var generalOptions = SettingsProvider.GetSettingsPage(typeof(ClangGeneralOptionsView)) as ClangGeneralOptionsView; if (null == generalOptions || false == generalOptions.ClangCompileAfterVsCompile) { return; } string commandName = GetCommandName(aGuid, aId); if (0 != string.Compare("Build.Compile", commandName)) { return; } CompileCommand.Instance.VsCompileFlag = true; }
private static string CreatePathEnvironmentVariable() { var path = Environment.GetEnvironmentVariable("Path"); var settingsProvider = new SettingsProvider(); var llvmVersion = settingsProvider.GetCompilerSettingsModel().LlvmVersion; if (string.IsNullOrEmpty(llvmVersion)) { return(path); } var paths = path.Split(';').ToList(); paths.RemoveAt(paths.Count - 1); paths.RemoveAll(ContainsLlvm); paths.Add(GetUsedLlvmVersionPath(llvmVersion)); return(String.Join(";", paths)); }
private void BeforeSaveClangTidy() { if (false == mSaveCommandWasGiven) // The save event was not triggered by Save File or SaveAll commands { return; } var tidyOption = SettingsProvider.GetSettingsPage(typeof(ClangTidyOptionsView)) as ClangTidyOptionsView; if (false == tidyOption.AutoTidyOnSave) // The clang-tidy on save option is disable { return; } if (true == Running) // Clang compile/tidy command is running { return; } TidyCommand.Instance.RunClangTidy(CommandIds.kTidyFixId); mSaveCommandWasGiven = false; }
private void BeforeSaveClangFormat(Document aDocument) { var clangFormatOptionPage = SettingsProvider.GetSettingsPage(typeof(ClangFormatOptionsView)) as ClangFormatOptionsView; var tidyOptionPage = SettingsProvider.GetSettingsPage(typeof(ClangTidyOptionsView)) as ClangTidyOptionsView; if (CurrentCommand == CommandIds.kTidyFixId && Running && tidyOptionPage.FormatAfterTidy && clangFormatOptionPage.EnableFormatOnSave) { mDocument = aDocument; mFormatAfterTidyFlag = true; return; } if (false == clangFormatOptionPage.EnableFormatOnSave) { return; } if (false == Vsix.IsDocumentDirty(aDocument) && false == mFormatAfterTidyFlag) { return; } if (false == FileHasExtension(aDocument.FullName, clangFormatOptionPage.FileExtensions)) { return; } if (true == SkipFile(aDocument.FullName, clangFormatOptionPage.FilesToIgnore)) { return; } var option = (SettingsProvider.GetSettingsPage(typeof(ClangFormatOptionsView)) as ClangFormatOptionsView).Clone(); option.FallbackStyle = ClangFormatFallbackStyle.none; ClangFormatCommand.Instance.FormatDocument(aDocument, option); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Switches to the UI thread in order to consume some services used in command initialization await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await RegisterVsServicesAsync(); mCommandController = new CommandController(this); CommandTestUtility.CommandController = mCommandController; var vsOutputWindow = VsServiceProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; mOutputWindowController = new OutputWindowController(); mOutputWindowController.Initialize(this, vsOutputWindow); mRunningDocTableEvents = new RunningDocTableEvents(this); mErrorWindowController = new ErrorWindowController(this); #region Get Pointer to IVsSolutionEvents if (VsServiceProvider.TryGetService(typeof(SVsSolution), out object vsSolutionService)) { var vsSolution = vsSolutionService as IVsSolution; UnadviseSolutionEvents(vsSolution); AdviseSolutionEvents(vsSolution); } #endregion // Get the build and command events from DTE if (VsServiceProvider.TryGetService(typeof(DTE), out object dte)) { var dte2 = dte as DTE2; mBuildEvents = dte2.Events.BuildEvents; mCommandEvents = dte2.Events.CommandEvents; mDteEvents = dte2.Events.DTEEvents; } DispatcherHandler.Initialize(dte as DTE2); SettingsProvider.Initialize(this); // Detect the first install if (string.IsNullOrWhiteSpace(SettingsProvider.GeneralSettings.Version)) { ShowToolbare(); // Show the toolbar on the first install } if (string.IsNullOrWhiteSpace(SettingsProvider.GeneralSettings.Version) || 0 > string.Compare(SettingsProvider.GeneralSettings.Version, "5.0.0")) { System.Diagnostics.Process.Start(new ProcessStartInfo("https://clangpowertools.com/blog/future-of-clang-power-tools.html")); } var currentVersion = PackageUtility.GetVersion(); if (!string.IsNullOrWhiteSpace(currentVersion) && 0 > string.Compare(SettingsProvider.GeneralSettings.Version, currentVersion)) { mOutputWindowController.Clear(); mOutputWindowController.Show(); mOutputWindowController.Write($"🎉\tClang Power Tools was upgraded to v{currentVersion}\n" + $"\tCheck out what's new at http://www.clangpowertools.com/CHANGELOG"); SettingsProvider.GeneralSettings.Version = currentVersion; } SettingsHandler.SaveGeneralSettings(); await mCommandController.InitializeCommandsAsync(this); mLicenseController = new LicenseController(); RegisterToEvents(); await mLicenseController.CheckLicenseAsync(); await base.InitializeAsync(cancellationToken, progress); }
public GeneralSettingsViewModel() { var settingsProvider = new SettingsProvider(); generalSettingsModel = settingsProvider.GetGeneralSettingsModel(); }
public FormatSettingsViewModel() { var settingsProvider = new SettingsProvider(); formatModel = settingsProvider.GetFormatSettingsModel(); }
public CompilerSettingsViewModel() { var settingsProvider = new SettingsProvider(); compilerModel = settingsProvider.GetCompilerSettingsModel(); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Switches to the UI thread in order to consume some services used in command initialization await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await RegisterVsServices(); mCommandsController = new CommandsController(this); SettingsProvider.Initialize(this); var vsOutputWindow = VsServiceProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; mOutputWindowController = new OutputWindowController(); mOutputWindowController.Initialize(this, vsOutputWindow); //mCommandsController.ClangCommandMessageEvent += mOutputWindowController.Write; //PowerShellWrapper.DataHandler += mOutputWindowController.OutputDataReceived; //PowerShellWrapper.DataErrorHandler += mOutputWindowController.OutputDataErrorReceived; //PowerShellWrapper.ExitedHandler += mOutputWindowController.ClosedDataConnection; mRunningDocTableEvents = new RunningDocTableEvents(this); mErrorWindowController = new ErrorWindowController(this); //mOutputWindowController.ErrorDetectedEvent += mErrorWindowController.OnErrorDetected; #region Get Pointer to IVsSolutionEvents if (VsServiceProvider.TryGetService(typeof(SVsSolution), out object vsSolutionService)) { var vsSolution = vsSolutionService as IVsSolution; UnadviseSolutionEvents(vsSolution); AdviseSolutionEvents(vsSolution); } #endregion // Get the build and command events from DTE if (VsServiceProvider.TryGetService(typeof(DTE), out object dte)) { var dte2 = dte as DTE2; mBuildEvents = dte2.Events.BuildEvents; mCommandEvents = dte2.Events.CommandEvents; mDteEvents = dte2.Events.DTEEvents; } DispatcherHandler.Initialize(dte as DTE2); // Get the general clang option page var generalSettings = SettingsProvider.GetSettingsPage(typeof(ClangGeneralOptionsView)) as ClangGeneralOptionsView; // Detect the first install if (string.IsNullOrWhiteSpace(generalSettings.Version)) { ShowToolbare(); // Show the toolbar on the first install } var currentVersion = GetPackageVersion(); if (0 > string.Compare(generalSettings.Version, currentVersion)) { mOutputWindowController.Clear(); mOutputWindowController.Show(); mOutputWindowController.Write($"🎉\tClang Power Tools was upgraded to v{currentVersion}\n" + $"\tCheck out what's new at http://www.clangpowertools.com/CHANGELOG"); generalSettings.Version = currentVersion; generalSettings.SaveSettingsToStorage(); } await mCommandsController.InitializeAsyncCommands(this); //mCommandsController.HierarchyDetectedEvent += mOutputWindowController.OnFileHierarchyDetected; //mOutputWindowController.MissingLlvmEvent += mCommandsController.OnMissingLLVMDetected; //RegisterToCPTEvents(); //RegisterToVsEvents(); RegisterToEvents(); await base.InitializeAsync(cancellationToken, progress); }