private void tryReplaceArguments ( Scope scope ) { // Find the number of parameters that can be accessed without using `arguments`. Node parametersList = NodeUtil . getFunctionParameters ( scope . getRootNode ( ) ) ; checkState ( parametersList . isParamList ( ) , parametersList ) ; int numParameters = parametersList . getChildCount ( ) ; // Determine the highest index that is used to make an access on `arguments`. By default, assume // that the value is the number of parameters to the function. int highestIndex = getHighestIndex ( numParameters - 1 ) ; if ( highestIndex < 0 ) { return ; } ImmutableSortedMap < Integer , String > argNames = assembleParamNames ( parametersList , highestIndex + 1 ) ; changeMethodSignature ( argNames , parametersList ) ; changeBody ( argNames ) ; }
Tries to optimize all the arguments array access in this scope by assigning a name to each element .