Skip to content

Commit e620586

Browse files
committed
adjusted LookForParent so it accepts multiple types to look for
1 parent 3c3d96c commit e620586

File tree

1 file changed

+4
-3
lines changed
  • src/PowerShellEditorServices/Services/PowerShell/Refactoring

1 file changed

+4
-3
lines changed

src/PowerShellEditorServices/Services/PowerShell/Refactoring/Utilities.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Linq;
67
using System.Management.Automation.Language;
@@ -10,13 +11,13 @@ namespace Microsoft.PowerShell.EditorServices.Refactoring
1011
internal class Utilities
1112
{
1213

13-
public static Ast LookForParentOfType<T>(Ast ast)
14+
public static Ast LookForParentOfType(Ast ast, params Type[] type)
1415
{
15-
Ast parent = ast.Parent;
16+
Ast parent = ast;
1617
// walk backwards till we hit a parent of the specified type or return null
1718
while (null != parent)
1819
{
19-
if (typeof(T) == parent.GetType())
20+
if (type.Contains(parent.GetType()))
2021
{
2122
return parent;
2223
}

0 commit comments

Comments
 (0)