Ejemplo n.º 1
0
 /**
  * @brief initialization WITHOUT Visual Studio services available.
  */
 public CTestAdapterPackage()
 {
     if (null != Instance)
     {
         /// @todo give some error here!
     }
     Instance = this;
     // main DTE object
     this._dte = (DTE)Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider.GetService(typeof(DTE));
     // basic solution events
     this._log = new CTestAdapterLog();
     this._sol = new SolutionEventListener(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
     this._sol.SolutionLoaded   += this.SolutionLoaded;
     this._sol.SolutionUnloaded += this.SolutionUnloaded;
     // cmake cache & cmake test file
     this._config            = new CTestAdapterConfig();
     this._cmakeCache        = new CMakeCache(this._log);
     this._cMakeCacheWatcher = new CMakeCacheWatcher(this._log);
     this._cMakeCacheWatcher.CacheFileChanged += this.OnCMakeCacheChanged;
     // test container discovery and management
     this._containerManager                        = new TestContainerManager(this, this._log);
     this._activeConfigurationTimer                = new System.Timers.Timer(CTestAdapterPackage.ConfigurationTimerIntervalMs);
     this._activeConfigurationTimer.Elapsed       += this.UpdateActiveConfiguration;
     this._containerManager.TestContainersChanged += this.OnTestContainersChanged;
     this.SetValidRelease();
 }
        public void Initialize(ISharePointProjectService projectService)
        {
            if (!projectService.IsSharePointInstalled)
            {
                return;
            }

            FileWatcherService.Initialize(projectService);
            SolutionEventListener.Initialize(projectService.ServiceProvider);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release
        /// only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            // Dispose of any event listeners.
            BuildProgressEventListener?.Dispose();
            DocumentEventListener?.Dispose();
            RunningDocumentTableEventListener?.Dispose();
            ShellEventListener?.Dispose();
            SolutionEventListener?.Dispose();
            TextEditorEventListener?.Dispose();
            WindowEventListener?.Dispose();
        }
Ejemplo n.º 4
0
        protected override void Initialize()
        {
            var solution = (IVsSolution)this.GetService(typeof(SVsSolution));

            this.solutionFilesService = new SolutionFilesService(solution);
            this.outputService = this.outputService ?? new OutputService(this);
            this.fileChangeService = this.fileChangeService ?? (IVsFileChangeEx)this.GetService(typeof(SVsFileChangeEx));

            var errorListProviderFacade = new GooseErrorListProviderFacade(this, this.solutionFilesService);
            var errorTaskHandler = new GooseErrorTaskHandler(errorListProviderFacade);
            this.errorReporter = new CommandErrorReporter(errorTaskHandler, new JsonCommandLogParser());

            var fileEventListenerFactory = new DefaultFileEventListenerFactory(solutionFilesService, this.fileChangeService, this.outputService, errorReporter);
            this.solutionEventListener = this.solutionEventListener ?? new SolutionEventListener(solution, fileEventListenerFactory, this.outputService);
            base.Initialize();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Register the package event listeners.
        /// </summary>
        /// <remarks>
        /// This must occur after the DTE service is available since many of the events are based
        /// off of the DTE object.
        /// </remarks>
        private void RegisterNonShellEventListeners()
        {
            // Create event listeners and register for events.
            var menuCommandService = MenuCommandService;

            if (menuCommandService != null)
            {
                var buildProgressToolWindowCommand     = _commands.OfType <BuildProgressToolWindowCommand>().First();
                var cleanupActiveCodeCommand           = _commands.OfType <CleanupActiveCodeCommand>().First();
                var collapseAllSolutionExplorerCommand = _commands.OfType <CollapseAllSolutionExplorerCommand>().First();
                var spadeToolWindowCommand             = _commands.OfType <SpadeToolWindowCommand>().First();

                var codeModelManager      = CodeModelManager.GetInstance(this);
                var settingsContextHelper = SettingsContextHelper.GetInstance(this);

                BuildProgressEventListener                       = new BuildProgressEventListener(this);
                BuildProgressEventListener.BuildBegin           += buildProgressToolWindowCommand.OnBuildBegin;
                BuildProgressEventListener.BuildProjConfigBegin += buildProgressToolWindowCommand.OnBuildProjConfigBegin;
                BuildProgressEventListener.BuildProjConfigDone  += buildProgressToolWindowCommand.OnBuildProjConfigDone;
                BuildProgressEventListener.BuildDone            += buildProgressToolWindowCommand.OnBuildDone;

                DocumentEventListener = new DocumentEventListener(this);
                DocumentEventListener.OnDocumentClosing += codeModelManager.OnDocumentClosing;

                RunningDocumentTableEventListener             = new RunningDocumentTableEventListener(this);
                RunningDocumentTableEventListener.BeforeSave += cleanupActiveCodeCommand.OnBeforeDocumentSave;
                RunningDocumentTableEventListener.AfterSave  += spadeToolWindowCommand.OnAfterDocumentSave;

                SolutionEventListener = new SolutionEventListener(this);
                SolutionEventListener.OnSolutionOpened += collapseAllSolutionExplorerCommand.OnSolutionOpened;
                SolutionEventListener.OnSolutionOpened += settingsContextHelper.OnSolutionOpened;
                SolutionEventListener.OnSolutionClosed += settingsContextHelper.OnSolutionClosed;
                SolutionEventListener.OnSolutionClosed += OnSolutionClosedShowStartPage;

                // Check if a solution has already been opened before CodeMaid was initialized.
                if (IDE.Solution != null && IDE.Solution.IsOpen)
                {
                    collapseAllSolutionExplorerCommand.OnSolutionOpened();
                }

                TextEditorEventListener = new TextEditorEventListener(this);
                TextEditorEventListener.OnLineChanged += codeModelManager.OnDocumentChanged;

                WindowEventListener = new WindowEventListener(this);
                WindowEventListener.OnWindowChange += spadeToolWindowCommand.OnWindowChange;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing">
        /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release
        /// only unmanaged resources.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            // Dispose of any event listeners.
            if (BuildProgressEventListener != null)
            {
                BuildProgressEventListener.Dispose();
            }

            if (DocumentEventListener != null)
            {
                DocumentEventListener.Dispose();
            }

            if (RunningDocumentTableEventListener != null)
            {
                RunningDocumentTableEventListener.Dispose();
            }

            if (ShellEventListener != null)
            {
                ShellEventListener.Dispose();
            }

            if (SolutionEventListener != null)
            {
                SolutionEventListener.Dispose();
            }

            if (TextEditorEventListener != null)
            {
                TextEditorEventListener.Dispose();
            }

            if (WindowEventListener != null)
            {
                WindowEventListener.Dispose();
            }
        }
        /// <summary>
        /// Register the package event listeners.
        /// </summary>
        /// <remarks>
        /// Every event listener registers VS events by itself.
        /// </remarks>
        private async Task RegisterEventListenersAsync()
        {
            var codeModelManager      = CodeModelManager.GetInstance(this);
            var settingsContextHelper = SettingsContextHelper.GetInstance(this);

            VSColorTheme.ThemeChanged += _ => ThemeManager.ApplyTheme();

            await BuildProgressEventListener.InitializeAsync(this);

            BuildProgressEventListener.Instance.BuildBegin           += BuildProgressToolWindowCommand.Instance.OnBuildBegin;
            BuildProgressEventListener.Instance.BuildProjConfigBegin += BuildProgressToolWindowCommand.Instance.OnBuildProjConfigBegin;
            BuildProgressEventListener.Instance.BuildProjConfigDone  += BuildProgressToolWindowCommand.Instance.OnBuildProjConfigDone;
            BuildProgressEventListener.Instance.BuildDone            += BuildProgressToolWindowCommand.Instance.OnBuildDone;

            await DocumentEventListener.InitializeAsync(this);

            DocumentEventListener.Instance.OnDocumentClosing += codeModelManager.OnDocumentClosing;

            await RunningDocumentTableEventListener.InitializeAsync(this);

            await SettingsMonitor.WatchAsync(s => s.Feature_SettingCleanupOnSave, on =>
            {
                if (on)
                {
                    RunningDocumentTableEventListener.Instance.BeforeSave += CleanupActiveCodeCommand.Instance.OnBeforeDocumentSave;
                }
                else
                {
                    RunningDocumentTableEventListener.Instance.BeforeSave -= CleanupActiveCodeCommand.Instance.OnBeforeDocumentSave;
                }

                return(Task.CompletedTask);
            });

            await SettingsMonitor.WatchAsync(s => s.Feature_SpadeToolWindow, on =>
            {
                if (on)
                {
                    RunningDocumentTableEventListener.Instance.AfterSave += SpadeToolWindowCommand.Instance.OnAfterDocumentSave;
                }
                else
                {
                    RunningDocumentTableEventListener.Instance.AfterSave -= SpadeToolWindowCommand.Instance.OnAfterDocumentSave;
                }

                return(Task.CompletedTask);
            });

            await SolutionEventListener.InitializeAsync(this);

            await SettingsMonitor.WatchAsync(s => s.Feature_CollapseAllSolutionExplorer, on =>
            {
                if (on)
                {
                    SolutionEventListener.Instance.OnSolutionOpened += CollapseAllSolutionExplorerCommand.Instance.OnSolutionOpened;
                }
                else
                {
                    SolutionEventListener.Instance.OnSolutionOpened -= CollapseAllSolutionExplorerCommand.Instance.OnSolutionOpened;
                }

                return(Task.CompletedTask);
            });

            SolutionEventListener.Instance.OnSolutionOpened += settingsContextHelper.OnSolutionOpened;
            SolutionEventListener.Instance.OnSolutionClosed += settingsContextHelper.OnSolutionClosed;
            SolutionEventListener.Instance.OnSolutionClosed += OnSolutionClosedShowStartPage;

            await TextEditorEventListener.InitializeAsync(this);

            TextEditorEventListener.Instance.OnLineChanged += codeModelManager.OnDocumentChanged;

            await WindowEventListener.InitializeAsync(this);

            WindowEventListener.Instance.OnWindowChange += SpadeToolWindowCommand.Instance.OnWindowChange;

            // Check if a solution has already been opened before CodeMaid was initialized.
            if (IDE.Solution?.IsOpen == true)
            {
                SolutionEventListener.Instance.FireSolutionOpenedEvent();
            }
        }