@Override public JCTree visit(final WildcardType n, final Object arg) { //ARG0: TypeBoundKind kind // For < ? extends> or < ? super > or < ? > TypeBoundKind arg0; //ARG1: JCTree inner // A class associated to this type, if any JCTree arg1; if (n.getExtends() != null) { arg0 = new ATypeBoundKind(make.TypeBoundKind(EXTENDS), null); arg1 = n.getExtends().accept(this, arg); } else if (n.getSuper() != null) { arg0 = new ATypeBoundKind(make.TypeBoundKind(SUPER), null); arg1 = n.getSuper().accept(this, arg); } else { arg0 = new ATypeBoundKind(make.TypeBoundKind(UNBOUND), null); arg1 = null; } return new AJCWildcard(make.Wildcard(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null)); }
protected int diffTypeBoundKind(TypeBoundKind oldT, TypeBoundKind newT, int[] bounds) { int localPointer = bounds[0]; if (oldT.kind != newT.kind) { copyTo(localPointer, oldT.pos); printer.print(newT.kind.toString()); localPointer = oldT.pos + oldT.kind.toString().length(); } copyTo(localPointer, bounds[1]); return bounds[1]; }
/** record all tree nodes found by reflection. */ public void reflectiveScan(Object o) { if (o == null) return; if (o instanceof JCTree) { JCTree tree = (JCTree) o; //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64)); expect.add(tree); for (Field f: getFields(tree)) { if (TypeBoundKind.class.isAssignableFrom(f.getType())) { // not part of public API continue; } try { //System.err.println("FIELD: " + f.getName()); if (tree instanceof JCModuleDecl && f.getName().equals("mods")) { // The modifiers will not found by TreeScanner, // but the embedded annotations will be. reflectiveScan(((JCModuleDecl) tree).mods.annotations); } else { reflectiveScan(f.get(tree)); } } catch (IllegalAccessException e) { error(e.toString()); } } } else if (o instanceof List) { List<?> list = (List<?>) o; for (Object item: list) reflectiveScan(item); } else error("unexpected item: " + o); }
/** record all tree nodes found by reflection. */ public void reflectiveScan(Object o) { if (o == null) return; if (o instanceof JCTree) { JCTree tree = (JCTree) o; //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64)); expect.add(tree); for (Field f: getFields(tree)) { if (TypeBoundKind.class.isAssignableFrom(f.getType())) { // not part of public API continue; } try { //System.err.println("FIELD: " + f.getName()); reflectiveScan(f.get(tree)); } catch (IllegalAccessException e) { error(e.toString()); } } } else if (o instanceof List) { List<?> list = (List<?>) o; for (Object item: list) reflectiveScan(item); } else error("unexpected item: " + o); }
public void visitTypeBoundKind(TypeBoundKind that) { try { print("TypeBoundKind:"); } catch (Exception e) { } super.visitTypeBoundKind(that); }
public void visitTypeBoundKind(TypeBoundKind tree) { try { print(String.valueOf(tree.kind)); } catch (IOException e) { throw new UncheckedIOException(e); } }
@Override public boolean visitTypeReference(TypeReference node) { WildcardKind wildcard = node.astWildcard(); if (wildcard == WildcardKind.UNBOUND) { return posSet(node, treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.UNBOUND), null)); } JCExpression result = plainTypeReference(node); result = addWildcards(node, result, wildcard); result = addDimensions(node, result, node.astArrayDimensions()); return set(node, result); }
private JCExpression addWildcards(Node node, JCExpression type, WildcardKind wildcardKind) { TypeBoundKind typeBoundKind; switch (wildcardKind) { case NONE: return type; case EXTENDS: typeBoundKind = treeMaker.TypeBoundKind(BoundKind.EXTENDS); Position jcExtendsPos = getConversionPositionInfo(node, "extends"); if (jcExtendsPos == null) { setPos(posOfStructure(node, "extends", true), posOfStructure(node, "extends", false), typeBoundKind); } else { setPos(jcExtendsPos.getStart(), jcExtendsPos.getEnd(), typeBoundKind); } return setPos(type.pos, endPosTable.get(type), treeMaker.Wildcard(typeBoundKind, type)); case SUPER: typeBoundKind = treeMaker.TypeBoundKind(BoundKind.SUPER); Position jcSuperPos = getConversionPositionInfo(node, "super"); if (jcSuperPos == null) { setPos(posOfStructure(node, "super", true), posOfStructure(node, "super", false), typeBoundKind); } else { setPos(jcSuperPos.getStart(), jcSuperPos.getEnd(), typeBoundKind); } return setPos(type.pos, endPosTable.get(type), treeMaker.Wildcard(typeBoundKind, type)); default: throw new IllegalStateException("Unexpected unbound wildcard: " + wildcardKind); } }
private Position getTypeBoundKindPosition(JCWildcard node) { try { Object o = JCWILDCARD_KIND.get(node); if (o instanceof TypeBoundKind) { return getPosition((TypeBoundKind) o); } } catch (Exception e) {} return Position.UNPLACED; }
/** record all tree nodes found by reflection. */ public void reflectiveScan(Object o) { if (o == null) return; if (o instanceof JCTree) { JCTree tree = (JCTree) o; //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64)); expect.add(tree); for (Field f: getFields(tree)) { if (TypeBoundKind.class.isAssignableFrom(f.getType())) { // not part of public API continue; } if (JCTree.JCNewArray.class.isAssignableFrom(tree.getClass()) && (f.getName().equals("annotations") || f.getName().equals("dimAnnotations"))) { // these fields are incorrectly missing from the public API // (CR 6983297) continue; } try { //System.err.println("FIELD: " + f.getName()); reflectiveScan(f.get(tree)); } catch (IllegalAccessException e) { error(e.toString()); } } } else if (o instanceof List) { List<?> list = (List<?>) o; for (Object item: list) reflectiveScan(item); } else error("unexpected item: " + o); }
@Override public void visitTypeBoundKind(TypeBoundKind tree) { try { print(String.valueOf(tree.kind)); } catch (IOException e) { throw new UncheckedIOException(e); } }
public JCWildcard Wildcard(TypeBoundKind kind, JCTree type) { return invoke(Wildcard, kind, type); }
public TypeBoundKind TypeBoundKind(BoundKind kind) { return invoke(TypeBoundKind, kind); }
public void visitTypeBoundKind(TypeBoundKind tree) { print(String.valueOf(tree.kind)); }
private static JCExpression cloneType0(JavacTreeMaker maker, JCTree in) { if (in == null) return null; if (in instanceof JCPrimitiveTypeTree) return (JCExpression) in; if (in instanceof JCIdent) { return maker.Ident(((JCIdent) in).name); } if (in instanceof JCFieldAccess) { JCFieldAccess fa = (JCFieldAccess) in; return maker.Select(cloneType0(maker, fa.selected), fa.name); } if (in instanceof JCArrayTypeTree) { JCArrayTypeTree att = (JCArrayTypeTree) in; return maker.TypeArray(cloneType0(maker, att.elemtype)); } if (in instanceof JCTypeApply) { JCTypeApply ta = (JCTypeApply) in; ListBuffer<JCExpression> lb = new ListBuffer<JCExpression>(); for (JCExpression typeArg : ta.arguments) { lb.append(cloneType0(maker, typeArg)); } return maker.TypeApply(cloneType0(maker, ta.clazz), lb.toList()); } if (in instanceof JCWildcard) { JCWildcard w = (JCWildcard) in; JCExpression newInner = cloneType0(maker, w.inner); TypeBoundKind newKind; switch (w.getKind()) { case SUPER_WILDCARD: newKind = maker.TypeBoundKind(BoundKind.SUPER); break; case EXTENDS_WILDCARD: newKind = maker.TypeBoundKind(BoundKind.EXTENDS); break; default: case UNBOUNDED_WILDCARD: newKind = maker.TypeBoundKind(BoundKind.UNBOUND); break; } return maker.Wildcard(newKind, newInner); } // This is somewhat unsafe, but it's better than outright throwing an exception here. Returning null will just cause an exception down the pipeline. return (JCExpression) in; }
public ATypeBoundKind(TypeBoundKind ltree) { super(ltree.kind); }
public ATypeBoundKind(TypeBoundKind ltree, String lcomment) { this(ltree); setComment(lcomment); }
public void visitTypeBoundKind(TypeBoundKind tree) { printNode(tree); property("kind", String.valueOf(tree.kind)); indent--; }
private static JCExpression cloneType0(TreeMaker maker, JCTree in) { if (in == null) return null; if (in instanceof JCPrimitiveTypeTree) return (JCExpression) in; if (in instanceof JCIdent) { return maker.Ident(((JCIdent) in).name); } if (in instanceof JCFieldAccess) { JCFieldAccess fa = (JCFieldAccess) in; return maker.Select(cloneType0(maker, fa.selected), fa.name); } if (in instanceof JCArrayTypeTree) { JCArrayTypeTree att = (JCArrayTypeTree) in; return maker.TypeArray(cloneType0(maker, att.elemtype)); } if (in instanceof JCTypeApply) { JCTypeApply ta = (JCTypeApply) in; ListBuffer<JCExpression> lb = ListBuffer.lb(); for (JCExpression typeArg : ta.arguments) { lb.append(cloneType0(maker, typeArg)); } return maker.TypeApply(cloneType0(maker, ta.clazz), lb.toList()); } if (in instanceof JCWildcard) { JCWildcard w = (JCWildcard) in; JCExpression newInner = cloneType0(maker, w.inner); TypeBoundKind newKind; switch (w.getKind()) { case SUPER_WILDCARD: newKind = maker.TypeBoundKind(BoundKind.SUPER); break; case EXTENDS_WILDCARD: newKind = maker.TypeBoundKind(BoundKind.EXTENDS); break; default: case UNBOUNDED_WILDCARD: newKind = maker.TypeBoundKind(BoundKind.UNBOUND); break; } return maker.Wildcard(newKind, newInner); } // This is somewhat unsafe, but it's better than outright throwing an exception here. Returning null will just cause an exception down the pipeline. return (JCExpression) in; }