Java 类com.sun.tools.javac.tree.JCTree.TypeBoundKind 实例源码

项目:javaparser2jctree    文件:JavaParser2JCTree.java   
@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));
}
项目:incubator-netbeans    文件:CasualDiff.java   
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];
}
项目:openjdk-jdk10    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:openjdk9    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:lookaside_java-1.8.0-openjdk    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:javaparser2jctree    文件:PrintAstVisitor.java   
public void visitTypeBoundKind(TypeBoundKind that) {
    try {
        print("TypeBoundKind:");
    } catch (Exception e) {
    }
    super.visitTypeBoundKind(that);
}
项目:jsr308-langtools    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:EasyMPermission    文件:PrettyCommentsPrinter.java   
public void visitTypeBoundKind(TypeBoundKind tree) {
    try {
        print(String.valueOf(tree.kind));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:android-retrolambda-lombok    文件:JcTreeBuilder.java   
@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);
}
项目:android-retrolambda-lombok    文件:JcTreeBuilder.java   
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);
    }
}
项目:android-retrolambda-lombok    文件:JcTreeConverter.java   
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;
}
项目:infobip-open-jdk-8    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:openjdk-source-code-learn    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:OLD-OpenJDK8    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:s4j    文件:Pretty.java   
@Override
public void visitTypeBoundKind(TypeBoundKind tree) {
    try {
        print(String.valueOf(tree.kind));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:s4j    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:jdk7-langtools    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:openjdk-icedtea7    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:lombok    文件:PrettyCommentsPrinter.java   
public void visitTypeBoundKind(TypeBoundKind tree) {
    try {
        print(String.valueOf(tree.kind));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:INF5000-StaticProxy    文件:SourceTreeScannerTest.java   
/** 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);
}
项目:lombok-ianchiu    文件:JavacTreeMaker.java   
public JCWildcard Wildcard(TypeBoundKind kind, JCTree type) {
    return invoke(Wildcard, kind, type);
}
项目:lombok-ianchiu    文件:JavacTreeMaker.java   
public TypeBoundKind TypeBoundKind(BoundKind kind) {
    return invoke(TypeBoundKind, kind);
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
public void visitTypeBoundKind(TypeBoundKind tree) {
    print(String.valueOf(tree.kind));
}
项目:lombok-ianchiu    文件:JavacHandlerUtil.java   
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;
}
项目:javaparser2jctree    文件:ATypeBoundKind.java   
public ATypeBoundKind(TypeBoundKind ltree) {
    super(ltree.kind);
}
项目:javaparser2jctree    文件:ATypeBoundKind.java   
public ATypeBoundKind(TypeBoundKind ltree, String lcomment) {
    this(ltree);
    setComment(lcomment);
}
项目:EasyMPermission    文件:JavacTreeMaker.java   
public JCWildcard Wildcard(TypeBoundKind kind, JCTree type) {
    return invoke(Wildcard, kind, type);
}
项目:EasyMPermission    文件:JavacTreeMaker.java   
public TypeBoundKind TypeBoundKind(BoundKind kind) {
    return invoke(TypeBoundKind, kind);
}
项目:EasyMPermission    文件:JavacHandlerUtil.java   
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;
}
项目:android-retrolambda-lombok    文件:JcTreePrinter.java   
public void visitTypeBoundKind(TypeBoundKind tree) {
    printNode(tree);
    property("kind", String.valueOf(tree.kind));
    indent--;
}
项目:lombok    文件:JavacHandlerUtil.java   
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;
}