private Object[] generateMethodParams(Object method, Object[] astParams) {
    if (!"filter".equals(method)) {
      return astParams; // We only change the signature method for filters
    }

    List<Object> args = new ArrayList<>();
    Map<String, Object> kwargs = new LinkedHashMap<>();

    // 2 -> Ignore the Left Value (0) and the JinjavaInterpreter (1)
    for (Object param: Arrays.asList(astParams).subList(2, astParams.length)) {
      if (param instanceof NamedParameter) {
        NamedParameter namedParameter = (NamedParameter) param;
        kwargs.put(namedParameter.getName(), namedParameter.getValue());
      } else {
        args.add(param);
      }
    }

    return new Object[] {astParams[0], astParams[1], args.toArray(), kwargs};
  }
private Object [ ] generateMethodParams ( Object method , Object [ ] astParams ) { if ( ! "filter" . equals ( method ) ) { return astParams ; } List < Object > args = new ArrayList < > ( ) ; Map < String , Object > kwargs = new LinkedHashMap < > ( ) ; for ( Object param : Arrays . asList ( astParams ) . subList ( 2 , astParams . length ) ) { if ( param instanceof NamedParameter ) { NamedParameter namedParameter = ( NamedParameter ) param ; kwargs . put ( namedParameter . getName ( ) , namedParameter . getValue ( ) ) ; } else { args . add ( param ) ; } } return new Object [ ] { astParams [ 0 ] , astParams [ 1 ] , args . toArray ( ) , kwargs } ; }
/*
We transform the AST parameters to something meaningful to Jinjava.

Functions, expressions and tags will receive the parameters as they are, but filters
have a different signature to what they have in the AST to support named parameters, so
this method transforms their arguments to be the following:

(Left Value, JinjavaInterpreter, Positional Arguments, Named Arguments)