protected final void writeParameters(Declaration decl) throws IOException {
   if (decl instanceof Functional) {
     boolean first = true;
     List<ParameterList> parameterLists = ((Functional) decl).getParameterLists();
     for (ParameterList parameterList : parameterLists) {
       for (Parameter parameter : parameterList.getParameters()) {
         String doc = getDoc(parameter, linkRenderer());
         if (!doc.isEmpty()) {
           if (first) {
             first = false;
             open("div class='parameters section'");
             around("span class='title'", "Parameters: ");
             open("ul");
           }
           open("li");
           write(parameter.getName());
           write(doc);
           close("li");
         }
       }
     }
     if (!first) {
       close("ul");
       close("div");
     }
   }
 }
 private JCTree makeCallTypedMethod(
     List<JCStatement> body, java.util.List<ProducedType> parameterTypes) {
   // make the method
   MethodDefinitionBuilder methodBuilder =
       MethodDefinitionBuilder.method(gen, false, Naming.getCallableTypedMethodName());
   methodBuilder.modifiers(Flags.PRIVATE);
   ProducedType returnType = gen.getReturnTypeOfCallable(typeModel);
   methodBuilder.resultType(gen.makeJavaType(returnType, JT_NO_PRIMITIVES), null);
   // add all parameters
   int i = 0;
   for (Parameter param : paramLists.getParameters()) {
     ParameterDefinitionBuilder parameterBuilder =
         ParameterDefinitionBuilder.instance(gen, param.getName());
     JCExpression paramType = gen.makeJavaType(parameterTypes.get(i));
     parameterBuilder.type(paramType, null);
     methodBuilder.parameter(parameterBuilder);
     i++;
   }
   // Return the call result, or null if a void method
   methodBuilder.body(body);
   return methodBuilder.build();
 }
  protected final void writeParameterList(Functional f) throws IOException {
    for (ParameterList lists : f.getParameterLists()) {
      write("(");
      boolean first = true;
      for (Parameter param : lists.getParameters()) {
        if (!first) {
          write(", ");
        } else {
          first = false;
        }

        if (param instanceof FunctionalParameter) {
          writeFunctionalParameter((FunctionalParameter) param);
        } else if (param.isSequenced()) {
          writeSequencedParameter(param);
        } else {
          linkRenderer().to(param.getType()).write();
          write(" ", param.getName());
        }
      }
      write(")");
    }
  }
 public MethodDefinitionBuilder parameter(Parameter param, int flags) {
   String paramName = param.getName();
   String aliasedName = paramName;
   MethodOrValue mov = CodegenUtil.findMethodOrValueForParam(param);
   int mods = 0;
   if (!(mov instanceof Value) || !mov.isVariable() || mov.isCaptured()) {
     mods |= FINAL;
   }
   if (mov instanceof Method || mov instanceof Value && mov.isVariable() && mov.isCaptured()) {
     aliasedName = Naming.getAliasedParameterName(param);
   }
   TypedDeclaration nonWideningDecl;
   ProducedType nonWideningType;
   if (mov instanceof Value) {
     ProducedTypedReference typedRef = gen.getTypedReference(mov);
     ProducedTypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef);
     nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef);
     nonWideningDecl = nonWideningTypedRef.getDeclaration();
   } else {
     nonWideningType = param.getType();
     nonWideningDecl = param;
   }
   return parameter(mods, paramName, aliasedName, param, nonWideningDecl, nonWideningType, flags);
 }
 public MethodDefinitionBuilder parameter(
     Parameter paramDecl, ProducedType paramType, int mods, int flags) {
   String name = paramDecl.getName();
   return parameter(mods, name, paramDecl, paramDecl, paramType, flags);
 }
Exemplo n.º 6
0
 @Override
 public String toString() {
   return parameter.getName() + " = " + term;
 }
 private String getCallableTempVarName(Parameter param) {
   // prefix them with $$ if we only forward, otherwise we need them to have the proper names
   return forwardCallTo != null ? Naming.getCallableTempVarName(param) : param.getName();
 }
 private void writeSequencedParameter(Parameter param) throws IOException {
   ProducedType sequencedParamType = param.getUnit().getIteratedType(param.getType());
   linkRenderer().to(sequencedParamType).write();
   write("...");
   write(" ", param.getName());
 }