Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<PackageVersion Include="Microsoft.VisualStudio.LiveShare.WebEditors" Version="3.0.8" />
<PackageVersion Include="Microsoft.VisualStudio.InteractiveWindow" Version="4.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.VsInteractiveWindow" Version="4.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Search" Version="17.10.961-preview.2" />
<PackageVersion Include="Microsoft.VisualStudio.Search" Version="17.14.39337" />
<PackageVersion Include="Microsoft.VisualStudio.Utilities" Version="18.0.1306-preview.1" />
<PackageVersion Include="Microsoft.VisualStudio.WinForms.Interfaces" Version="17.0.0-previews-4-31709-430" />
<PackageVersion Include="Microsoft.VisualStudio.Workspace.VSIntegration" Version="17.9.29-preview-0001" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public async Task NotFullyLoadedOnlyMakesOneSearchProjectCallIfValueReturned()
var callbackMock = new Mock<INavigateToSearchCallback>(MockBehavior.Strict);
callbackMock.Setup(c => c.ReportIncomplete());
callbackMock.Setup(c => c.ReportProgress(It.IsAny<int>(), It.IsAny<int>()));
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<Document>(), It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);

// Because we returned a result when not fully loaded, we should notify the user that data was not complete.
callbackMock.Setup(c => c.Done(false));
Expand Down Expand Up @@ -175,7 +175,7 @@ public async Task NotFullyLoadedMakesTwoSearchProjectCallIfValueNotReturned(bool
var callbackMock = new Mock<INavigateToSearchCallback>(MockBehavior.Strict);
callbackMock.Setup(c => c.ReportIncomplete());
callbackMock.Setup(c => c.ReportProgress(It.IsAny<int>(), It.IsAny<int>()));
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<CancellationToken>()))
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<Document>(), It.IsAny<CancellationToken>()))
.Returns(Task.CompletedTask);

// Because the remote host wasn't fully loaded, we still notify that our results may be incomplete.
Expand Down Expand Up @@ -249,7 +249,7 @@ public async Task FullyLoadedMakesSingleSearchProjectCallIfValueNotReturned()

var callbackMock = new Mock<INavigateToSearchCallback>(MockBehavior.Strict);
callbackMock.Setup(c => c.ReportProgress(It.IsAny<int>(), It.IsAny<int>()));
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<CancellationToken>()))
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<Document>(), It.IsAny<CancellationToken>()))
.Returns(Task.CompletedTask);

// Because we did a full search, we should let the user know it was totally accurate.
Expand Down Expand Up @@ -282,7 +282,7 @@ public async Task DoNotCrashWithoutSearchService()
var callbackMock = new Mock<INavigateToSearchCallback>(MockBehavior.Strict);
callbackMock.Setup(c => c.ReportIncomplete());
callbackMock.Setup(c => c.ReportProgress(It.IsAny<int>(), It.IsAny<int>()));
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<Document>(), It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);

callbackMock.Setup(c => c.Done(true));

Expand Down Expand Up @@ -340,7 +340,7 @@ public class D
var callbackMock = new Mock<INavigateToSearchCallback>(MockBehavior.Strict);
callbackMock.Setup(c => c.ReportIncomplete());
callbackMock.Setup(c => c.ReportProgress(It.IsAny<int>(), It.IsAny<int>()));
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);
callbackMock.Setup(c => c.AddResultsAsync(results, It.IsAny<Document>(), It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);

callbackMock.Setup(c => c.Done(true));

Expand Down Expand Up @@ -488,7 +488,7 @@ public void ReportIncomplete()
{
}

public Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, CancellationToken cancellationToken)
public Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, Document? activeDocument, CancellationToken cancellationToken)
{
foreach (var result in results)
this.Results.Add(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void Done(bool isFullyLoaded)
}
}

public Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, CancellationToken cancellationToken)
public Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, Document? activeDocument, CancellationToken cancellationToken)
{
foreach (var result in results)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task SearchDocumentAsync(
CancellationToken cancellationToken)
{
var solution = document.Project.Solution;
var onItemsFound = GetOnItemsFoundCallback(solution, activeDocument: null, onResultsFound);
var onItemsFound = GetOnItemsFoundCallback(solution, activeDocument: document, onResultsFound);

var client = await RemoteHostClient.TryGetClientAsync(document.Project, cancellationToken).ConfigureAwait(false);
if (client != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal interface INavigateToSearchCallback
void Done(bool isFullyLoaded);
void ReportIncomplete();

Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, CancellationToken cancellationToken);
Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, Document? activeDocument, CancellationToken cancellationToken);

void ReportProgress(int current, int maximum);
}
4 changes: 2 additions & 2 deletions src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private async Task SearchCurrentDocumentAsync(CancellationToken cancellationToke
await AddProgressItemsAsync(1, cancellationToken).ConfigureAwait(false);
await service.SearchDocumentAsync(
_activeDocument, _searchPattern, _kinds,
r => _callback.AddResultsAsync(r, cancellationToken),
r => _callback.AddResultsAsync(r, _activeDocument, cancellationToken),
cancellationToken).ConfigureAwait(false);
}

