Fix one case where immutable should have been mutable

This commit is contained in:
Andrew Hall (METAL) 2024-07-10 14:07:01 -07:00
Родитель 55a8a699f0
Коммит 0a24790d60
1 изменённых файлов: 5 добавлений и 3 удалений

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

@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.AspNetCore.Razor.LanguageServer.CodeActions.Models;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.VisualStudio.LanguageServer.Protocol;
@ -60,9 +61,10 @@ internal sealed class CreateComponentCodeActionResolver(IDocumentContextFactory
Host = string.Empty,
}.Uri;
ImmutableArray<SumType<TextDocumentEdit, CreateFile, RenameFile, DeleteFile>> documentChanges = [new CreateFile() { Uri = newComponentUri }];
using var documentChanges = new PooledArrayBuilder<SumType<TextDocumentEdit, CreateFile, RenameFile, DeleteFile>>();
documentChanges.Add(new CreateFile() { Uri = newComponentUri });
TryAddNamespaceDirective(codeDocument, newComponentUri, documentChanges);
TryAddNamespaceDirective(codeDocument, newComponentUri, ref documentChanges.AsRef());
return new WorkspaceEdit()
{
@ -70,7 +72,7 @@ internal sealed class CreateComponentCodeActionResolver(IDocumentContextFactory
};
}
private static void TryAddNamespaceDirective(RazorCodeDocument codeDocument, Uri newComponentUri, ImmutableArray<SumType<TextDocumentEdit, CreateFile, RenameFile, DeleteFile>> documentChanges)
private static void TryAddNamespaceDirective(RazorCodeDocument codeDocument, Uri newComponentUri, ref PooledArrayBuilder<SumType<TextDocumentEdit, CreateFile, RenameFile, DeleteFile>> documentChanges)
{
var syntaxTree = codeDocument.GetSyntaxTree();
var namespaceDirective = syntaxTree.Root.DescendantNodes()