Merge pull request #1137 from sharwell/nested-actions
Support CodeAction.NestedActions via light-up
This commit is contained in:
Коммит
c15f87dc94
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче