/// <summary>
        /// make sure solution cralwer is registered for the given workspace.
        /// </summary>
        /// <param name="workspace"><see cref="Workspace"/> this solution crawler runs for</param>
        /// <param name="initializeLazily">
        /// when true, solution crawler will be initialized when there is the first workspace event fired.
        /// otherwise, it will be initialized when workspace is registered right away.
        /// something like "Build" will use initializeLazily:false to make sure diagnostic analyzer engine (incremental analyzer)
        /// is initialized. otherwise, if build is called before workspace is fully populated, we will think some errors from build
        /// doesn't belong to us since diagnostic analyzer engine is not there yet and
        /// let project system to take care of these unknown errors.
        /// </param>
        public void EnsureRegistration(Workspace workspace, bool initializeLazily)
        {
            Contract.ThrowIfNull(workspace.Kind);

            var correlationId = LogAggregator.GetNextId();

            lock (_gate)
            {
                if (_documentWorkCoordinatorMap.ContainsKey(workspace))
                {
                    // already registered.
                    return;
                }

                var coordinator = new WorkCoordinator(
                    _listener,
                    GetAnalyzerProviders(workspace.Kind),
                    initializeLazily,
                    new Registration(correlationId, workspace, _progressReporter));

                _documentWorkCoordinatorMap.Add(workspace, coordinator);
            }

            SolutionCrawlerLogger.LogRegistration(correlationId, workspace);
        }
Esempio n. 2
0
        private DiagnosticIncrementalAnalyzer CreateIncrementalAnalyzerCallback(Workspace workspace)
        {
            // subscribe to active context changed event for new workspace
            workspace.DocumentActiveContextChanged += OnDocumentActiveContextChanged;

            return(new DiagnosticIncrementalAnalyzer(this, LogAggregator.GetNextId(), workspace, AnalyzerInfoCache, _hostDiagnosticUpdateSource));
        }
Esempio n. 3
0
            public IncrementalAnalyzerDelegatee(DiagnosticAnalyzerService owner, Workspace workspace, HostAnalyzerManager hostAnalyzerManager, AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
                : base(owner, workspace, hostAnalyzerManager, hostDiagnosticUpdateSource)
            {
                var v2CorrelationId = LogAggregator.GetNextId();

                _engineV2 = new EngineV2.DiagnosticIncrementalAnalyzer(owner, v2CorrelationId, workspace, hostAnalyzerManager, hostDiagnosticUpdateSource);
            }
Esempio n. 4
0
        private DiagnosticIncrementalAnalyzer CreateIncrementalAnalyzerCallback(Workspace workspace)
        {
            // subscribe to active context changed event for new workspace
            workspace.DocumentActiveContextChanged += OnDocumentActiveContextChanged;

            var correlationId = LogAggregator.GetNextId();

            return(new DiagnosticIncrementalAnalyzer(this, correlationId, workspace, _analyzerManager));
        }
        private DiagnosticIncrementalAnalyzer CreateIncrementalAnalyzerCallback(Workspace workspace)
        {
            Contract.ThrowIfTrue(_workspaceAnalyzers.IsDefault);

            // subscribe to active context changed event for new workspace
            workspace.DocumentActiveContextChanged += OnDocumentActiveContextChanged;

            var correlationId = LogAggregator.GetNextId();

            return(new DiagnosticIncrementalAnalyzer(this, correlationId, workspace, _workspaceAnalyzers));
        }
            public IncrementalAnalyzerDelegatee(DiagnosticAnalyzerService owner, Workspace workspace, WorkspaceAnalyzerManager workspaceAnalyzerManager, AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
                : base(workspace, hostDiagnosticUpdateSource)
            {
                _workspaceAnalyzerManager = workspaceAnalyzerManager;
                _owner = owner;

                var v1CorrelationId = LogAggregator.GetNextId();

                _engineV1 = new EngineV1.DiagnosticIncrementalAnalyzer(_owner, v1CorrelationId, workspace, _workspaceAnalyzerManager, hostDiagnosticUpdateSource);

                var v2CorrelationId = LogAggregator.GetNextId();

                _engineV2 = new EngineV2.DiagnosticIncrementalAnalyzer(_owner, v2CorrelationId, workspace, _workspaceAnalyzerManager, hostDiagnosticUpdateSource);
            }
            public IncrementalAnalyzerDelegatee(DiagnosticAnalyzerService owner, Workspace workspace, AnalyzerManager analyzerManager)
            {
                _workspace       = workspace;
                _analyzerManager = analyzerManager;
                _owner           = owner;

                var v1CorrelationId = LogAggregator.GetNextId();

                _engineV1 = new EngineV1.DiagnosticIncrementalAnalyzer(_owner, v1CorrelationId, _workspace, _analyzerManager);

                var v2CorrelationId = LogAggregator.GetNextId();

                _engineV2 = new EngineV2.DiagnosticIncrementalAnalyzer(_owner, v2CorrelationId, _workspace, _analyzerManager);
            }
Esempio n. 8
0
        public void Register(Workspace workspace)
        {
            var correlationId = LogAggregator.GetNextId();

            lock (this.gate)
            {
                if (this.documentWorkCoordinatorMap.ContainsKey(workspace))
                {
                    // already registered.
                    return;
                }

                var coordinator = new WorkCoordinator(
                    this.listener, this.analyzerProviders.Where(l => l.Metadata.WorkspaceKinds.Any(wk => wk == workspace.Kind)), correlationId, workspace);

                this.documentWorkCoordinatorMap.Add(workspace, coordinator);
            }

            SolutionCrawlerLogger.LogRegistration(correlationId, workspace);
        }
        public void Register(Workspace workspace)
        {
            var correlationId = LogAggregator.GetNextId();

            lock (_gate)
            {
                if (_documentWorkCoordinatorMap.ContainsKey(workspace))
                {
                    // already registered.
                    return;
                }

                var coordinator = new WorkCoordinator(
                    _listener,
                    GetAnalyzerProviders(workspace),
                    new Registration(correlationId, workspace, _progressReporter));

                _documentWorkCoordinatorMap.Add(workspace, coordinator);
            }

            SolutionCrawlerLogger.LogRegistration(correlationId, workspace);
        }
Esempio n. 10
0
 public static int GetNextId()
 {
     return(LogAggregator.GetNextId());
 }