Fixes an arguments array to fit a given length,
the last value is an array filled with varargs.
@param length
@param varArgType
@param arguments
@return fixed arguments array
557237
@SuppressWarnings("SuspiciousSystemArraycopy")
    public static Object[] fixVarArgs(int length, Class<?> varArgType, Object[] arguments) {
        final Object[] result;
        if (arguments.length == length && varArgType.isInstance(arguments[length-1])) {
            return arguments;
        } else {
            result = Arrays.copyOf(arguments, length, Object[].class);
        }
        final Object varArgs;
        Class<?> varArgElementType = varArgType.getComponentType();
        if (varArgElementType.isPrimitive()) {
            varArgs = Boxing.unboxAll(varArgElementType, arguments, length-1, -1);
        } else {
            int varLen = arguments.length - length + 1;
            varArgs = Array.newInstance(varArgElementType, varLen);
            System.arraycopy(arguments, length-1, varArgs, 0, varLen);
        }
        result[length-1] = varArgs;
        return result;
    }
594372
private static String convertArgs(String[] args)
    {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < args.length; i++)
        {
            result.append(args[i]);
            if (i < args.length - 1)
            {
                result.append(' ');
            }
        }
        return result.toString().toUpperCase();
    }
326154
public static <T> Array<T> ofLength(final int length) {
		return new Array<T>(ObjectStore.ofLength(length));
	}
229970
private SemanticStatus argumentsMatch(final String[] myargs,
            final String[] other) {
        String my_arg, arg;
        boolean varargs = false;
        for (int i = 0, j = 0;; i++, j++) {

            boolean my_last = (i == (myargs.length - 1));
            boolean other_last = (j == (other.length - 1));

            if (myargs[i].endsWith(VARARGS_SUFFIX)) {
                my_arg = varargsRoot(myargs[i]);
                // stay at position in argument list
                i = i - 1;
                varargs = true;
            } else {
                my_arg = myargs[i];
            }

            arg = other[j];
            final SemanticStatus status = argumentsMatch(my_arg, arg);
            if (status != VALID) return status;

            if (my_last && other_last) {
                break;
            } else if (my_last && !varargs) {
                // You have arguments left to match, I don't.
                return TOO_MANY_ARGUMENTS;
            } else if (other_last) {
                // I have arguments left to match, you don't.
                return TOO_FEW_ARGUMENTS;
            }
        }
        return VALID;
    }
1190371
private static String countArgs(final String s) {
        String[] args = ARGS_REGEX.split(s);
        if ("".equals(args[1])) return "0";

        String[] argarray = args[1].split(",");
        for (final String arg : argarray)
            if (arg.contains(VARARGS_SUFFIX)) return "1 or more";
        return valueOf(argarray.length);
    }
852722
public static String[] stripArgs(String[] originalArgs, int stripCount) {
		if (originalArgs.length <= stripCount) {
			return new String[0];
		}
		String[] stripped = new String[originalArgs.length - stripCount];
		for (int i = 0; i < stripped.length; i++) {
			stripped[i] = originalArgs[i+stripCount];
		}
		return stripped;
	}
194610
private static Class<?>[] convertArgumentTypesToPrimitive(Class<?>[] paramTypes, Object[] arguments) {
        Class<?>[] types = new Class<?>[arguments.length];
        for (int i = 0; i < arguments.length; i++) {
            Class<?> argumentType = null;
            if (arguments[i] == null) {
                argumentType = paramTypes[i];
            } else {
                argumentType = getType(arguments[i]);
            }
            Class<?> primitiveWrapperType = PrimitiveWrapper.getPrimitiveFromWrapperType(argumentType);
            if (primitiveWrapperType == null) {
                types[i] = argumentType;
            } else {
                types[i] = primitiveWrapperType;
            }
        }
        return types;
    }
380592
public static Object[] values( TypedArgument... arguments )
    {
        Object[] values = new Object[arguments.length];
        for ( int i = 0; i < values.length; i++ )
        {
            values[i] = arguments[i].value;
        }
        return values;
    }
470161
private function fixArgs(array $args, array $parsedVars = []): array
    {
        array_shift($args); // script name
        $vars     = [];
        $position = 0;
        foreach ($args as $arg) {
            if (isset($parsedVars[substr($arg, 1)]) || isset($parsedVars[substr($arg, 2)]) || in_array($arg, $parsedVars)) {
                continue;
            }

            $vars['argv.' . $position] = $arg;
            $position++;
        }

        return array_merge($vars, $parsedVars);
    }
