Skip to content

Commit 9eeba30

Browse files
committed
Moved GetAstNodeByLineAndColumn to a generic method
1 parent 563e98d commit 9eeba30

File tree

1 file changed

+16
-0
lines changed
  • src/PowerShellEditorServices/Services/PowerShell/Refactoring

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ namespace Microsoft.PowerShell.EditorServices.Refactoring
1111
internal class Utilities
1212
{
1313

14+
public static Ast GetAstNodeByLineAndColumn(int StartLineNumber, int StartColumnNumber, Ast ScriptAst,params Type[] type)
15+
{
16+
Ast result = null;
17+
result = ScriptAst.Find(ast =>
18+
{
19+
return ast.Extent.StartLineNumber == StartLineNumber &&
20+
ast.Extent.StartColumnNumber == StartColumnNumber &&
21+
type.Contains(ast.GetType());
22+
}, true);
23+
if (result == null)
24+
{
25+
throw new TargetSymbolNotFoundException();
26+
}
27+
return result;
28+
}
29+
1430
public static Ast LookForParentOfType(Ast ast, params Type[] type)
1531
{
1632
Ast parent = ast;

0 commit comments

Comments
 (0)