-
Notifications
You must be signed in to change notification settings - Fork 196
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
Support FAR in cohosting #11238
base: main
Are you sure you want to change the base?
Support FAR in cohosting #11238
Conversation
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.
overall LGTM. More questions for my learning than anything.
|
||
if (!codeDocument.Source.Text.TryGetAbsoluteIndex(position, out var hostDocumentIndex)) | ||
{ | ||
return NoFurtherHandling; |
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.
❓: Where is this defined? I'm assuming it's something similar to RemoteResponse<null>
?
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.
Yeah, Its on RemoteResponse
: https://github.com/dotnet/razor/blob/main/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Remote/RemoteResponse.cs#L14
Brought in by the using static
above. In my VS is bold, which makes it look less magical.
return NoFurtherHandling; | ||
} | ||
|
||
// Finally, call into C#. |
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.
? referenceItem.Location | ||
: result.Second; | ||
|
||
if (location is null) |
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.
What's the use case for the location being null here? I would have assumed it just didn't get added to the results?
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.
Honestly, I've no idea, but referenceItem.Location
is annotated as nullable so this defensiveness is just to make the compiler happy. I suspect this falls out as a quirk in the VS LSP client, where the underlying VS type doesn't have to specify a location, because navigation can be done by a callback, but callbacks aren't part of LSP.
referenceItem.DisplayPath = mappedUri.AbsolutePath; | ||
referenceItem.DocumentName = mappedUri.AbsolutePath; |
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.
I'm only alive by caffeine right now so excuse my ignorance. Is DisplayName
and DocumentName
supposed to be user friendly in some way? Wouldn't we want something to manipulate this from the AbsolutePath
? Or is that just how it is?
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.
The docs here are not really clear, so I just looked at what was returned by Roslyn, which was full paths, and took that as gospel. I couldn't find any visual evidence in VS that the values are used. The docs say things like DisplayPath is for when "the actual path would be confusing", but whether that means we're doing the right thing because generated document paths are confusing, or the wrong thing because full paths are confusing, is entirely up to individual interpretation.
|
||
namespace Microsoft.CodeAnalysis.Remote.Razor; | ||
|
||
internal sealed class RemoteFindAllReferencesService(in ServiceArgs args) : RazorDocumentServiceBase(in args), IRemoteFindAllReferencesService |
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.
❓ This is the pattern everywhere but I'm not sure I get it. Is it just to avoid making copies of the struct?
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.
This is code written by Dustin, inspired by code written by Tomas, so I'm going to go out on a limb and say "Yes" 😁
Fixes #11237
Needs dotnet/roslyn#76002 and a version bump
Very simple one, though I was a little cheeky. There is basically no code that could be shared, except for code that removes
__o
andk_BackingField
from the results, but those methods operate on VS LSP types. Given cohosting largely uses Roslyn LSP types, and will be exclusively FUSE, and FUSE doesn't have__o
, I just skipped that bit. Confirmed in VS that having cohosting and FUSE on makes for nice looking results with no generated code artifacts.Side note: I don't think anything will ever have
k_BackingField
in the results, but there is zero test coverage so who knows! 😁