Skip to content

Commit bc1ba49

Browse files
committed
Renaming methods to be clearer
1 parent 1b7246f commit bc1ba49

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public IterativeFunctionRename(string OldName, string NewName, int StartLineNumb
3030
this.StartColumnNumber = StartColumnNumber;
3131
this.ScriptAst = ScriptAst;
3232

33-
Ast Node = Utilities.GetAstNodeByLineAndColumn(StartLineNumber, StartColumnNumber, ScriptAst,
33+
Ast Node = Utilities.GetAstAtPositionOfType(StartLineNumber, StartColumnNumber, ScriptAst,
3434
typeof(FunctionDefinitionAst), typeof(CommandAst));
3535

3636
if (Node != null)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public IterativeVariableRename(string NewName, int StartLineNumber, int StartCol
4343
isParam = true;
4444
Ast parent = Node;
4545
// Look for a target function that the parameterAst will be within if it exists
46-
parent = Utilities.LookForParentOfType(parent, typeof(FunctionDefinitionAst));
46+
parent = Utilities.GetAstParentOfType(parent, typeof(FunctionDefinitionAst));
4747
if (parent != null)
4848
{
4949
TargetFunction = (FunctionDefinitionAst)parent;
@@ -60,7 +60,7 @@ public static Ast GetVariableTopAssignment(int StartLineNumber, int StartColumnN
6060
{
6161

6262
// Look up the target object
63-
Ast node = Utilities.GetAstNodeByLineAndColumn(StartLineNumber, StartColumnNumber,
63+
Ast node = Utilities.GetAstAtPositionOfType(StartLineNumber, StartColumnNumber,
6464
ScriptAst, typeof(VariableExpressionAst), typeof(CommandParameterAst), typeof(StringConstantExpressionAst));
6565

6666
string name = node switch
@@ -77,7 +77,7 @@ public static Ast GetVariableTopAssignment(int StartLineNumber, int StartColumnN
7777
if (node is StringConstantExpressionAst)
7878
{
7979
Ast parent = node;
80-
parent = Utilities.LookForParentOfType(parent, typeof(AssignmentStatementAst));
80+
parent = Utilities.GetAstParentOfType(parent, typeof(AssignmentStatementAst));
8181
if (parent is not null and AssignmentStatementAst assignmentStatementAst)
8282
{
8383
splatAssignment = (VariableExpressionAst)assignmentStatementAst.Left.Find(
@@ -181,7 +181,7 @@ internal static Ast GetAstParentScope(Ast node)
181181
{
182182
Ast parent = node;
183183
// Walk backwards up the tree looking for a ScriptBLock of a FunctionDefinition
184-
parent = Utilities.LookForParentOfType(parent, typeof(ScriptBlockAst), typeof(FunctionDefinitionAst));
184+
parent = Utilities.GetAstParentOfType(parent, typeof(ScriptBlockAst), typeof(FunctionDefinitionAst));
185185
if (parent is ScriptBlockAst && parent.Parent != null && parent.Parent is FunctionDefinitionAst)
186186
{
187187
parent = parent.Parent;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 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)
14+
public static Ast GetAstAtPositionOfType(int StartLineNumber, int StartColumnNumber, Ast ScriptAst, params Type[] type)
1515
{
1616
Ast result = null;
1717
result = ScriptAst.Find(ast =>
@@ -27,7 +27,7 @@ public static Ast GetAstNodeByLineAndColumn(int StartLineNumber, int StartColumn
2727
return result;
2828
}
2929

30-
public static Ast LookForParentOfType(Ast ast, params Type[] type)
30+
public static Ast GetAstParentOfType(Ast ast, params Type[] type)
3131
{
3232
Ast parent = ast;
3333
// walk backwards till we hit a parent of the specified type or return null
@@ -46,7 +46,7 @@ public static Ast LookForParentOfType(Ast ast, params Type[] type)
4646
public static FunctionDefinitionAst GetFunctionDefByCommandAst(string OldName, int StartLineNumber, int StartColumnNumber, Ast ScriptFile)
4747
{
4848
// Look up the targetted object
49-
CommandAst TargetCommand = (CommandAst)Utilities.GetAstNodeByLineAndColumn(StartLineNumber, StartColumnNumber, ScriptFile
49+
CommandAst TargetCommand = (CommandAst)Utilities.GetAstAtPositionOfType(StartLineNumber, StartColumnNumber, ScriptFile
5050
, typeof(CommandAst));
5151

5252
if (TargetCommand.GetCommandName().ToLower() != OldName.ToLower())

0 commit comments

Comments
 (0)