576390
public EasyRandomParameters stringLengthRange(final int minStringLength, final int maxStringLength) {
        if (minStringLength < 0) {
            throw new IllegalArgumentException("minStringLength must be >= 0");
        }
        if (minStringLength > maxStringLength) {
            throw new IllegalArgumentException(format("minStringLength (%s) must be <= than maxStringLength (%s)",
                    minStringLength, maxStringLength));
        }
        setStringLengthRange(new Range<>(minStringLength, maxStringLength));
        return this;
    }
38488
public Arguments processArgs(final String[] arguments) {
        useColor = getUseColor();

        final Map<String, Object> definedProps = new HashMap<>();
        final Deque<String> args = new ArrayDeque<>(Arrays.asList(arguments));
        while (!args.isEmpty()) {
            final String arg = args.pop();

            if (isLongForm(arg, "-help") || arg.equals("-h")) {
                justPrintUsage = true;
            } else if (isLongForm(arg, "-version")) {
                justPrintVersion = true;
            } else if (isLongForm(arg, "-plugins")) {
                justPrintPlugins = true;
            } else if (isLongForm(arg, "-transtypes")) {
                justPrintTranstypes = true;
            } else if (isLongForm(arg, "-deliverables")) {
                justPrintDeliverables = true;
            } else if (isLongForm(arg, "-install")) {
                handleArgInstall(arg, args);
            } else if (isLongForm(arg, "-project") || arg.equals("-p")) {
                handleArgProject(arg, args);
            } else if (isLongForm(arg, "-force")) {
                definedProps.put("force", "true");
            } else if (isLongForm(arg, "-uninstall")) {
                handleArgUninstall(arg, args);
            } else if (isLongForm(arg, "-diagnostics")) {
                justPrintDiagnostics = true;
            } else if (isLongForm(arg, "-verbose") || arg.equals("-v")) {
                msgOutputLevel = Project.MSG_INFO;
            } else if (isLongForm(arg, "-debug") || arg.equals("-d")) {
                msgOutputLevel = Project.MSG_VERBOSE;
            } else if (isLongForm(arg, "-noinput")) {
                allowInput = false;
            } else if (isLongForm(arg, "-logfile") || arg.equals("-l")) {
                handleArgLogFile(arg, args);
            } else if (isLongForm(arg, "-buildfile") || isLongForm(arg, "-file")) { //|| arg.equals("-f")
                handleArgBuildFile(args);
            } else if (isLongForm(arg, "-listener")) {
                handleArgListener(args);
            } else if (arg.startsWith("-D")) {
                handleArgDefine(arg, args);
            } else if (isLongForm(arg, "-logger")) {
                handleArgLogger(args);
            } else if (isLongForm(arg, "-inputhandler")) {
                handleArgInputHandler(args);
            } else if (isLongForm(arg, "-emacs") || arg.equals("-e")) {
                emacsMode = true;
            } else if (isLongForm(arg, "-propertyfile")) {
                handleArgPropertyFile(arg, args);
            } else if (arg.equals("-k") || isLongForm(arg, "-keep-going")) {
                keepGoingMode = true;
            } else if (isLongForm(arg, "-nice")) {
                handleArgNice(args);
            } else if (isLongForm(arg, "-input") || arg.equals("-i")) {
                handleArgInput(arg, args, ARGUMENTS.get(getArgumentName(arg)));
            } else if (ARGUMENTS.containsKey(getArgumentName(arg))) {
                definedProps.putAll(handleParameterArg(arg, args, ARGUMENTS.get(getArgumentName(arg))));
            } else if (getPluginArguments().containsKey(getArgumentName(arg))) {
                definedProps.putAll(handleParameterArg(arg, args, getPluginArguments().get(getArgumentName(arg))));
            } else if (LAUNCH_COMMANDS.contains(arg)) {
                // catch script/ant mismatch with a meaningful message
                // we could ignore it, but there are likely to be other
                // version problems, so we stamp down on the configuration now
                final String msg = "Ant's Main method is being handed " + "an option " + arg
                        + " that is only for the launcher class."
                        + "\nThis can be caused by a version mismatch between "
                        + "the ant script/.bat file and Ant itself.";
                throw new BuildException(msg);
            } else if (isLongForm(arg, "-autoproxy")) {
                proxy = true;
            } else if (arg.startsWith("-") || arg.startsWith("/")) {
                // we don't have any more args to recognize!
                throw new IllegalArgumentException(arg);
            } else {
                // if it's no other arg, it may be the target
                targets.addElement(arg);
            }
        }
        if (!inputs.isEmpty()) {
            definedProps.put("args.input", inputs.get(0));
        }

        if (install && msgOutputLevel < Project.MSG_INFO) {
            emacsMode = true;
        }

        definedProps.putAll(loadPropertyFiles());

        return new Arguments(useColor, msgOutputLevel, buildFile, install, installFile, projectFile, uninstallId,
                inputs, targets, listeners, propertyFiles, allowInput, keepGoingMode, loggerClassname,
                inputHandlerClassname, emacsMode, threadPriority, proxy, justPrintUsage, justPrintVersion,
                justPrintDiagnostics, justPrintPlugins, justPrintTranstypes, justPrintDeliverables, logFile,
                definedProps);
    }
