public override async ValueTask OnDefinitionFoundAsync(DefinitionItem definition) { using (await _semaphore.DisposableWaitAsync(CancellationToken).ConfigureAwait(false)) { if (_definitionToId.ContainsKey(definition)) { return; } // Assigning a new id to the definition _id++; _definitionToId.Add(definition, _id); // Creating a new VSReferenceItem for the definition var definitionItem = await GenerateVSReferenceItemAsync( _id, definitionId : _id, _document, _position, definition.SourceSpans.FirstOrDefault(), definition.DisplayableProperties, _metadataAsSourceFileService, definition.GetClassifiedText(), definition.Tags.GetFirstGlyph(), symbolUsageInfo : null, isWrittenTo : false, CancellationToken).ConfigureAwait(false); if (definitionItem != null) { // If a definition shouldn't be included in the results list if it doesn't have references, we // have to hold off on reporting it until later when we do find a reference. if (definition.DisplayIfNoReferences) { _workQueue.AddWork(definitionItem); } else { _definitionsWithoutReference.Add(definitionItem.Id, definitionItem); } } } }
/// <summary> /// Callback from the OOP service back into us. /// </summary> public ValueTask ReportProjectTelemetryDataAsync( ProjectTelemetryData info, CancellationToken cancellationToken ) { Contract.ThrowIfNull(_workQueue); _workQueue.AddWork(info); return(ValueTaskFactory.CompletedTask); }
private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs e) { // Events that can't change existing code model items. Can just ignore them. switch (e.Kind) { case WorkspaceChangeKind.SolutionAdded: case WorkspaceChangeKind.ProjectAdded: case WorkspaceChangeKind.DocumentAdded: case WorkspaceChangeKind.AdditionalDocumentAdded: case WorkspaceChangeKind.AdditionalDocumentRemoved: case WorkspaceChangeKind.AdditionalDocumentReloaded: case WorkspaceChangeKind.AdditionalDocumentChanged: case WorkspaceChangeKind.AnalyzerConfigDocumentAdded: case WorkspaceChangeKind.AnalyzerConfigDocumentRemoved: case WorkspaceChangeKind.AnalyzerConfigDocumentReloaded: case WorkspaceChangeKind.AnalyzerConfigDocumentChanged: return; case WorkspaceChangeKind.DocumentRemoved: case WorkspaceChangeKind.DocumentChanged: // Fast path when we know we affected a document that could have had code model elements in it. No // need to do a solution diff in this case. _documentsToFireEventsFor.AddWork(e.DocumentId !); return; } // Other type of event that could indicate a doc change/removal. Have to actually analyze the change to // determine what we should do here. var changes = e.OldSolution.GetChanges(e.NewSolution); foreach (var project in changes.GetRemovedProjects()) { _documentsToFireEventsFor.AddWork(project.DocumentIds); } foreach (var projectChange in changes.GetProjectChanges()) { _documentsToFireEventsFor.AddWork(projectChange.GetRemovedDocuments()); _documentsToFireEventsFor.AddWork(projectChange.GetChangedDocuments()); } }
private void DiagnosticService_DiagnosticsUpdated(Solution?solution, DocumentId?documentId) { // LSP doesn't support diagnostics without a document. So if we get project level diagnostics without a document, ignore them. if (documentId != null && solution != null) { var document = solution.GetDocument(documentId); if (document == null || document.FilePath == null) { return; } // Only publish document diagnostics for the languages this provider supports. if (!_supportedLanguages.Contains(document.Project.Language)) { return; } _diagnosticsWorkQueue.AddWork(document.Id); } }
public Task ReportDesignerAttributeDataAsync(ImmutableArray <DesignerAttributeData> data, CancellationToken cancellationToken) { Contract.ThrowIfNull(_workQueue); _workQueue.AddWork(data); return(Task.CompletedTask); }
private void OnWorkspaceChanged(object?sender, WorkspaceChangeEventArgs eventArgs) => _asyncDelay.AddWork();
public Task ReportTodoCommentDataAsync(DocumentId documentId, ImmutableArray <TodoCommentData> infos, CancellationToken cancellationToken) { Contract.ThrowIfNull(_workQueue); _workQueue.AddWork(new DocumentAndComments(documentId, infos)); return(Task.CompletedTask); }
private void EnqueueFlushTask() { // actual value isn't relevant. this just ensures that a flush will happen in the future. _flushQueue.AddWork(true); }
public TagSource( ITextView textViewOpt, ITextBuffer subjectBuffer, AbstractAsynchronousTaggerProvider <TTag> dataSource, IAsynchronousOperationListener asyncListener) : base(dataSource.ThreadingContext) { this.AssertIsForeground(); if (dataSource.SpanTrackingMode == SpanTrackingMode.Custom) { throw new ArgumentException("SpanTrackingMode.Custom not allowed.", "spanTrackingMode"); } _subjectBuffer = subjectBuffer; _textViewOpt = textViewOpt; _dataSource = dataSource; _asyncListener = asyncListener; _eventWorkQueue = new AsyncBatchingWorkQueue <bool>( _dataSource.EventChangeDelay.ComputeTimeDelay(), ProcessEventsAsync, EqualityComparer <bool> .Default, asyncListener, _disposalTokenSource.Token); _highPriTagsChangedQueue = new AsyncBatchingWorkQueue <NormalizedSnapshotSpanCollection>( TaggerDelay.NearImmediate.ComputeTimeDelay(), ProcessTagsChangedAsync, equalityComparer: null, asyncListener, _disposalTokenSource.Token); if (_dataSource.AddedTagNotificationDelay == TaggerDelay.NearImmediate) { // if the tagger wants "added tags" to be reported "NearImmediate"ly, then just reuse // the "high pri" queue as that already reports things at that cadence. _normalPriTagsChangedQueue = _highPriTagsChangedQueue; } else { _normalPriTagsChangedQueue = new AsyncBatchingWorkQueue <NormalizedSnapshotSpanCollection>( _dataSource.AddedTagNotificationDelay.ComputeTimeDelay(), ProcessTagsChangedAsync, equalityComparer: null, asyncListener, _disposalTokenSource.Token); } DebugRecordInitialStackTrace(); _eventSource = CreateEventSource(); Connect(); // Start computing the initial set of tags immediately. We want to get the UI // to a complete state as soon as possible. _eventWorkQueue.AddWork(/*initialTags*/ true); return; void Connect() { this.AssertIsForeground(); _eventSource.Changed += OnEventSourceChanged; if (_dataSource.TextChangeBehavior.HasFlag(TaggerTextChangeBehavior.TrackTextChanges)) { _subjectBuffer.Changed += OnSubjectBufferChanged; } if (_dataSource.CaretChangeBehavior.HasFlag(TaggerCaretChangeBehavior.RemoveAllTagsOnCaretMoveOutsideOfTag)) { if (_textViewOpt == null) { throw new ArgumentException( nameof(_dataSource.CaretChangeBehavior) + " can only be specified for an " + nameof(IViewTaggerProvider)); } _textViewOpt.Caret.PositionChanged += OnCaretPositionChanged; } // Tell the interaction object to start issuing events. _eventSource.Connect(); } }
public Task RegisterDesignerAttributesAsync(IList <DesignerInfo> attributeInfos, CancellationToken cancellationToken) { _workQueue.AddWork(attributeInfos); return(Task.CompletedTask); }
private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs eventArgs) => _workQueue.AddWork(true);
private void EnqueueFlushTask() { _flushQueue.AddWork(); }