File tree 1 file changed +5
-15
lines changed
1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -631,30 +631,20 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanTwoPositiona
631
631
632
632
// Because of the way we count, we will also count the cmdlet as an argument so we have to -1
633
633
int argumentsWithoutProcedingParameters = - 1 ;
634
- bool parameterPreceding = false ;
635
634
636
- foreach ( CommandElementAst ceAst in cmdAst . CommandElements )
637
- {
638
- var cmdParamAst = ceAst as CommandParameterAst ;
639
- if ( cmdParamAst != null )
640
- {
641
- parameterPreceding = true ;
642
- } else
635
+ var commandElementCollection = cmdAst . CommandElements ;
636
+ for ( int i = 0 ; i < commandElementCollection . Count ( ) ; i ++ ) {
637
+ if ( ! ( commandElementCollection [ i ] is CommandParameterAst ) && ( i == 0 || ! ( commandElementCollection [ i - 1 ] is CommandParameterAst ) ) )
643
638
{
644
- if ( ! parameterPreceding )
645
- {
646
- argumentsWithoutProcedingParameters += 1 ;
647
- }
648
- parameterPreceding = false ;
639
+ argumentsWithoutProcedingParameters ++ ;
649
640
}
650
641
}
651
642
652
643
// if not the first element in a pipeline, increase the number of arguments by 1
653
644
PipelineAst parent = cmdAst . Parent as PipelineAst ;
654
-
655
645
if ( parent != null && parent . PipelineElements . Count > 1 && parent . PipelineElements [ 0 ] != cmdAst )
656
646
{
657
- argumentsWithoutProcedingParameters += 1 ;
647
+ argumentsWithoutProcedingParameters ++ ;
658
648
}
659
649
660
650
return moreThanTwoPositional ? argumentsWithoutProcedingParameters > 2 : argumentsWithoutProcedingParameters > 0 ;
You can’t perform that action at this time.
0 commit comments