-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expose FAR to cohosting #76002
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
Expose FAR to cohosting #76002
Changes from all commits
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
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
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
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
32 changes: 32 additions & 0 deletions
32
src/Tools/ExternalAccess/Razor/Cohost/Handlers/FindAllReferences.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,32 @@ | ||
// 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.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.LanguageServer.Handler; | ||
using Microsoft.CodeAnalysis.MetadataAsSource; | ||
using Microsoft.CodeAnalysis.Options; | ||
using Microsoft.CodeAnalysis.Shared.TestHooks; | ||
using Microsoft.CodeAnalysis.Text; | ||
using Roslyn.LanguageServer.Protocol; | ||
|
||
namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.Handlers; | ||
|
||
using Location = Roslyn.LanguageServer.Protocol.Location; | ||
|
||
internal static class FindAllReferences | ||
{ | ||
public static async Task<SumType<VSInternalReferenceItem, Location>[]?> FindReferencesAsync(Workspace workspace, Document document, LinePosition linePosition, bool supportsVSExtensions, CancellationToken cancellationToken) | ||
{ | ||
var globalOptions = document.Project.Solution.Services.ExportProvider.GetService<IGlobalOptionService>(); | ||
var metadataAsSourceFileService = document.Project.Solution.Services.ExportProvider.GetService<IMetadataAsSourceFileService>(); | ||
|
||
// Passing null here means this will just collect items in an array builder | ||
var progress = BufferedProgress.Create<SumType<VSInternalReferenceItem, Location>[]>(progress: null); | ||
|
||
await FindAllReferencesHandler.FindReferencesAsync(progress, workspace, document, linePosition, supportsVSExtensions, globalOptions, metadataAsSourceFileService, AsynchronousOperationListenerProvider.NullListener, cancellationToken).ConfigureAwait(false); | ||
|
||
return progress.GetFlattenedValues(); | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might consider having a progress parameter here and passing it in from Razor - otherwise you could be waiting a while for anything to stream in. I don't think you need all the references before you can do anything with them right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now Razor doesn't support streaming at all, because the LSP client middle layer doesn't. Cohosting removes that limitation, but none of our shared code on the Razor file knows how to deal with it, plus we'd have to work out how to stream things from OOP back to devenv to send to the language client, so I just decided to punt all of that until later :)