-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add ExternalAccess for INavigateToSearcherService #63386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/Tools/ExternalAccess/OmniSharp/NavigateTo/OmniSharpNavigateToSearchResult.cs
This file contains hidden or 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 hidden or 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); | ||
|
333fred marked this conversation as resolved.
|
||
|
|
||
| return searcher.SearchAsync(searchCurrentDocument: false, cancellationToken); | ||
| } | ||
|
|
||
| private class OmniSharpNavigateToCallbackImpl : INavigateToSearchCallback | ||
|
333fred marked this conversation as resolved.
Outdated
|
||
| { | ||
| 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.