public void Show()
 {
     DispatcherHandler.BeginInvoke(() =>
     {
         mOutputWindow.Show(mDte);
     });
 }
 public void AfterExecute()
 {
     DispatcherHandler.Invoke(() =>
     {
         Running = false;
     });
 }
 public void Clear()
 {
     DispatcherHandler.BeginInvoke(() =>
     {
         mErrorWindow.Clear();
     });
 }
 public void RemoveErrors(IVsHierarchy aHierarchy)
 {
     DispatcherHandler.BeginInvoke(() =>
     {
         mErrorWindow.SuspendRefresh();
         mErrorWindow.RemoveErrors(aHierarchy);
         mErrorWindow.ResumeRefresh();
     });
 }
Exemple #5
0
 public void Show()
 {
     using (OutputWindow outputWindow = new OutputWindow(mDte))
     {
         DispatcherHandler.BeginInvoke(() =>
         {
             outputWindow.Show(mDte);
         });
     }
 }
 public void AddMessage(string aMessage)
 {
     DispatcherHandler.BeginInvoke(() =>
     {
         if (String.IsNullOrWhiteSpace(aMessage))
         {
             return;
         }
         mOutputWindow.Write(aMessage);
     });
 }
        public static void Animation(vsStatusAnimation aAnimation, int aEnableAnimation)
        {
            DispatcherHandler.BeginInvoke(() =>
            {
                // Use the standard Visual Studio icon for building.
                object icon = (short)Microsoft.VisualStudio.Shell.Interop.Constants.SBAI_Build;

                // Display the icon in the Animation region.
                mStatusBar.Animation(aEnableAnimation, ref icon);
            });
        }
Exemple #8
0
 public void AddErrors(IEnumerable <TaskError> aErrors)
 {
     DispatcherHandler.BeginInvoke(() =>
     {
         foreach (TaskError error in aErrors)
         {
             mErrorWindow.AddError(error);
         }
         mErrorWindow.Show();
     });
 }
        public void AddError(TaskError aError)
        {
            DispatcherHandler.BeginInvoke(() =>
            {
                mErrorWindow.SuspendRefresh();

                if (!String.IsNullOrWhiteSpace(aError.Description))
                {
                    mErrorWindow.AddError(aError);
                }

                mErrorWindow.Show();
                mErrorWindow.ResumeRefresh();
            });
        }
        /// <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);
        }
Exemple #11
0
        /// <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);
        }
Exemple #12
0
        public int OnAfterOpenSolution(object aPUnkReserved, int aFNewSolution)
        {
            try
            {
                var dte = GetService(typeof(DTE)) as DTE2;
                mCommandsController = new CommandsController(this, dte);


                if (null == mCompileCmd)
                {
                    mCompileCmd = new CompileCommand(this, CommandSet, CommandIds.kCompileId, mCommandsController);
                }

                if (null == mTidyCmd)
                {
                    mTidyCmd = new TidyCommand(this, CommandSet, CommandIds.kTidyId, mCommandsController);
                }

                if (null == mClangFormatCmd)
                {
                    mClangFormatCmd = new ClangFormatCommand(this, CommandSet, CommandIds.kClangFormat, mCommandsController);
                }

                if (null == mStopClangCmd)
                {
                    mStopClangCmd = new StopClang(this, CommandSet, CommandIds.kStopClang, mCommandsController);
                }

                DispatcherHandler.Initialize(dte);
                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(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 += 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);
        }