182286
public Type addArguments(List<Type> argTypes) {
    Type t = this;
    for (Type a : argTypes) {
      t = t.addArgument(a);
    }
    return t;
  }
892737
private static boolean hasTypeVariables(final Type type) {
        if (type instanceof TypeVariable<?> || type instanceof GenericArrayType) {
            return true;
        } else if (type instanceof ParameterizedType) {
            for (final Type arg : ((ParameterizedType) type).getActualTypeArguments()) {
                if (hasTypeVariables(arg)) {
                    return true;
                }
            }
        }
        return false;
    }
765956
private void add( final List<String> arguments,
                      final String argument )
    {
        if( argument != null && argument.trim().length() > 0 )
        {
            arguments.add( argument );
        }
    }
130110
def _format_arg_list(args, variadic=False):
    
    def sugar(s):
        """Shorten strings that are too long for decency."""
        s = s.replace("{", "{{").replace("}", "}}")
        if len(s) > 50:
            return s[:20] + " ... " + s[-20:]
        else:
            return s

    def arg_to_str(arg):
        """Convert argument to a string."""
        if isinstance(arg, str):
            return sugar(repr(arg))
        elif arg is Parameter.empty:
            return '\u2014'
        else:
            return sugar(str(arg))

    if not args:
        if variadic:
            return "(\u2026)"
        else:
            return "()"

    return "(" + ", ".join(map(arg_to_str, args)) + ")"
674911
public String[] parse(final String[] args) {
    parsed = new HashMap<String, String>(options.size());
    ArrayList<String> unparsed = null;
    for (int i = 0; i < args.length; i++) {
      final String arg = args[i];
      String[] opt = options.get(arg);
      if (opt != null) {  // Perfect match: got --foo
        if (opt[0] != null) {  // This option requires an argument.
          if (++i < args.length) {
            parsed.put(arg, args[i]);
          } else {
            throw new IllegalArgumentException("Missing argument for " + arg);
          }
        } else {
          parsed.put(arg, null);
        }
        continue;
      }
      // Is it a --foo=blah?
      final int equal = arg.indexOf('=', 1);
      if (equal > 0) {  // Looks like so.
        final String name = arg.substring(0, equal);
        opt = options.get(name);
        if (opt != null) {
          parsed.put(name, arg.substring(equal + 1, arg.length()));
          continue;
        }
      }
      // Not a flag.
      if (unparsed == null) {
        unparsed = new ArrayList<String>(args.length - i);
      }
      if (!arg.isEmpty() && arg.charAt(0) == '-') {
        if (arg.length() == 2 && arg.charAt(1) == '-') {  // `--'
          for (i++; i < args.length; i++) {
            unparsed.add(args[i]);
          }
          break;
        }
        throw new IllegalArgumentException("Unrecognized option " + arg);
      }
      unparsed.add(arg);
    }
    if (unparsed != null) {
      return unparsed.toArray(new String[unparsed.size()]);
    } else {
      return new String[0];
    }
  }
768613
function List(length) {
        if (arguments.length === 0) {
            length = 0;
        }

        // in this case we create a list with a given length
        if (arguments.length <= 1 && typeof length === 'number') {
            if (this instanceof List) {
                this.length = length;
            }
            else {
                return new List(length);
            }
        }
        else {
            //here we create a list with initial values
            if (!(this instanceof List)) {
                return List.fromArray(arrSlice(arguments));
            }
            else {
                for (var i = 0, l = arguments.length ; i < l ; i++) {
                    this[i] = arguments[i];
                }
                this.length = arguments.length;
            }
        }
    }