Filter out all SeLion Grid args -- They do not apply. Finds the argument names and how many values it can
have through reflection.

Note: this code does not concern itself with {@link Parameter}s that have
{@link Parameter#variableArity()}}
439560
private List<String> removeSeLionArgumentsAndValues(List<String> args) {
        // assume all of the ProcessLauncherConfiguration and LauncherConfiguration arguments should not be forwarded
        Set<Field> fields = new HashSet<>();
        fields.addAll(Arrays.asList(ProcessLauncherConfiguration.class.getDeclaredFields()));
        fields.addAll(Arrays.asList(LauncherConfiguration.class.getDeclaredFields()));

        for (Field field : fields) {
            // we need jcommander parameter fields only
            Parameter parameter = field.getAnnotation(Parameter.class);
            if (parameter == null) {
                continue;
            }

            // get the "arity" (how many values it can have on the command line) of the parameter/argument.
            // for example "-foo bar bar2"  --> argument = -foo --> arity = 2 --> values = {bar, bar2}
            final Class<?> fieldType = field.getType();
            final int arity = (parameter.arity() != -1) ? parameter.arity() :
                (fieldType.equals(Integer.class) || fieldType.equals(Long.class) || fieldType.equals(String.class) ||
                    fieldType.equals(int.class) || fieldType.equals(long.class)) ? 1 : 0;

            if (arity > 0) {
                for (String arg : args) {
                    // when the arg we are processing is one of the @Parameter names
                    if (Arrays.asList(parameter.names()).contains(arg)) {
                        // replace each value with ""
                        for (int x = 1; x <= arity; x += 1 ) {
                            args.set(args.indexOf(arg) + x, "");
                        }
                        // replace the argument with ""
                        args.set(args.indexOf(arg), "");
                    }
                }
                // remove all ""
                args.removeAll(Arrays.asList(""));
            } else {
                // the "arity" of the argument 0. there are no values to worry about.
                // remove all instances of the argument (and/or one of its names) from args
                args.removeAll(Arrays.asList(parameter.names()));
            }
        }

        return args;
    }
32309
Optional<ExecutableElement> findAccessibleNoArgumentInstanceMethod(TypeElement classElement, String methodName) {
        return ElementFilter.methodsIn(elementUtils.getAllMembers(classElement))
                .stream().filter(m -> m.getSimpleName().toString().equals(methodName) && !isPrivate(m) && !isStatic(m))
                .findFirst();
    }
444251
public boolean matches(Class<?>[] args) {
        int i;
        Class<?>[] paras;

        paras = getParameterTypes();
        if (args.length != paras.length) {
            return false;
        }
        for (i = 0; i < args.length; i++) {
            if (!paras[i].isAssignableFrom(args[i])) {
                return false;
            }
        }
        return true;
    }
404114
@SuppressWarnings("unused") // called through reflection by RequestServer
  public GridsV99 list(int version, GridsV99 s) {
    final Key[] gridKeys = KeySnapshot.globalSnapshot().filter(new KeySnapshot.KVFilter() {
      @Override
      public boolean filter(KeySnapshot.KeyInfo k) {
        return Value.isSubclassOf(k._type, Grid.class);
      }
    }).keys();

    s.grids = new GridSchemaV99[gridKeys.length];
    for (int i = 0; i < gridKeys.length; i++) {
      s.grids[i] = new GridSchemaV99();
      s.grids[i].fillFromImpl(getFromDKV("(none)", gridKeys[i], Grid.class));
    }

    return s;
  }
975518
private List<String> getArgClassQualifiedNames(CtMethod method) throws NotFoundException {
        CtClass[] paramTypes = method.getParameterTypes();
        List<String> result = new ArrayList<>(paramTypes.length);
        for (CtClass paramType : paramTypes) {
            result.add(paramType.getName());
        }
        return result;
    }
340769
private static Class<?>[] getParamTypes(Context context, Object... arguments)
    {
        final Collection<Object> params = new ArrayList<>();
        params.add(context);
        params.addAll(Arrays.asList(arguments));
        return UtilReflection.getParamTypes(params.toArray());
    }
893495
public static boolean checkArgs(String[] args) {
	if (args.length < 5) {
	    return false;
	}
	
	if (!(args[0].compareToIgnoreCase("-all") == 0 ||
		    args[0].compareToIgnoreCase("-trn") == 0 ||
		    args[0].compareToIgnoreCase("-tst") == 0) || 
		    args[0].compareToIgnoreCase("-cont") == 0) {
	    return false;
	}
	
	if (args[1].compareToIgnoreCase("-d") != 0) {
	    return false;
	}
	
	if (args[3].compareToIgnoreCase("-o") != 0)
		return false; 
	
	return true;
    }
261156
public static Object[] findMethodWithListParameters(Object service, String methodName, Object[] args) {
        Method method = null;
        try {
            //try to skip the listing of all the methods by checking for exactly what
            //we want first
            method = service.getClass().getMethod(methodName, ConversionUtils.convertParams(args));
            log.debug("Exact method found (skipping list): {}", methodName);
            return new Object[] { method, args };
        } catch (NoSuchMethodException nsme) {
            log.debug("Method not found using exact parameter types");
        }
        List<Method> methods = ConversionUtils.findMethodsByNameAndNumParams(service, methodName, 1);
        log.debug("Found {} methods", methods.size());
        if (methods.isEmpty()) {
            return new Object[] { null, null };
        } else if (methods.size() > 1) {
            log.debug("Multiple methods found with same name and parameter count; parameter conversion will be attempted in order.");
        }
        ArrayList<Object> argsList = new ArrayList<Object>();
        if (args != null) {
            for (Object element : args) {
                argsList.add(element);
            }
        }
        args = new Object[] { argsList };
        Object[] params = null;
        for (int i = 0; i < methods.size(); i++) {
            try {
                method = methods.get(i);
                params = ConversionUtils.convertParams(args, method.getParameterTypes());
                if (argsList.size() > 0 && (argsList.get(0) instanceof IConnection) && (!(params[0] instanceof IConnection))) {
                    // Don't convert first IConnection parameter
                    continue;
                }
                return new Object[] { method, params };
            } catch (Exception ex) {
                log.debug("Parameter conversion failed", ex);
            }
        }
        return nullReturn;
    }
154328
public List/*< String >*/ getParameters( String name )
    {
        if ( _parameters == null || !_parameters.hasParameters())
            return Collections.EMPTY_LIST;
        else {

            List parameters = _parameters.getParameterValues(name);
            if(parameters == null)
                return Collections.EMPTY_LIST;
            else return Collections.unmodifiableList(parameters);
        }
    }
313367
private ParameterName[] parameterNames(Method method) {
        ParameterName[] parameterNames;
        if (method != null) {
            String[] annotatedNames = annotatedParameterNames(method);
            String[] paranamerNames = paranamerParameterNames(method);
            String[] contextNames = contextParameterNames(method);

            parameterNames = new ParameterName[annotatedNames.length];
            for (int i = 0; i < annotatedNames.length; i++) {
                parameterNames[i] = parameterName(annotatedNames, paranamerNames, contextNames, i);
            }
        } else {
            String[] stepMatcherParameterNames = stepMatcher.parameterNames();
            parameterNames = new ParameterName[stepMatcherParameterNames.length];
            for (int i = 0; i < stepMatcherParameterNames.length; i++) {
                parameterNames[i] = new ParameterName(stepMatcherParameterNames[i], false, false);
            }
        }
        return parameterNames;
    }
1253878
def prep_args(arg_info):
    # type: (ArgInfo) -> ResolvedTypes
    

    # pull out any varargs declarations
    filtered_args = [a for a in arg_info.args if getattr(arg_info, 'varargs', None) != a]

    # we don't care about self/cls first params (perhaps we can test if it's an instance/class method another way?)
    if filtered_args and (filtered_args[0] in ('self', 'cls')):
        filtered_args = filtered_args[1:]

    pos_args = []  # type: List[InternalType]
    if filtered_args:
        for arg in filtered_args:
            if isinstance(arg, str) and arg in arg_info.locals:
                # here we know that return type will be of type "type"
                resolved_type = resolve_type(arg_info.locals[arg])
                pos_args.append(resolved_type)
            else:
                pos_args.append(type(UnknownType()))

    varargs = None  # type: Optional[List[InternalType]]
    if arg_info.varargs:
        varargs_tuple = arg_info.locals[arg_info.varargs]
        # It's unclear what all the possible values for 'varargs_tuple' are,
        # so perform a defensive type check since we don't want to crash here.
        if isinstance(varargs_tuple, tuple):
            varargs = [resolve_type(arg) for arg in varargs_tuple[:4]]

    return ResolvedTypes(pos_args=pos_args, varargs=varargs)
271868
private void checkFactoryMethodArguments(int arguments) {
        for (Method m : typeDef.getMethods()) {
            int a = m.getArguments() != null ? m.getArguments().size() : 0;
            if (m.getName().equals(staticFactoryMethod) && a == arguments && m.isStatic()) {
                return;
            }
        }
        throw new IllegalArgumentException("No static method found on " + typeDef.getName() + " with name " + staticFactoryMethod + " and " + arguments + " arguments.");
    }
504525
public List<String> getFilterParameters() {
        final List<String> parameters = new ArrayList<>();
        filterKeysToValues.forEach((filterKey, filterValues) -> {
            filterValues.forEach(filterValue -> {
                final String parameterString = String.format("%s:%s", filterKey, filterValue);
                parameters.add(parameterString);
            });
        });

        return parameters;
    }
1190388
static List<NamedArgument> getNamedArgs( ExtensionContext context ) {
        List<NamedArgument> namedArgs = new ArrayList<>();

        if( context.getTestMethod().get().getParameterCount() > 0 ) {
            try {
                if( context.getClass().getCanonicalName().equals( METHOD_EXTENSION_CONTEXT ) ) {
                    Field field = context.getClass().getSuperclass().getDeclaredField( "testDescriptor" );
                    Object testDescriptor = ReflectionUtil.getFieldValueOrNull( field, context, ERROR );
                    if( testDescriptor != null
                            && testDescriptor.getClass().getCanonicalName().equals( TEST_TEMPLATE_INVOCATION_TEST_DESCRIPTOR ) ) {
                        Object invocationContext = ReflectionUtil.getFieldValueOrNull( "invocationContext", testDescriptor, ERROR );
                        if( invocationContext != null
                                && invocationContext.getClass().getCanonicalName().equals( PARAMETERIZED_TEST_INVOCATION_CONTEXT ) ) {
                            Object arguments = ReflectionUtil.getFieldValueOrNull( "arguments", invocationContext, ERROR );
                            List<Object> args = Arrays.asList( (Object[]) arguments );
                            namedArgs = ParameterNameUtil.mapArgumentsWithParameterNames( context.getTestMethod().get(), args );
                        }
                    }
                }
            } catch( Exception e ) {
                log.warn( ERROR, e );
            }
        }

        return namedArgs;
    }
1125444
public List<String> parse(String[] args) {    // merge args & defaults
        List<String> extras = new ArrayList<>();
        List<String> filteredArgs = filterMonadics(args);          // detect and fill mons
        for (int i = 0; i < filteredArgs.size(); i++) {
            String key = filteredArgs.get(i);
            if (key.equalsIgnoreCase("-h") || key.equalsIgnoreCase("-help")) {
                System.out.println(usage);
                System.exit(0);
            }
            
            if (parameters.containsKey(key)) {
                Parameter param = parameters.get(key);
                param.value = filteredArgs.get(i+1);
                switch(param.paramType) {
                    case INTEGER:
                        try {
                            Integer.parseInt(param.value);
                        } catch (Exception ex) {
                            System.err.println("Invalid parameter " + param.name + ' ' + param.value);
                            System.err.println(usage);
                            System.exit(1);
                        }
                        break;

                    case FLOAT:
                        try {
                            Double.parseDouble(param.value);
                        } catch (Exception ex) {
                            System.err.println("Invalid parameter " + param.name + ' ' + param.value);
                            System.err.println(usage);
                            System.exit(1);
                        }
                        break;
                        
                    default:
                    	// Just to remove unmatched case warning
                }
                i++;
            } else {
                extras.add(key);
            }
        }

        for(String key : parameters.keySet()) {
            Parameter param = parameters.get(key);
            if (param.mandatory && param.value == null) {
                System.err.println("Missing mandatory parameter: " + key);
                System.err.println(usage);
                System.exit(1);
            }
        }

        return extras;   // parsed + defaults
    }
1363850
def FilterArgsFromSemanticProtobuf(protobuf, kwargs):
  """"""
  for descriptor in protobuf.type_infos:
    value = kwargs.pop(descriptor.name, None)
    if value is not None:
      setattr(protobuf, descriptor.name, value)
1335803
protected VariableMap getVariables(List<CallableElementParameter> params, VariableScope variableScope) {
    VariableMap result = Variables.createVariables();

    for (CallableElementParameter param : params) {
      param.applyTo(variableScope, result);
    }

    return result;
  }