Skip to content
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

Cohosting OnAutoInsert endpoint #10674

Closed
wants to merge 38 commits into from

Conversation

alexgav
Copy link
Contributor

@alexgav alexgav commented Jul 26, 2024

Summary of the changes

  • Cohosting endpoint for auto-insert endpoint.

Fixes:
Part of #9519

Notes:

All auto-insert scenarios should be addressed now (Razor, HTML, C#)
Tests will be added in a separate PR since this one has grown large and long enough as it is.

@alexgav alexgav requested a review from a team as a code owner July 26, 2024 03:37
@alexgav alexgav marked this pull request as draft July 26, 2024 03:38
@alexgav alexgav force-pushed the dev/alexgav/CohostingOnAutoInsertEndpoint branch from 061faae to 51deccc Compare July 27, 2024 09:43
@alexgav alexgav force-pushed the dev/alexgav/CohostingOnAutoInsertEndpoint branch from 1bebbf8 to 2587d1f Compare August 9, 2024 07:38
cancellationToken
);
return autoInsertResponseItem is not null
? Response.Results(RemoteInsertTextEdit.FromRoslynAutoInsertResponse(autoInsertResponseItem))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there some mapping that needs to happen, to get the LinePositionSpan contained in this response back to Razor coordinates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes unfortunately. It's done in the original endpoint by the RazorFormattingService. I didn't realize that besides doing code formatting it also remaps document positions from C# to Razor (during CSharpOnTypeFormattingPass from what I can tell).

Does it mean that we need to move RazorFormattingService to the common layer after all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh yeah, I forgot that on type formatting (which this would use internally) works on being given a set of C# edits. Yes, this will need the formatting service to move down.


var codeDocument = await remoteDocumentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);

var languageKind = _documentMappingService.GetLanguageKind(codeDocument, index, rightAssociative: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happened to be looking at the existing AutoInsert endpoint today, for other reasons, and noticed is uses this: https://github.com/dotnet/razor/blob/main/src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/AutoInsert/PreferHtmlInAttributeValuesDocumentPositionStrategy.cs#L19

We'll need to do that here too, to get matching behaviour. Should be able to just move it down to Workspaces, and call the static Instance property etc.

@alexgav alexgav force-pushed the dev/alexgav/CohostingOnAutoInsertEndpoint branch from 98a1ba2 to 6089d38 Compare August 14, 2024 03:48
alexgav and others added 20 commits August 20, 2024 19:25
…rt/AutoClosingTagOnAutoInsertProvider.cs

Co-authored-by: David Wengier <[email protected]>
…rt/IAutoInsertService.cs

Co-authored-by: David Wengier <[email protected]>
@alexgav alexgav force-pushed the dev/alexgav/CohostingOnAutoInsertEndpoint branch from dc85b28 to 53e5186 Compare August 21, 2024 05:24
Moving GetFormatterCodeDocumentAsync() into IDocumentSnapshot (and implementations of that) to allow eaiser differentiation of behavior in remote (cohosting) case where we don't need to check the flag on Project.Configuration.

Also AddUsingStatementsIfNeeded *always* gets called, even in cases when they are not actually needed, so we can't Debug.Fail there.
…the original code does

That allows the code insert double-quotes by delegating to HTML language server after attribute name and equals.
@alexgav alexgav marked this pull request as ready for review August 22, 2024 02:13
@alexgav alexgav closed this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants