private void EnqueueParseSnapshotTask(Document newDocument) { if (newDocument != null) { _workQueue.EnqueueBackgroundTask(c => this.EnqueueParseSnapshotWorkerAsync(newDocument, c), GetType() + ".EnqueueParseSnapshotTask.1", CancellationToken.None); } }
private void EnqueueParseSnapshotTask(Document newDocument) { Contract.Assert(!_isClassificationOnlyWorkspace, "classification-only workspaces must provide the corresponding snapshot"); _workQueue.EnqueueBackgroundTask( c => this.EnqueueParseSnapshotWorkerAsync(newDocument, c), GetType() + ".EnqueueParseSnapshotTask.1", CancellationToken.None); }
private void EnqueueProcessSnapshotAsync(DocumentId updatedDocumentId = null) { var workspace = this._workspace; if (workspace == null) { return; } var documentId = workspace.GetDocumentIdInCurrentContext(this._textBuffer.AsTextContainer()); if (documentId == null) { return; } // If the caller specified a DocumentId and it's the one for this buffer (in the current context), // then there's nothing to do. if (updatedDocumentId != null && updatedDocumentId != documentId) { // This is very common and not very interesting, so don't record it. return; } if (Interlocked.CompareExchange(ref this._isRequestPending, 1, 0) != 0) { return; } _workQueue.EnqueueBackgroundTask(c => this.EnqueueProcessSnapshotWorkerAsync(documentId, c), GetType() + "." + nameof(EnqueueProcessSnapshotAsync) + ".1", CancellationToken.None); }
private void OnEventSourceChanged(object?sender, TaggerEventArgs args) { // First, notify anyone listening to us that something definitely changed. this.Changed?.Invoke(this, args); var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); if (document == null) { return; } if (!document.SupportsSemanticModel) { return; } // Now, attempt to cancel any existing work to get the compilation for this project, and kick off a new // piece of work in the future to do so. Do this after a delay so we can appropriately throttle ourselves // if we hear about a flurry of notifications. _workQueue.CancelCurrentWork(); _workQueue.EnqueueBackgroundTask(async c => { await document.Project.GetCompilationAsync(c).ConfigureAwait(false); this.Changed?.Invoke(this, new TaggerEventArgs()); }, $"{nameof(CompilationAvailableTaggerEventSource)}.{nameof(OnEventSourceChanged)}", 500, _workQueue.CancellationToken); }
private void EnqueueParseSnapshotTask(Document newDocument) { // When renaming a file's extension through VS when it's opened in editor, // the content type might change and the content type changed event can be // raised before the renaming propagate through VS workspace. As a result, // the document we got (based on the buffer) could still be the one in the workspace // before rename happened. This would cause us problem if the document is supported // by workspace but not a roslyn language (e.g. xaml, F#, etc.), since none of the roslyn // language services would be available. // // If this is the case, we will not parse the snapshot. It's OK to ignore the request // because when the buffer eventually get associated with the correct document in roslyn // workspace, we will be invoked again. // // For example, if you open a xaml from from a WPF project in designer view, // and then rename file extension from .xaml to .cs, then the document we received // here would still belong to the special "-xaml" project. if (newDocument != null && newDocument.SupportsSyntaxTree) { _workQueue.EnqueueBackgroundTask(c => this.EnqueueParseSnapshotWorkerAsync(newDocument, c), GetType() + ".EnqueueParseSnapshotTask.1", CancellationToken.None); } }
public void OnDocumentChanged(Action onCompleted) { _workQueue.CancelCurrentWork(); var cancellationToken = _workQueue.CancellationToken; _workQueue.EnqueueBackgroundTask( async ct => { await UpdateCurrentSnapshotAsync(ct); onCompleted(); }, "BuildDiagnostics", 1000, cancellationToken); }
private void OnDocumentChanged(object sender, DocumentEventArgs e) { if (e.Document.Language != LanguageNames.ShaderLab) { return; } _workQueue.CancelCurrentWork(); _workQueue.EnqueueBackgroundTask( async ct => { // TODO: Figure out whether this is a destructive change. // TODO: Incremental updates. await UpdateBuffersAsync(e.Document, ct); }, "UpdateBuffers", _workQueue.CancellationToken); }