Make it more explicit that we only do code action formatting for C#

This commit is contained in:
David Wengier 2024-08-21 16:25:41 +10:00
Родитель 2c39c207c7
Коммит e45f09468d
6 изменённых файлов: 7 добавлений и 11 удалений

Просмотреть файл

@ -80,9 +80,8 @@ internal sealed class DefaultCSharpCodeActionResolver(
// Remaps the text edits from the generated C# to the razor file,
// as well as applying appropriate formatting.
var formattedEdits = await _razorFormattingService.GetCodeActionEditsAsync(
var formattedEdits = await _razorFormattingService.GetCSharpCodeActionEditsAsync(
documentContext,
RazorLanguageKind.CSharp,
csharpTextEdits,
s_defaultFormattingOptions,
cancellationToken).ConfigureAwait(false);

Просмотреть файл

@ -210,9 +210,8 @@ internal sealed class GenerateMethodCodeActionResolver(
InsertSpaces = _razorLSPOptionsMonitor.CurrentValue.InsertSpaces,
};
var formattedEdits = await _razorFormattingService.GetCodeActionEditsAsync(
var formattedEdits = await _razorFormattingService.GetCSharpCodeActionEditsAsync(
documentContext,
RazorLanguageKind.CSharp,
result,
formattingOptions,
cancellationToken).ConfigureAwait(false);

Просмотреть файл

@ -26,9 +26,8 @@ internal interface IRazorFormattingService
char triggerCharacter,
CancellationToken cancellationToken);
Task<TextEdit[]> GetCodeActionEditsAsync(
Task<TextEdit[]> GetCSharpCodeActionEditsAsync(
DocumentContext documentContext,
RazorLanguageKind kind,
TextEdit[] formattedEdits,
FormattingOptions options,
CancellationToken cancellationToken);

Просмотреть файл

@ -78,8 +78,8 @@ internal class RazorFormattingService(
public Task<TextEdit[]> GetOnTypeFormattingEditsAsync(DocumentContext documentContext, RazorLanguageKind kind, TextEdit[] formattedEdits, FormattingOptions options, int hostDocumentIndex, char triggerCharacter, CancellationToken cancellationToken)
=> ApplyFormattedEditsAsync(documentContext, kind, formattedEdits, options, hostDocumentIndex, triggerCharacter, bypassValidationPasses: false, collapseEdits: false, automaticallyAddUsings: false, cancellationToken: cancellationToken);
public Task<TextEdit[]> GetCodeActionEditsAsync(DocumentContext documentContext, RazorLanguageKind kind, TextEdit[] formattedEdits, FormattingOptions options, CancellationToken cancellationToken)
=> ApplyFormattedEditsAsync(documentContext, kind, formattedEdits, options, hostDocumentIndex: 0, triggerCharacter: '\0', bypassValidationPasses: true, collapseEdits: false, automaticallyAddUsings: true, cancellationToken: cancellationToken);
public Task<TextEdit[]> GetCSharpCodeActionEditsAsync(DocumentContext documentContext, TextEdit[] formattedEdits, FormattingOptions options, CancellationToken cancellationToken)
=> ApplyFormattedEditsAsync(documentContext, RazorLanguageKind.CSharp, formattedEdits, options, hostDocumentIndex: 0, triggerCharacter: '\0', bypassValidationPasses: true, collapseEdits: false, automaticallyAddUsings: true, cancellationToken: cancellationToken);
public async Task<TextEdit[]> GetSnippetFormattingEditsAsync(DocumentContext documentContext, RazorLanguageKind kind, TextEdit[] edits, FormattingOptions options, CancellationToken cancellationToken)
{

Просмотреть файл

@ -188,9 +188,8 @@ public class DefaultCSharpCodeActionResolverTest(ITestOutputHelper testOutput) :
private static IRazorFormattingService CreateRazorFormattingService(Uri documentUri)
{
var razorFormattingService = Mock.Of<IRazorFormattingService>(
rfs => rfs.GetCodeActionEditsAsync(
rfs => rfs.GetCSharpCodeActionEditsAsync(
It.Is<DocumentContext>(c => c.Uri == documentUri),
RazorLanguageKind.CSharp,
It.IsAny<TextEdit[]>(),
It.IsAny<FormattingOptions>(),
It.IsAny<CancellationToken>()) == Task.FromResult(s_defaultFormattedEdits), MockBehavior.Strict);

Просмотреть файл

@ -44,7 +44,7 @@ public abstract class FormattingLanguageServerTestBase(ITestOutputHelper testOut
return SpecializedTasks.EmptyArray<TextEdit>();
}
public Task<TextEdit[]> GetCodeActionEditsAsync(DocumentContext documentContext, RazorLanguageKind kind, TextEdit[] formattedEdits, FormattingOptions options, CancellationToken cancellationToken)
public Task<TextEdit[]> GetCSharpCodeActionEditsAsync(DocumentContext documentContext, TextEdit[] formattedEdits, FormattingOptions options, CancellationToken cancellationToken)
{
return Task.FromResult(formattedEdits);
}