@@ -31,7 +31,7 @@ public IterativeFunctionRename(string OldName, string NewName, int StartLineNumb
31
31
this . StartColumnNumber = StartColumnNumber ;
32
32
this . ScriptAst = ScriptAst ;
33
33
34
- Ast Node = FunctionRename . GetAstNodeByLineAndColumn ( OldName , StartLineNumber , StartColumnNumber , ScriptAst ) ;
34
+ Ast Node = GetAstNodeByLineAndColumn ( OldName , StartLineNumber , StartColumnNumber , ScriptAst ) ;
35
35
if ( Node != null )
36
36
{
37
37
if ( Node is FunctionDefinitionAst FuncDef )
@@ -218,7 +218,6 @@ ast is CommandAst CommDef &&
218
218
CommDef . GetCommandName ( ) . ToLower ( ) == OldName . ToLower ( ) ;
219
219
} , true ) ;
220
220
}
221
-
222
221
return result ;
223
222
}
224
223
@@ -248,12 +247,7 @@ public static FunctionDefinitionAst GetFunctionDefByCommandAst(string OldName, i
248
247
{
249
248
return FunctionDefinitions [ 0 ] ;
250
249
}
251
- // Sort function definitions
252
- //FunctionDefinitions.Sort((a, b) =>
253
- //{
254
- // return b.Extent.EndColumnNumber + b.Extent.EndLineNumber -
255
- // a.Extent.EndLineNumber + a.Extent.EndColumnNumber;
256
- //});
250
+
257
251
// Determine which function definition is the right one
258
252
FunctionDefinitionAst CorrectDefinition = null ;
259
253
for ( int i = FunctionDefinitions . Count - 1 ; i >= 0 ; i -- )
@@ -262,14 +256,8 @@ public static FunctionDefinitionAst GetFunctionDefByCommandAst(string OldName, i
262
256
263
257
Ast parent = element . Parent ;
264
258
// walk backwards till we hit a functiondefinition if any
265
- while ( null != parent )
266
- {
267
- if ( parent is FunctionDefinitionAst )
268
- {
269
- break ;
270
- }
271
- parent = parent . Parent ;
272
- }
259
+ parent = Utilities . LookForParentOfType < FunctionDefinitionAst > ( parent ) ;
260
+
273
261
// we have hit the global scope of the script file
274
262
if ( null == parent )
275
263
{
0 commit comments