Пример #1
0
 public VSSolutionEventsActions(IndexingWorkflow indexingWorkflow)
 {
     _indexingWorkflow = indexingWorkflow;
 }
Пример #2
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            NLogConfigurationService.ConfigureNLog();
            NLogConfigurationService.ConfigureMiniProfilerWithDefaultLogger();

            Logger logger = LogManager.GetLogger("error");

            logger.Info("Extension initalizing");

            EnvDTE = await GetServiceAsync(typeof(DTE)) as DTE2;

            Assumes.Present(EnvDTE);

            DteSemaphore.Release();

            Storage = new PackageStorage();

            var componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel;

            Assumes.Present(componentModel);

            //Initialize public components, initialize instances that are dependent on any component
            TextManager = await GetServiceAsync(typeof(SVsTextManager)) as IVsTextManager;

            EditorAdaptersFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>();

            DocumentNavigationInstance.InjectDTE(EnvDTE);
            //Prepare package events
            var indexingQueue   = new ProjectIndexingQueue();
            var workspaceEvents = new WorkspaceEvents(indexingQueue);

            Workspace = componentModel.GetService <VisualStudioWorkspace>();
            Workspace.WorkspaceChanged += (s, e) => ThreadHelper.JoinableTaskFactory.RunAsync(async() => await workspaceEvents.WorkspaceChangedAsync(s, e));

            var indexingWorkflow = new IndexingWorkflow(Storage.IndexingWorkflowOptions, new ProjectItemRetreiver(EnvDTE), Storage);

            _envDteEvents = EnvDTE.Events as Events2;
            if (_envDteEvents != null)
            {
                ProjectItemEventsActions projectItemEvents = new ProjectItemEventsActions();
                _envDteProjectItemsEvents              = _envDteEvents.ProjectItemsEvents;
                _envDteProjectItemsEvents.ItemAdded   += projectItemEvents.ItemAdded;
                _envDteProjectItemsEvents.ItemRemoved += projectItemEvents.ItemRemoved;
                _envDteProjectItemsEvents.ItemRenamed += projectItemEvents.ItemRenamed;

                EventHandlers.BuildEventsActions buildEvents = new EventHandlers.BuildEventsActions();
                _buildEvents = _envDteEvents.BuildEvents;
                _buildEvents.OnBuildBegin += buildEvents.OnBuildBegin;
            }

            var solutionEventsActions = new VSSolutionEventsActions(indexingWorkflow);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            await ResultWindowCommand.InitializeAsync(this);

            OutputWindowLogger.Init(await GetServiceAsync(typeof(SVsOutputWindow)) as SVsOutputWindow);
            IStatusBar = await GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;

            var svsSolution = await GetServiceAsync(typeof(SVsSolution));

            Solution = svsSolution as IVsSolution;
            Assumes.Present(Solution);

            await HandleSolutionAsync(svsSolution, solutionEventsActions, indexingQueue);


            _solutionEventsHandler = new SolutionEventsHandler(solutionEventsActions);
            Solution.AdviseSolutionEvents(_solutionEventsHandler, out _solutionEventsCookie);

            await Goto.InitializeAsync(this);

            await RenameModalWindowCommand.InitializeAsync(this);

            await RenameCommand.InitializeAsync(this);

            await PrettyPrintCommand.InitializeAsync(this);
        }