public async Task <DataTipInfo> GetDebugInfoAsync(SnapshotPoint snapshotPoint, CancellationToken cancellationToken) { var analysisDocument = snapshotPoint.Snapshot.AsText().GetOpenDocumentInCurrentContextWithChanges(); IProjectionSnapshot projectionSnapshot = null; if (analysisDocument == null) { projectionSnapshot = snapshotPoint.Snapshot as IProjectionSnapshot; if (projectionSnapshot != null) { snapshotPoint = projectionSnapshot.MapToSourceSnapshot(snapshotPoint.Position); analysisDocument = snapshotPoint.Snapshot.AsText().GetOpenDocumentInCurrentContextWithChanges(); } } if (analysisDocument == null) { return(default(DataTipInfo)); } var debugInfoService = analysisDocument.GetLanguageService <Microsoft.CodeAnalysis.Editor.Implementation.Debugging.ILanguageDebugInfoService> (); if (debugInfoService == null) { return(default(DataTipInfo)); } var tipInfo = await debugInfoService.GetDataTipInfoAsync(analysisDocument, snapshotPoint.Position, cancellationToken).ConfigureAwait(false); var text = tipInfo.Text; if (text == null && !tipInfo.IsDefault) { text = snapshotPoint.Snapshot.GetText(tipInfo.Span.Start, tipInfo.Span.Length); } var semanticModel = await analysisDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false); var syntaxNode = root.FindNode(tipInfo.Span); DebugDataTipInfo debugDataTipInfo; if (syntaxNode == null) { debugDataTipInfo = new DebugDataTipInfo(tipInfo.Span, text); } else { debugDataTipInfo = GetInfo(root, semanticModel, syntaxNode, text, cancellationToken); } if (projectionSnapshot != null) { var originalSpan = projectionSnapshot.MapFromSourceSnapshot(new SnapshotSpan(snapshotPoint.Snapshot, debugDataTipInfo.Span.Start, debugDataTipInfo.Span.Length)).FirstOrDefault(); if (originalSpan == default) { return(default);
public async Task <DataTipInfo> GetDebugInfoAsync(SnapshotPoint snapshotPoint, CancellationToken cancellationToken) { var analysisDocument = snapshotPoint.Snapshot.AsText().GetOpenDocumentInCurrentContextWithChanges(); if (analysisDocument == null) { return(default(DataTipInfo)); } var debugInfoService = analysisDocument.GetLanguageService <Microsoft.CodeAnalysis.Editor.Implementation.Debugging.ILanguageDebugInfoService> (); if (debugInfoService == null) { return(default(DataTipInfo)); } var tipInfo = await debugInfoService.GetDataTipInfoAsync(analysisDocument, snapshotPoint.Position, cancellationToken).ConfigureAwait(false); var text = tipInfo.Text; if (text == null && !tipInfo.IsDefault) { text = snapshotPoint.Snapshot.GetText(tipInfo.Span.Start, tipInfo.Span.Length); } var semanticModel = await analysisDocument.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false); var syntaxNode = root.FindNode(tipInfo.Span); DebugDataTipInfo debugDataTipInfo; if (syntaxNode == null) { debugDataTipInfo = new DebugDataTipInfo(tipInfo.Span, text); } else { debugDataTipInfo = GetInfo(root, semanticModel, syntaxNode, text, cancellationToken); } return(new DataTipInfo(snapshotPoint.Snapshot.CreateTrackingSpan(debugDataTipInfo.Span.Start, debugDataTipInfo.Span.Length, SpanTrackingMode.EdgeInclusive), debugDataTipInfo.Text)); }