@@ -275,7 +275,13 @@ public object VisitCommandParameter(CommandParameterAst commandParameterAst)
275275 public object VisitConfigurationDefinition ( ConfigurationDefinitionAst configurationDefinitionAst ) => throw new NotImplementedException ( ) ;
276276 public object VisitConstantExpression ( ConstantExpressionAst constantExpressionAst ) => null ;
277277 public object VisitContinueStatement ( ContinueStatementAst continueStatementAst ) => throw new NotImplementedException ( ) ;
278- public object VisitConvertExpression ( ConvertExpressionAst convertExpressionAst ) => throw new NotImplementedException ( ) ;
278+ public object VisitConvertExpression ( ConvertExpressionAst convertExpressionAst )
279+ {
280+ // TODO figure out if there is a case to visit the type
281+ //convertExpressionAst.Type.Visit(this);
282+ convertExpressionAst . Child . Visit ( this ) ;
283+ return null ;
284+ }
279285 public object VisitDataStatement ( DataStatementAst dataStatementAst ) => throw new NotImplementedException ( ) ;
280286 public object VisitDoUntilStatement ( DoUntilStatementAst doUntilStatementAst )
281287 {
@@ -325,7 +331,13 @@ public object VisitForStatement(ForStatementAst forStatementAst)
325331 public object VisitFunctionDefinition ( FunctionDefinitionAst functionDefinitionAst )
326332 {
327333 ScopeStack . Push ( functionDefinitionAst ) ;
328-
334+ if ( null != functionDefinitionAst . Parameters )
335+ {
336+ foreach ( ParameterAst element in functionDefinitionAst . Parameters )
337+ {
338+ element . Visit ( this ) ;
339+ }
340+ }
329341 functionDefinitionAst . Body . Visit ( this ) ;
330342
331343 ScopeStack . Pop ( ) ;
@@ -353,9 +365,14 @@ public object VisitIfStatement(IfStatementAst ifStmtAst)
353365
354366 return null ;
355367 }
356- public object VisitIndexExpression ( IndexExpressionAst indexExpressionAst ) => throw new NotImplementedException ( ) ;
368+ public object VisitIndexExpression ( IndexExpressionAst indexExpressionAst ) {
369+ indexExpressionAst . Target . Visit ( this ) ;
370+ indexExpressionAst . Index . Visit ( this ) ;
371+ return null ;
372+ }
357373 public object VisitInvokeMemberExpression ( InvokeMemberExpressionAst invokeMemberExpressionAst ) => throw new NotImplementedException ( ) ;
358- public object VisitMemberExpression ( MemberExpressionAst memberExpressionAst ) {
374+ public object VisitMemberExpression ( MemberExpressionAst memberExpressionAst )
375+ {
359376 memberExpressionAst . Expression . Visit ( this ) ;
360377 return null ;
361378 }
@@ -369,9 +386,25 @@ public object VisitNamedBlock(NamedBlockAst namedBlockAst)
369386 }
370387 return null ;
371388 }
372- public object VisitParamBlock ( ParamBlockAst paramBlockAst ) => throw new NotImplementedException ( ) ;
373- public object VisitParameter ( ParameterAst parameterAst ) => throw new NotImplementedException ( ) ;
374- public object VisitParenExpression ( ParenExpressionAst parenExpressionAst ) {
389+ public object VisitParamBlock ( ParamBlockAst paramBlockAst )
390+ {
391+ foreach ( ParameterAst element in paramBlockAst . Parameters )
392+ {
393+ element . Visit ( this ) ;
394+ }
395+ return null ;
396+ }
397+ public object VisitParameter ( ParameterAst parameterAst )
398+ {
399+ parameterAst . Name . Visit ( this ) ;
400+ foreach ( AttributeBaseAst element in parameterAst . Attributes )
401+ {
402+ element . Visit ( this ) ;
403+ }
404+ return null ;
405+ }
406+ public object VisitParenExpression ( ParenExpressionAst parenExpressionAst )
407+ {
375408 parenExpressionAst . Pipeline . Visit ( this ) ;
376409 return null ;
377410 }
@@ -384,7 +417,10 @@ public object VisitPipeline(PipelineAst pipelineAst)
384417 return null ;
385418 }
386419 public object VisitPropertyMember ( PropertyMemberAst propertyMemberAst ) => throw new NotImplementedException ( ) ;
387- public object VisitReturnStatement ( ReturnStatementAst returnStatementAst ) => throw new NotImplementedException ( ) ;
420+ public object VisitReturnStatement ( ReturnStatementAst returnStatementAst ) {
421+ returnStatementAst . Pipeline . Visit ( this ) ;
422+ return null ;
423+ }
388424 public object VisitScriptBlock ( ScriptBlockAst scriptBlockAst )
389425 {
390426 ScopeStack . Push ( scriptBlockAst ) ;
@@ -472,11 +508,14 @@ public object VisitVariableExpression(VariableExpressionAst variableExpressionAs
472508 else if ( variableExpressionAst . Parent is AssignmentStatementAst assignment &&
473509 assignment . Operator == TokenKind . Equals )
474510 {
475-
511+ if ( ! WithinTargetsScope ( TargetVariableAst , variableExpressionAst ) )
512+ {
476513 DuplicateVariableAst = variableExpressionAst ;
477514 ShouldRename = false ;
478515 }
479516
517+ }
518+
480519 if ( ShouldRename )
481520 {
482521 // have some modifications to account for the dollar sign prefix powershell uses for variables
@@ -494,6 +533,12 @@ public object VisitVariableExpression(VariableExpressionAst variableExpressionAs
494533 }
495534 return null ;
496535 }
497- public object VisitWhileStatement ( WhileStatementAst whileStatementAst ) => throw new NotImplementedException ( ) ;
536+ public object VisitWhileStatement ( WhileStatementAst whileStatementAst )
537+ {
538+ whileStatementAst . Condition . Visit ( this ) ;
539+ whileStatementAst . Body . Visit ( this ) ;
540+
541+ return null ;
542+ }
498543 }
499544}
0 commit comments