Expand Down Expand Up @@ -400,7 +400,7 @@ await processProjectAsync(
}

if (nonDuplicates.Count > 0)
_callback.AddResultsAsync(nonDuplicates.ToImmutableAndClear(), cancellationToken);
_callback.AddResultsAsync(nonDuplicates.ToImmutableAndClear(), _activeDocument, cancellationToken);

return Task.CompletedTask;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static Task SearchAsync(

private sealed class OmniSharpNavigateToCallbackImpl(Solution solution, OmniSharpNavigateToCallback callback) : INavigateToSearchCallback
{
public async Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, CancellationToken cancellationToken)
public async Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, Document? activeDocument, CancellationToken cancellationToken)
{
foreach (var result in results)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ private sealed class LSPNavigateToCallback(
BufferedProgress<SymbolInformation[]> progress)
: INavigateToSearchCallback
{
public async Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, CancellationToken cancellationToken)
public async Task AddResultsAsync(
ImmutableArray<INavigateToSearchResult> results, Document? activeDocument, CancellationToken cancellationToken)
{
Contract.ThrowIfNull(context.Solution);
var solution = context.Solution;
Expand Down
47 changes: 22 additions & 25 deletions src/VisualStudio/Core/Def/NavigateTo/RoslynCodeSearchResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,28 @@ internal sealed partial class RoslynSearchItemsSourceProvider
/// cref="INavigateToSearchResult"/> object we got back from the search so we can present the UI with the data
/// from it.
/// </summary>
private sealed class RoslynCodeSearchResult : CodeSearchResult
private sealed class RoslynCodeSearchResult(
RoslynSearchItemsSourceProvider provider,
INavigateToSearchResult searchResult,
string resultType,
string primarySortText,
string secondarySortText,
IReadOnlyCollection<PatternMatch> patternMatches,
string? location,
float perProviderItemPriority,
string language,
bool isActiveDocument)
: CodeSearchResult(
provider._viewFactory,
resultType,
primarySortText,
secondarySortText,
patternMatches,
location,
perProviderItemPriority: perProviderItemPriority,
language: language,
isActiveDocument: isActiveDocument)
{
public readonly INavigateToSearchResult SearchResult;

public RoslynCodeSearchResult(
RoslynSearchItemsSourceProvider provider,
INavigateToSearchResult searchResult,
string resultType,
string primarySortText,
string secondarySortText,
IReadOnlyCollection<PatternMatch> patternMatches,
string? location,
float perProviderItemPriority,
string language)
: base(
provider._viewFactory,
resultType,
primarySortText,
secondarySortText,
patternMatches,
location,
perProviderItemPriority: perProviderItemPriority,
language: language)
{
SearchResult = searchResult;
}
public readonly INavigateToSearchResult SearchResult = searchResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,14 @@ internal sealed partial class RoslynSearchItemsSourceProvider
/// A callback to be passed to the <see cref="NavigateToSearcher"/>. Results it pushes into us will then be
/// converted and pushed into <see cref="_searchCallback"/>.
/// </summary>
private sealed class RoslynNavigateToSearchCallback : INavigateToSearchCallback
private sealed class RoslynNavigateToSearchCallback(
Solution solution,
RoslynSearchItemsSourceProvider provider,
ISearchCallback searchCallback) : INavigateToSearchCallback
{
private readonly Solution _solution;
private readonly RoslynSearchItemsSourceProvider _provider;
private readonly ISearchCallback _searchCallback;

public RoslynNavigateToSearchCallback(
Solution solution,
RoslynSearchItemsSourceProvider provider,
ISearchCallback searchCallback)
{
_solution = solution;
_provider = provider;
_searchCallback = searchCallback;
}
private readonly Solution _solution = solution;
private readonly RoslynSearchItemsSourceProvider _provider = provider;
private readonly ISearchCallback _searchCallback = searchCallback;

public void Done(bool isFullyLoaded)
{
Expand All @@ -54,7 +47,8 @@ public void ReportIncomplete()
_searchCallback.ReportIncomplete(IncompleteReason.Parsing);
}

public Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, CancellationToken cancellationToken)
public Task AddResultsAsync(
ImmutableArray<INavigateToSearchResult> results, Document? activeDocument, CancellationToken cancellationToken)
{
// Convert roslyn pattern matches to the platform type.
foreach (var result in results)
Expand All @@ -80,7 +74,8 @@ public Task AddResultsAsync(ImmutableArray<INavigateToSearchResult> results, Can
matches,
result.NavigableItem.Document.FilePath,
perProviderItemPriority,
project.Language));
project.Language,
isActiveDocument: activeDocument != null && activeDocument.Id == result.NavigableItem.Document.Id));
}

return Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void ReportProgress(int current, int maximum) { }

public Task AddResultsAsync(
ImmutableArray<INavigateToSearchResult> results,
Document? activeDocument,
CancellationToken cancellationToken)
{
foreach (var result in results)
Expand Down