diff --git a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs index 4f988f07be124287019ec21a38a400afa0fe0224..8e12fe198169041fbd78326c677a904836ed0e53 100644 --- a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs +++ b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemSource.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System; using System.Collections.Generic; using System.Threading; @@ -71,7 +73,7 @@ public void AugmentPeekSession(IPeekSession session, IList peekab { return; } - + var navigableItems = goToDefinitionService.FindDefinitionsAsync(document, triggerPoint.Value.Position, cancellationToken) .WaitAndGetResult(cancellationToken); @@ -96,6 +98,11 @@ public void AugmentPeekSession(IPeekSession session, IList peekab // Get the symbol back from the originating workspace var symbolMappingService = document.Project.Solution.Workspace.Services.GetService(); + if (symbolMappingService == null) + { + return; + } + var mappingResult = symbolMappingService.MapSymbolAsync(document, symbol, cancellationToken) .WaitAndGetResult(cancellationToken); @@ -118,6 +125,10 @@ public void AugmentPeekSession(IPeekSession session, IList peekab { var workspace = project.Solution.Workspace; var navigationService = workspace.Services.GetService(); + if (navigationService == null) + { + yield break; + } foreach (var item in navigableItems) { @@ -126,9 +137,12 @@ public void AugmentPeekSession(IPeekSession session, IList peekab { var text = document.GetTextSynchronously(cancellationToken); var linePositionSpan = text.Lines.GetLinePositionSpan(item.SourceSpan); - yield return new ExternalFilePeekableItem( - new FileLinePositionSpan(document.FilePath, linePositionSpan), - PredefinedPeekRelationships.Definitions, peekResultFactory); + if (document.FilePath != null) + { + yield return new ExternalFilePeekableItem( + new FileLinePositionSpan(document.FilePath, linePositionSpan), + PredefinedPeekRelationships.Definitions, peekResultFactory); + } } } }