public RequestContext( Solution?solution, ILspLogger logger, ClientCapabilities clientCapabilities, WellKnownLspServerKinds serverKind, Document?document, IDocumentChangeTracker documentChangeTracker, ImmutableDictionary <Uri, SourceText> trackedDocuments, ImmutableArray <string> supportedLanguages, IGlobalOptionService globalOptions, ILanguageServerNotificationManager notificationManager, CancellationToken queueCancellationToken) { Document = document; Solution = solution; ClientCapabilities = clientCapabilities; ServerKind = serverKind; SupportedLanguages = supportedLanguages; GlobalOptions = globalOptions; _documentChangeTracker = documentChangeTracker; _logger = logger; _trackedDocuments = trackedDocuments; NotificationManager = notificationManager; QueueCancellationToken = queueCancellationToken; }
public RequestContext(Solution solution, ClientCapabilities clientCapabilities, string?clientName, Document?document, IDocumentChangeTracker documentChangeTracker) { Document = document; Solution = solution; ClientCapabilities = clientCapabilities; ClientName = clientName; _documentChangeTracker = documentChangeTracker; }
public RequestContext( Solution? solution, Action<string> traceInformation, ClientCapabilities clientCapabilities, string? clientName, Document? document, IDocumentChangeTracker documentChangeTracker, ImmutableArray<string> supportedLanguages, IGlobalOptionService globalOptions) { Document = document; Solution = solution; ClientCapabilities = clientCapabilities; ClientName = clientName; SupportedLanguages = supportedLanguages; GlobalOptions = globalOptions; _documentChangeTracker = documentChangeTracker; _traceInformation = traceInformation; }
public RequestContext( Solution?solution, ILspLogger logger, ClientCapabilities clientCapabilities, string?clientName, Document?document, IDocumentChangeTracker documentChangeTracker, ImmutableDictionary <Uri, SourceText> trackedDocuments, ImmutableArray <string> supportedLanguages, IGlobalOptionService globalOptions) { Document = document; Solution = solution; ClientCapabilities = clientCapabilities; ClientName = clientName; SupportedLanguages = supportedLanguages; GlobalOptions = globalOptions; _documentChangeTracker = documentChangeTracker; _logger = logger; _trackedDocuments = trackedDocuments; }
public static RequestContext?Create( bool requiresLSPSolution, TextDocumentIdentifier?textDocument, string?clientName, ILspLogger logger, ClientCapabilities clientCapabilities, LspWorkspaceManager lspWorkspaceManager, IDocumentChangeTracker documentChangeTracker, ImmutableArray <string> supportedLanguages, IGlobalOptionService globalOptions) { // Retrieve the current LSP tracked text as of this request. // This is safe as all creation of request contexts cannot happen concurrently. var trackedDocuments = lspWorkspaceManager.GetTrackedLspText(); // If the handler doesn't need an LSP solution we do two important things: // 1. We don't bother building the LSP solution for perf reasons // 2. We explicitly don't give the handler a solution or document, even if we could // so they're not accidentally operating on stale solution state. if (!requiresLSPSolution) { return(new RequestContext(solution: null, logger, clientCapabilities, clientName, document: null, documentChangeTracker, trackedDocuments, supportedLanguages, globalOptions)); } // Go through each registered workspace, find the solution that contains the document that // this request is for, and then updates it based on the state of the world as we know it, based on the // text content in the document change tracker. Document?document = null; var workspaceSolution = lspWorkspaceManager.TryGetHostLspSolution(); if (textDocument is not null) { // we were given a request associated with a document. Find the corresponding roslyn // document for this. If we can't, we cannot proceed. document = lspWorkspaceManager.GetLspDocument(textDocument, clientName); if (document != null) { workspaceSolution = document.Project.Solution; } } if (workspaceSolution == null) { logger.TraceError("Could not find appropriate solution for operation"); return(null); } var context = new RequestContext( workspaceSolution, logger, clientCapabilities, clientName, document, documentChangeTracker, trackedDocuments, supportedLanguages, globalOptions); return(context); }
public static async Task <RequestContext?> CreateAsync( bool requiresLSPSolution, TextDocumentIdentifier?textDocument, WellKnownLspServerKinds serverKind, ILspLogger logger, ClientCapabilities clientCapabilities, LspWorkspaceManager lspWorkspaceManager, ILanguageServerNotificationManager notificationManager, IDocumentChangeTracker documentChangeTracker, ImmutableArray <string> supportedLanguages, IGlobalOptionService globalOptions, CancellationToken queueCancellationToken, CancellationToken requestCancellationToken) { // Retrieve the current LSP tracked text as of this request. // This is safe as all creation of request contexts cannot happen concurrently. var trackedDocuments = lspWorkspaceManager.GetTrackedLspText(); // If the handler doesn't need an LSP solution we do two important things: // 1. We don't bother building the LSP solution for perf reasons // 2. We explicitly don't give the handler a solution or document, even if we could // so they're not accidentally operating on stale solution state. if (!requiresLSPSolution) { return(new RequestContext( solution: null, logger: logger, clientCapabilities: clientCapabilities, serverKind: serverKind, document: null, documentChangeTracker: documentChangeTracker, trackedDocuments: trackedDocuments, supportedLanguages: supportedLanguages, globalOptions: globalOptions, notificationManager: notificationManager, queueCancellationToken: queueCancellationToken)); } Solution?workspaceSolution; Document?document = null; if (textDocument is not null) { // we were given a request associated with a document. Find the corresponding roslyn document for this. // There are certain cases where we may be asked for a document that does not exist (for example a document is removed) // For example, document pull diagnostics can ask us after removal to clear diagnostics for a document. document = await lspWorkspaceManager.GetLspDocumentAsync(textDocument, requestCancellationToken).ConfigureAwait(false); } workspaceSolution = document?.Project.Solution ?? await lspWorkspaceManager.TryGetHostLspSolutionAsync(requestCancellationToken).ConfigureAwait(false); if (workspaceSolution == null) { logger.TraceError("Could not find appropriate solution for operation"); return(null); } var context = new RequestContext( workspaceSolution, logger, clientCapabilities, serverKind, document, documentChangeTracker, trackedDocuments, supportedLanguages, globalOptions, notificationManager, queueCancellationToken); return(context); }