public CancellationToken Start(IServiceContainer services, JsonRpc rpc)
        {
            _server   = new Server(services);
            _services = services;
            _rpc      = rpc;

            _jsonSerializer  = services.GetService <JsonSerializer>();
            _idleTimeTracker = services.GetService <IIdleTimeTracker>();
            _logger          = services.GetService <ILogger>();
            _telemetry       = services.GetService <ITelemetryService>();

            var rpcTraceListener = new TelemetryRpcTraceListener(_telemetry);

            _rpc.TraceSource.Listeners.Add(rpcTraceListener);

            _diagnosticsPublisher                     = new DiagnosticsPublisher(_server, services);
            _server.OnApplyWorkspaceEdit             += OnApplyWorkspaceEdit;
            _server.OnRegisterCapability             += OnRegisterCapability;
            _server.OnUnregisterCapability           += OnUnregisterCapability;
            _server.AnalysisQueue.UnhandledException += OnAnalysisQueueUnhandledException;

            _disposables
            .Add(() => _server.OnApplyWorkspaceEdit             -= OnApplyWorkspaceEdit)
            .Add(() => _server.OnRegisterCapability             -= OnRegisterCapability)
            .Add(() => _server.OnUnregisterCapability           -= OnUnregisterCapability)
            .Add(() => _server.AnalysisQueue.UnhandledException -= OnAnalysisQueueUnhandledException)
            .Add(() => _shutdownCts.Cancel())
            .Add(_prioritizer)
            .Add(() => _pathsWatcher?.Dispose())
            .Add(() => _rpc.TraceSource.Listeners.Remove(rpcTraceListener))
            .Add(_diagnosticsPublisher);

            return(_sessionTokenSource.Token);
        }
        /// <summary>
        ///     Publish current diagnostics (if any) for the specified project document.
        /// </summary>
        /// <param name="projectDocument">
        ///     The project document.
        /// </param>
        public void PublishDiagnostics(ProjectDocument projectDocument)
        {
            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            DiagnosticsPublisher.Publish(
                documentUri: projectDocument.DocumentUri,
                diagnostics: projectDocument.Diagnostics.ToArray()
                );
        }
Exemplo n.º 3
0
        public DocumentEntry(string content, Uri uri, IServiceContainer services)
        {
            _services = services;

            EditorBuffer = new EditorBuffer(content, "R");
            Document     = new REditorDocument(EditorBuffer, services, false);

            _completionManager    = new CompletionManager(services);
            _signatureManager     = new SignatureManager(services);
            _diagnosticsPublisher = new DiagnosticsPublisher(Document, uri, services);
            _formatter            = new CodeFormatter(_services);
            _symbolsProvider      = new DocumentSymbolsProvider();
        }
        /// <summary>
        ///     Clear current diagnostics (if any) for the specified project document.
        /// </summary>
        /// <param name="projectDocument">
        ///     The project document.
        /// </param>
        public void ClearDiagnostics(ProjectDocument projectDocument)
        {
            if (projectDocument == null)
            {
                throw new ArgumentNullException(nameof(projectDocument));
            }

            if (!projectDocument.HasDiagnostics)
            {
                return;
            }

            DiagnosticsPublisher.Publish(
                documentUri: projectDocument.DocumentUri,
                diagnostics: null // Overwrites existing diagnostics for this document with an empty list
                );
        }