private DiagnosticTaggerWrapper(TestWorkspace workspace, DiagnosticAnalyzerService analyzerService, IDiagnosticUpdateSource updateSource)
        {
            if (updateSource == null)
            {
                updateSource = analyzerService;
            }

            this.workspace = workspace;

            this.registrationService = workspace.Services.GetService<ISolutionCrawlerRegistrationService>();
            registrationService.Register(workspace);

            this.asyncListener = new AsynchronousOperationListener();
            var listeners = AsynchronousOperationListener.CreateListeners(
                ValueTuple.Create(FeatureAttribute.DiagnosticService, asyncListener),
                ValueTuple.Create(FeatureAttribute.ErrorSquiggles, asyncListener));

            this.analyzerService = analyzerService;
            var diagnosticService = new DiagnosticService(SpecializedCollections.SingletonEnumerable(updateSource), listeners);

            this.TaggerProvider = new DiagnosticsSquiggleTaggerProvider(
                workspace.Services.GetService<IOptionService>(), diagnosticService,
                workspace.GetService<IForegroundNotificationService>(), listeners);

            if (analyzerService != null)
            {
                this.incrementalAnalyzers = ImmutableArray.Create(analyzerService.CreateIncrementalAnalyzer(workspace));
                this.solutionCrawlerService = workspace.Services.GetService<ISolutionCrawlerRegistrationService>() as SolutionCrawlerRegistrationService;
            }
        }
示例#2
0
 internal InteractiveWorkspace(HostServices hostServices)
     : base(hostServices, WorkspaceKind.Interactive)
 {
     // register work coordinator for this workspace
     _registrationService = this.Services.GetService<ISolutionCrawlerRegistrationService>();
     _registrationService.Register(this);
 }
示例#3
0
 public void EnableDiagnostic()
 {
     _registrationService = this.Services.GetService<ISolutionCrawlerRegistrationService>();
     if (_registrationService != null)
     {
         _registrationService.Register(this);
     }
 }
示例#4
0
 internal InteractiveWorkspace(HostServices hostServices)
     : base(hostServices, WorkspaceKind.Interactive)
 {
     // register work coordinator for this workspace
     _registrationService =
         Services.GetRequiredService <ISolutionCrawlerRegistrationService>();
     _registrationService.Register(this);
 }
示例#5
0
 public void EnableDiagnostic()
 {
     _registrationService = this.Services.GetService <ISolutionCrawlerRegistrationService>();
     if (_registrationService != null)
     {
         _registrationService.Register(this);
     }
 }
示例#6
0
        internal InteractiveWorkspace(InteractiveEvaluator engine, HostServices hostServices)
            : base(hostServices, "Interactive")
        {
            this.Engine = engine;

            // register work coordinator for this workspace
            _registrationService = this.Services.GetService<ISolutionCrawlerRegistrationService>();
            _registrationService.Register(this);
        }
        internal InteractiveWorkspace(InteractiveEvaluator engine, HostServices hostServices)
            : base(hostServices, "Interactive")
        {
            this.Engine = engine;

            // register work coordinator for this workspace
            _registrationService = this.Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService.Register(this);
        }
示例#8
0
        public RemoteWorkspace()
            : base(RoslynServices.HostServices, workspaceKind: WorkspaceKind.RemoteWorkspace)
        {
            PrimaryWorkspace.Register(this);

            Options = Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0);

            _registrationService = Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService?.Register(this);
        }
示例#9
0
        // internal for testing purposes.
        internal RemoteWorkspace(HostServices hostServices, string?workspaceKind)
            : base(hostServices, workspaceKind)
        {
            var exportProvider = (IMefHostExportProvider)Services.HostServices;

            RegisterDocumentOptionProviders(exportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>());

            SetOptions(Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0));

            _registrationService = Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService?.Register(this);
        }
示例#10
0
        internal InteractiveWorkspace(InteractiveEvaluator engine, HostServices hostServices)
            : base(hostServices, "Interactive")
        {
            this.Engine = engine;

            // register work coordinator for this workspace
            _registrationService = this.Services.GetService<ISolutionCrawlerRegistrationService>();
            _registrationService.Register(this);

            // TODO (https://github.com/dotnet/roslyn/issues/5107): Enable in Interactive.
            this.Options = this.Options.WithChangedOption(InternalFeatureOnOffOptions.Snippets, false);
        }
示例#11
0
        internal InteractiveWorkspace(InteractiveEvaluator engine, HostServices hostServices)
            : base(hostServices, "Interactive")
        {
            this.Engine = engine;

            // register work coordinator for this workspace
            _registrationService = this.Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService.Register(this);

            // TODO (https://github.com/dotnet/roslyn/issues/5107): Enable in Interactive.
            this.Options = this.Options.WithChangedOption(InternalFeatureOnOffOptions.Snippets, false);
        }
