Esempio n. 1
0
 @Override
 public Void visitFunctionTypeAlias(FunctionTypeAlias node) {
   writer.print("typedef ");
   visit(node.getReturnType(), " ");
   visit(node.getName());
   visit(node.getTypeParameters());
   visit(node.getParameters());
   writer.print(";");
   return null;
 }
Esempio n. 2
0
  @Override
  public Void visitFunctionTypeAlias(FunctionTypeAlias node) {
    ElementHolder holder = new ElementHolder();
    visitChildren(holder, node);

    SimpleIdentifier aliasName = node.getName();
    ParameterElement[] parameters = holder.getParameters();
    TypeAliasElementImpl element = new TypeAliasElementImpl(aliasName);
    element.setParameters(parameters);
    element.setTypeVariables(holder.getTypeVariables());

    ArrayList<Type> normalParameterTypes = new ArrayList<Type>();
    ArrayList<Type> optionalParameterTypes = new ArrayList<Type>();
    LinkedHashMap<String, Type> namedParameterTypes = new LinkedHashMap<String, Type>();
    for (ParameterElement parameter : parameters) {
      switch (parameter.getParameterKind()) {
        case REQUIRED:
          normalParameterTypes.add(parameter.getType());
          break;
        case POSITIONAL:
          optionalParameterTypes.add(parameter.getType());
          break;
        case NAMED:
          namedParameterTypes.put(parameter.getName(), parameter.getType());
          break;
      }
    }
    TypeName returnType = node.getReturnType();
    FunctionTypeImpl functionType = new FunctionTypeImpl(element);
    functionType.setNormalParameterTypes(
        normalParameterTypes.toArray(new Type[normalParameterTypes.size()]));
    functionType.setOptionalParameterTypes(
        optionalParameterTypes.toArray(new Type[optionalParameterTypes.size()]));
    functionType.setNamedParameterTypes(namedParameterTypes);
    if (returnType != null) {
      functionType.setReturnType(returnType.getType());
    }
    element.setType(functionType);

    currentHolder.addTypeAlias(element);
    aliasName.setElement(element);
    return null;
  }
Esempio n. 3
0
  @Override
  public Void visitFunctionTypeAlias(FunctionTypeAlias node) {
    ElementHolder holder = new ElementHolder();
    visitChildren(holder, node);

    SimpleIdentifier aliasName = node.getName();
    ParameterElement[] parameters = holder.getParameters();
    TypeParameterElement[] typeParameters = holder.getTypeParameters();
    FunctionTypeAliasElementImpl element = new FunctionTypeAliasElementImpl(aliasName);
    element.setParameters(parameters);
    element.setTypeParameters(typeParameters);

    FunctionTypeImpl type = new FunctionTypeImpl(element);
    type.setTypeArguments(createTypeParameterTypes(typeParameters));
    element.setType(type);

    currentHolder.addTypeAlias(element);
    aliasName.setStaticElement(element);
    holder.validate();
    return null;
  }