Esempio n. 1
0
                public IncrementalAnalyzerProcessor(
                    IAsynchronousOperationListener listener,
                    IEnumerable <Lazy <IIncrementalAnalyzerProvider, IncrementalAnalyzerProviderMetadata> > analyzerProviders,
                    Registration registration,
                    int highBackOffTimeSpanInMs, int normalBackOffTimeSpanInMs, int lowBackOffTimeSpanInMs, CancellationToken shutdownToken)
                {
                    _logAggregator = new LogAggregator();

                    _listener     = listener;
                    _registration = registration;
                    _cacheService = registration.GetService <IProjectCacheService>();

                    _lazyDiagnosticAnalyzerService = new Lazy <IDiagnosticAnalyzerService>(() => GetDiagnosticAnalyzerService(analyzerProviders));

                    var analyzersGetter = new AnalyzersGetter(analyzerProviders);

                    // create analyzers lazily.
                    var lazyActiveFileAnalyzers = new Lazy <ImmutableArray <IIncrementalAnalyzer> >(() => GetIncrementalAnalyzers(_registration, analyzersGetter, onlyHighPriorityAnalyzer: true));
                    var lazyAllAnalyzers        = new Lazy <ImmutableArray <IIncrementalAnalyzer> >(() => GetIncrementalAnalyzers(_registration, analyzersGetter, onlyHighPriorityAnalyzer: false));

                    // event and worker queues
                    _documentTracker = _registration.GetService <IDocumentTrackingService>();

                    var globalNotificationService = _registration.GetService <IGlobalOperationNotificationService>();

                    _highPriorityProcessor   = new HighPriorityProcessor(listener, this, lazyActiveFileAnalyzers, highBackOffTimeSpanInMs, shutdownToken);
                    _normalPriorityProcessor = new NormalPriorityProcessor(listener, this, lazyAllAnalyzers, globalNotificationService, normalBackOffTimeSpanInMs, shutdownToken);
                    _lowPriorityProcessor    = new LowPriorityProcessor(listener, this, lazyAllAnalyzers, globalNotificationService, lowBackOffTimeSpanInMs, shutdownToken);
                }
                private static ImmutableArray <IIncrementalAnalyzer> GetIncrementalAnalyzers(
                    Registration registration,
                    AnalyzersGetter analyzersGetter,
                    bool onlyHighPriorityAnalyzer
                    )
                {
                    var orderedAnalyzers = analyzersGetter.GetOrderedAnalyzers(
                        registration.Workspace,
                        onlyHighPriorityAnalyzer
                        );

                    SolutionCrawlerLogger.LogAnalyzers(
                        registration.CorrelationId,
                        registration.Workspace,
                        orderedAnalyzers,
                        onlyHighPriorityAnalyzer
                        );
                    return(orderedAnalyzers);
                }
Esempio n. 3
0
                public IncrementalAnalyzerProcessor(
                    IAsynchronousOperationListener listener,
                    IEnumerable <Lazy <IIncrementalAnalyzerProvider, IncrementalAnalyzerProviderMetadata> > analyzerProviders,
                    bool initializeLazily,
                    Registration registration,
                    TimeSpan highBackOffTimeSpan,
                    TimeSpan normalBackOffTimeSpan,
                    TimeSpan lowBackOffTimeSpan,
                    CancellationToken shutdownToken)
                {
                    _listener     = listener;
                    _registration = registration;
                    _cacheService = registration.Workspace.Services.GetService <IProjectCacheService>();

                    _lazyDiagnosticAnalyzerService = new Lazy <IDiagnosticAnalyzerService?>(() => GetDiagnosticAnalyzerService(analyzerProviders));

                    var analyzersGetter = new AnalyzersGetter(analyzerProviders);

                    // create analyzers lazily.
                    var lazyActiveFileAnalyzers = new Lazy <ImmutableArray <IIncrementalAnalyzer> >(() => GetIncrementalAnalyzers(_registration, analyzersGetter, onlyHighPriorityAnalyzer: true));
                    var lazyAllAnalyzers        = new Lazy <ImmutableArray <IIncrementalAnalyzer> >(() => GetIncrementalAnalyzers(_registration, analyzersGetter, onlyHighPriorityAnalyzer: false));

                    if (!initializeLazily)
                    {
                        // realize all analyzer right away
                        _ = lazyActiveFileAnalyzers.Value;
                        _ = lazyAllAnalyzers.Value;
                    }

                    // event and worker queues
                    _documentTracker = _registration.Workspace.Services.GetRequiredService <IDocumentTrackingService>();

                    var globalNotificationService = _registration.Workspace.Services.GetRequiredService <IGlobalOperationNotificationService>();

                    _highPriorityProcessor   = new HighPriorityProcessor(listener, this, lazyActiveFileAnalyzers, highBackOffTimeSpan, shutdownToken);
                    _normalPriorityProcessor = new NormalPriorityProcessor(listener, this, lazyAllAnalyzers, globalNotificationService, normalBackOffTimeSpan, shutdownToken);
                    _lowPriorityProcessor    = new LowPriorityProcessor(listener, this, lazyAllAnalyzers, globalNotificationService, lowBackOffTimeSpan, shutdownToken);
                }