示例#12
0
        public RemoteWorkspace()
            : base(RoslynServices.HostServices, workspaceKind: WorkspaceKind.RemoteWorkspace)
        {
            var exportProvider   = (IMefHostExportProvider)Services.HostServices;
            var primaryWorkspace = exportProvider.GetExports <PrimaryWorkspace>().Single().Value;

            primaryWorkspace.Register(this);

            Options = Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0);

            _registrationService = Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService?.Register(this);
        }
示例#13
0
 internal void StartSolutionCrawler()
 {
     if (_registrationService == null)
     {
         lock (this)
         {
             if (_registrationService == null)
             {
                 _registrationService = this.Services.GetService <ISolutionCrawlerRegistrationService>();
                 _registrationService.Register(this);
             }
         }
     }
 }
 internal void StartSolutionCrawler()
 {
     if (_registrationService == null)
     {
         lock (this)
         {
             if (_registrationService == null)
             {
                 _registrationService = this.Services.GetService<ISolutionCrawlerRegistrationService>();
                 _registrationService.Register(this);
             }
         }
     }
 }
示例#15
0
        // internal for testing purposes.
        internal RemoteWorkspace(bool applyStartupOptions)
            : base(RoslynServices.HostServices, workspaceKind : WorkspaceKind.RemoteWorkspace)
        {
            var exportProvider   = (IMefHostExportProvider)Services.HostServices;
            var primaryWorkspace = exportProvider.GetExports <PrimaryWorkspace>().Single().Value;

            primaryWorkspace.Register(this);

            RegisterDocumentOptionProviders(exportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>());

            if (applyStartupOptions)
            {
                SetOptions(Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0));
            }

            _registrationService = Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService?.Register(this);
        }
示例#16
0
        public RemoteWorkspace()
            : base(RoslynServices.HostServices, workspaceKind: WorkspaceKind.RemoteWorkspace)
        {
            var exportProvider   = (IMefHostExportProvider)Services.HostServices;
            var primaryWorkspace = exportProvider.GetExports <PrimaryWorkspace>().Single().Value;

            primaryWorkspace.Register(this);

            foreach (var providerFactory in exportProvider.GetExports <IDocumentOptionsProviderFactory>())
            {
                Services.GetRequiredService <IOptionService>().RegisterDocumentOptionsProvider(providerFactory.Value.Create(this));
            }

            Options = Options.WithChangedOption(CacheOptions.RecoverableTreeLengthThreshold, 0);

            _registrationService = Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService?.Register(this);
        }
示例#17
0
        private DiagnosticTaggerWrapper(
            TestWorkspace workspace,
            Dictionary <string, DiagnosticAnalyzer[]> analyzerMap,
            IDiagnosticUpdateSource updateSource,
            bool createTaggerProvider)
        {
            _asyncListener = new AsynchronousOperationListener();
            _listeners     = AsynchronousOperationListener.CreateListeners(
                ValueTuple.Create(FeatureAttribute.DiagnosticService, _asyncListener),
                ValueTuple.Create(FeatureAttribute.ErrorSquiggles, _asyncListener));

            if (analyzerMap != null || updateSource == null)
            {
                AnalyzerService = CreateDiagnosticAnalyzerService(analyzerMap, _asyncListener);
            }

            if (updateSource == null)
            {
                updateSource = AnalyzerService;
            }

            _workspace = workspace;

            _registrationService = workspace.Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService.Register(workspace);

            DiagnosticService = new DiagnosticService(_listeners);
            DiagnosticService.Register(updateSource);

            if (createTaggerProvider)
            {
                var taggerProvider = this.TaggerProvider;
            }

            if (AnalyzerService != null)
            {
                _incrementalAnalyzers   = ImmutableArray.Create(AnalyzerService.CreateIncrementalAnalyzer(workspace));
                _solutionCrawlerService = workspace.Services.GetService <ISolutionCrawlerRegistrationService>() as SolutionCrawlerRegistrationService;
            }
        }
示例#18
0
        private DiagnosticTaggerWrapper(
            TestWorkspace workspace,
            Dictionary <string, DiagnosticAnalyzer[]> analyzerMap,
            IDiagnosticUpdateSource updateSource,
            bool createTaggerProvider)
        {
            _threadingContext = workspace.GetService <IThreadingContext>();
            _listenerProvider = workspace.GetService <IAsynchronousOperationListenerProvider>();

            if (analyzerMap != null || updateSource == null)
            {
                AnalyzerService = CreateDiagnosticAnalyzerService(analyzerMap, _listenerProvider.GetListener(FeatureAttribute.DiagnosticService));
            }

            if (updateSource == null)
            {
                updateSource = AnalyzerService;
            }

            _workspace = workspace;

            _registrationService = workspace.Services.GetService <ISolutionCrawlerRegistrationService>();
            _registrationService.Register(workspace);

            DiagnosticService = new DiagnosticService(_listenerProvider, Array.Empty <Lazy <IEventListener, EventListenerMetadata> >());
            DiagnosticService.Register(updateSource);

            if (createTaggerProvider)
            {
                var taggerProvider = this.TaggerProvider;
            }

            if (AnalyzerService != null)
            {
                _incrementalAnalyzers   = ImmutableArray.Create(AnalyzerService.CreateIncrementalAnalyzer(workspace));
                _solutionCrawlerService = workspace.Services.GetService <ISolutionCrawlerRegistrationService>() as SolutionCrawlerRegistrationService;
            }
        }
