Beispiel #1
0
        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);
        }
Beispiel #2
0
        private void InitializeCommands()
        {
            if (null == mCompileCmd)
            {
                mCompileCmd = new CompileCommand(mCommandsController, mSolution, mDte, this, CommandSet, CommandIds.kCompileId);
            }

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

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

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