-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ExternalAccess for INavigateToSearcherService (#63386)
* Add ExternalAccess for INavigateToSearcherService Because of #63375, O# cannot currently use SymbolFinder for finding all symbols for a pattern in the workspace. As a workaround, expose INavigateToSearcherService via EA to unblock the workspace symbol service.
- Loading branch information
Showing
3 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/Tools/ExternalAccess/OmniSharp/NavigateTo/OmniSharpNavigateToSearchResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Text; | ||
using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Navigation; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.NavigateTo; | ||
|
||
internal readonly record struct OmniSharpNavigateToSearchResult( | ||
string AdditionalInformation, | ||
string Kind, | ||
OmniSharpNavigateToMatchKind MatchKind, | ||
bool IsCaseSensitive, | ||
string Name, | ||
ImmutableArray<TextSpan> NameMatchSpans, | ||
string SecondarySort, | ||
string Summary, | ||
OmniSharpNavigableItem NavigableItem); | ||
|
||
internal enum OmniSharpNavigateToMatchKind | ||
{ | ||
Exact = 0, | ||
Prefix = 1, | ||
Substring = 2, | ||
Regular = 3, | ||
None = 4, | ||
CamelCaseExact = 5, | ||
CamelCasePrefix = 6, | ||
CamelCaseNonContiguousPrefix = 7, | ||
CamelCaseSubstring = 8, | ||
CamelCaseNonContiguousSubstring = 9, | ||
Fuzzy = 10 | ||
} |
72 changes: 72 additions & 0 deletions
72
src/Tools/ExternalAccess/OmniSharp/NavigateTo/OmniSharpNavigateToSearchService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Navigation; | ||
using Microsoft.CodeAnalysis.NavigateTo; | ||
using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
|
||
namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.NavigateTo; | ||
|
||
internal static class OmniSharpNavigateToSearcher | ||
{ | ||
public delegate Task OmniSharpNavigateToCallback(Project project, in OmniSharpNavigateToSearchResult result, CancellationToken cancellationToken); | ||
|
||
public static Task SearchAsync( | ||
Solution solution, | ||
OmniSharpNavigateToCallback callback, | ||
string searchPattern, | ||
IImmutableSet<string> kinds, | ||
CancellationToken cancellationToken) | ||
{ | ||
var searcher = NavigateToSearcher.Create( | ||
solution, | ||
AsynchronousOperationListenerProvider.NullListener, | ||
new OmniSharpNavigateToCallbackImpl(callback), | ||
searchPattern, | ||
kinds, | ||
disposalToken: CancellationToken.None); | ||
|
||
return searcher.SearchAsync(searchCurrentDocument: false, cancellationToken); | ||
} | ||
|
||
private sealed class OmniSharpNavigateToCallbackImpl : INavigateToSearchCallback | ||
{ | ||
private readonly OmniSharpNavigateToCallback _callback; | ||
|
||
public OmniSharpNavigateToCallbackImpl(OmniSharpNavigateToCallback callback) | ||
{ | ||
_callback = callback; | ||
} | ||
|
||
public Task AddItemAsync(Project project, INavigateToSearchResult result, CancellationToken cancellationToken) | ||
{ | ||
var omniSharpResult = new OmniSharpNavigateToSearchResult( | ||
result.AdditionalInformation, | ||
result.Kind, | ||
(OmniSharpNavigateToMatchKind)result.MatchKind, | ||
result.IsCaseSensitive, | ||
result.Name, | ||
result.NameMatchSpans, | ||
result.SecondarySort, | ||
result.Summary, | ||
new(result.NavigableItem.DisplayTaggedParts, result.NavigableItem.Document, result.NavigableItem.SourceSpan)); | ||
|
||
return _callback(project, omniSharpResult, cancellationToken); | ||
} | ||
|
||
public void Done(bool isFullyLoaded) | ||
{ | ||
} | ||
|
||
public void ReportProgress(int current, int maximum) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters