public async Task <QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken) { var snapshot = _textBuffer.CurrentSnapshot; var triggerPoint = session.GetTriggerPoint(snapshot); if (!triggerPoint.HasValue) { return(null); } var navigationsResult = await _navigationTokenService .GetNavigationsAsync(triggerPoint.Value) .ConfigureAwait(false); if (navigationsResult == null) { return(null); } var dataElement = await _descriptionBuilder .GetColorizedDescriptionAsync(navigationsResult.Values, cancellationToken) .ConfigureAwait(false); if (dataElement == null) { return(null); } var tokenSpan = navigationsResult.ApplicableToken.Span; var applicableSpan = snapshot.CreateTrackingSpan(tokenSpan, SpanTrackingMode.EdgeInclusive); return(new QuickInfoItem(applicableSpan, dataElement)); }
public void AugmentPeekSession(IPeekSession session, IList <IPeekableItem> peekableItems) { if (session == null) { throw new ArgumentNullException(nameof(session)); } if (peekableItems == null) { throw new ArgumentNullException(nameof(peekableItems)); } if (!string.Equals(session.RelationshipName, PredefinedPeekRelationships.Definitions.Name, StringComparison.OrdinalIgnoreCase)) { return; } var triggerPoint = session.GetTriggerPoint(_textBuffer.CurrentSnapshot); if (!triggerPoint.HasValue) { return; } var tokensResult = ThreadHelper.JoinableTaskFactory.Run( () => _navigationTokenService.GetNavigationsAsync(triggerPoint.Value)); if (tokensResult == null || tokensResult.Values.Count != 1) { return; } peekableItems.Add(new PeekableItem(_peekResultFactory, tokensResult.Values[0])); }
private bool TryGoToDefinition() { var point = _textView.Caret.Position.BufferPosition; var navigationServiceResult = ThreadHelper.JoinableTaskFactory.Run(() => _navigationService.GetNavigationsAsync(point)); if (navigationServiceResult == null || navigationServiceResult.Values.Count == 0) { return(false); } _navigationService.NavigateOrOpenNavigationList(navigationServiceResult.Values); return(true); }
public async Task <INavigableSymbol> GetNavigableSymbolAsync(SnapshotSpan triggerSpan, CancellationToken token) { var triggerPoint = triggerSpan.Start; var tokensResult = await _navigationService.GetNavigationsAsync(triggerPoint); if (tokensResult == null) { return(null); } var snapshotSpan = new SnapshotSpan(triggerPoint.Snapshot, tokensResult.ApplicableToken.Span); return(new NavigableSymbol(snapshotSpan, () => _navigationService.NavigateOrOpenNavigationList(tokensResult.Values))); }