示例#19
0
        public DiagnosticTaggerWrapper(
            TestWorkspace workspace,
            IReadOnlyDictionary <string, ImmutableArray <DiagnosticAnalyzer> >?analyzerMap = null,
            IDiagnosticUpdateSource?updateSource = null,
            bool createTaggerProvider            = true)
        {
            _threadingContext = workspace.GetService <IThreadingContext>();
            _listenerProvider = workspace.GetService <IAsynchronousOperationListenerProvider>();

            if (updateSource == null)
            {
                updateSource = AnalyzerService = new MyDiagnosticAnalyzerService(_listenerProvider.GetListener(FeatureAttribute.DiagnosticService));
            }

            var analyzerReference = new TestAnalyzerReferenceByLanguage(analyzerMap ?? DiagnosticExtensions.GetCompilerDiagnosticAnalyzersMap());

            workspace.TryApplyChanges(workspace.CurrentSolution.WithAnalyzerReferences(new[] { analyzerReference }));

            _workspace = workspace;

            _registrationService = workspace.Services.GetRequiredService <ISolutionCrawlerRegistrationService>();
            _registrationService.Register(workspace);

            DiagnosticService = new DiagnosticService(_listenerProvider, Array.Empty <Lazy <IEventListener, EventListenerMetadata> >());
            DiagnosticService.Register(updateSource);

            if (createTaggerProvider)
            {
                _ = TaggerProvider;
            }

            if (AnalyzerService != null)
            {
                _incrementalAnalyzers   = ImmutableArray.Create(AnalyzerService.CreateIncrementalAnalyzer(workspace));
                _solutionCrawlerService = workspace.Services.GetService <ISolutionCrawlerRegistrationService>() as SolutionCrawlerRegistrationService;
            }
        }
        private DiagnosticTaggerWrapper(
            TestWorkspace workspace,
            DiagnosticAnalyzerService analyzerService,
            IDiagnosticUpdateSource updateSource,
            bool createTaggerProvider)
        {
            if (updateSource == null)
            {
                updateSource = analyzerService;
            }

            _workspace = workspace;

            _registrationService = workspace.Services.GetService<ISolutionCrawlerRegistrationService>();
            _registrationService.Register(workspace);

            _asyncListener = new AsynchronousOperationListener();
            _listeners = AsynchronousOperationListener.CreateListeners(
                ValueTuple.Create(FeatureAttribute.DiagnosticService, _asyncListener),
                ValueTuple.Create(FeatureAttribute.ErrorSquiggles, _asyncListener));

            _analyzerService = analyzerService;
            _diagnosticService = new DiagnosticService(_listeners);
            _diagnosticService.Register(updateSource);

            if (createTaggerProvider)
            {
                var taggerProvider = this.TaggerProvider;
            }

            if (analyzerService != null)
            {
                _incrementalAnalyzers = ImmutableArray.Create(analyzerService.CreateIncrementalAnalyzer(workspace));
                _solutionCrawlerService = workspace.Services.GetService<ISolutionCrawlerRegistrationService>() as SolutionCrawlerRegistrationService;
            }
        }
示例#21
0
        private DiagnosticTaggerWrapper(
            TestWorkspace workspace,
            DiagnosticAnalyzerService analyzerService,
            IDiagnosticUpdateSource updateSource,
            bool createTaggerProvider)
        {
            if (updateSource == null)
            {
                updateSource = analyzerService;
            }

            this.workspace = workspace;

            this.registrationService = workspace.Services.GetService <ISolutionCrawlerRegistrationService>();
            registrationService.Register(workspace);

            this.asyncListener = new AsynchronousOperationListener();
            this.listeners     = AsynchronousOperationListener.CreateListeners(
                ValueTuple.Create(FeatureAttribute.DiagnosticService, asyncListener),
                ValueTuple.Create(FeatureAttribute.ErrorSquiggles, asyncListener));

            this.analyzerService   = analyzerService;
            this.diagnosticService = new DiagnosticService(listeners);
            diagnosticService.Register(updateSource);

            if (createTaggerProvider)
            {
                var taggerProvider = this.TaggerProvider;
            }

            if (analyzerService != null)
            {
                this.incrementalAnalyzers   = ImmutableArray.Create(analyzerService.CreateIncrementalAnalyzer(workspace));
                this.solutionCrawlerService = workspace.Services.GetService <ISolutionCrawlerRegistrationService>() as SolutionCrawlerRegistrationService;
            }
        }
示例#22
0
 public void Register(Workspace workspace)
 => _registrationService.Register(workspace);