Merge pull request #1137 from sharwell/nested-actions

Support CodeAction.NestedActions via light-up
This commit is contained in:
Sam Harwell 2023-12-27 13:48:12 -06:00 коммит произвёл GitHub
Родитель df43702e4a 0aa8da7d5f
Коммит c15f87dc94
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 20 добавлений и 4 удалений

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

@ -164,7 +164,7 @@ namespace Microsoft.CodeAnalysis.Testing
for (var i = builder.Count - 1; i >= 0; i--)
{
var action = builder[i];
var nestedActions = action.NestedCodeActions();
var nestedActions = action.NestedActions();
if (!nestedActions.IsEmpty)
{
builder.RemoveAt(i);

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

@ -11,13 +11,29 @@ namespace Microsoft.CodeAnalysis.Testing
{
internal static class CodeActionExtensions
{
private static readonly Func<CodeAction, ImmutableArray<CodeAction>> s_nestedActions =
LightupHelpers.CreatePropertyAccessor<CodeAction, ImmutableArray<CodeAction>>(
typeof(CodeAction),
nameof(NestedActions),
defaultValue: default);
private static readonly Func<CodeAction, ImmutableArray<CodeAction>> s_nestedCodeActions =
LightupHelpers.CreatePropertyAccessor<CodeAction, ImmutableArray<CodeAction>>(
typeof(CodeAction),
nameof(NestedCodeActions),
"NestedCodeActions",
defaultValue: ImmutableArray<CodeAction>.Empty);
public static ImmutableArray<CodeAction> NestedCodeActions(this CodeAction action)
=> s_nestedCodeActions(action);
public static ImmutableArray<CodeAction> NestedActions(this CodeAction action)
{
// CodeAction.NestedCodeActions was renamed to CodeAction.NestedActions in
// https://github.com/dotnet/roslyn/pull/71327
var nestedActions = s_nestedActions(action);
if (nestedActions.IsDefault)
{
nestedActions = s_nestedCodeActions(action);
}
return nestedActions;
}
}
}