Java Code Examples for com.sun.source.tree.ParameterizedTypeTree#getTypeArguments()

The following examples show how to use com.sun.source.tree.ParameterizedTypeTree#getTypeArguments() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) {
    sync(node);
    if (node.getTypeArguments().isEmpty()) {
        scan(node.getType(), null);
        token("<");
        token(">");
    } else {
        builder.open(plusFour);
        scan(node.getType(), null);
        token("<");
        builder.breakOp();
        builder.open(ZERO);
        boolean first = true;
        for (Tree typeArgument : node.getTypeArguments()) {
            if (!first) {
                token(",");
                // TODO(cushon): unify breaks
                builder.breakToFill(" ");
            }
            scan(typeArgument, null);
            first = false;
        }
        builder.close();
        builder.close();
        token(">");
    }
    return null;
}
 
Example 2
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) {
    sync(node);
    if (node.getTypeArguments().isEmpty()) {
        scan(node.getType(), null);
        token("<");
        token(">");
    } else {
        builder.open(plusFour);
        scan(node.getType(), null);
        token("<");
        builder.breakOp();
        builder.open(ZERO);
        boolean first = true;
        for (Tree typeArgument : node.getTypeArguments()) {
            if (!first) {
                token(",");
                // TODO(cushon): unify breaks
                builder.breakToFill(" ");
            }
            scan(typeArgument, null);
            first = false;
        }
        builder.close();
        builder.close();
        token(">");
    }
    return null;
}
 
Example 3
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) {
  sync(node);
  if (node.getTypeArguments().isEmpty()) {
    scan(node.getType(), null);
    token("<");
    token(">");
  } else {
    builder.open(plusFour);
    scan(node.getType(), null);
    token("<");
    builder.breakOp();
    builder.open(ZERO);
    boolean first = true;
    for (Tree typeArgument : node.getTypeArguments()) {
      if (!first) {
        token(",");
        builder.breakOp(" ");
      }
      scan(typeArgument, null);
      first = false;
    }
    builder.close();
    builder.close();
    token(">");
  }
  return null;
}
 
Example 4
Source File: Translator.java    From groovy-cps with Apache License 2.0 5 votes vote down vote up
@Override
public JType visitParameterizedType(ParameterizedTypeTree pt, Void __) {
    JClass base = (JClass)visit(pt.getType());
    List<JClass> args = new ArrayList<>();
    for (Tree arg : pt.getTypeArguments()) {
        args.add((JClass)visit(arg));
    }
    return base.narrow(args);
}