Java 类com.sun.source.tree.UnionTypeTree 实例源码

项目:incubator-netbeans    文件:ExtraCatch.java   
private void removeAlternativeFromMultiCatch(TransformationContext ctx) throws Exception {
    TreePath unionPath = ctx.getPath().getParentPath();
    UnionTypeTree union = (UnionTypeTree)unionPath.getLeaf();
    TreeMaker mk = ctx.getWorkingCopy().getTreeMaker();
    GeneratorUtilities gen = GeneratorUtilities.get(ctx.getWorkingCopy());
    union = gen.importComments(union, ctx.getWorkingCopy().getCompilationUnit());
    List<? extends Tree> alts = new ArrayList<>(union.getTypeAlternatives());
    alts.remove(ctx.getPath().getLeaf());
    if (alts.size() > 1) {
        // still remains a multi-catch

        Tree newUnion = mk.UnionType(alts);
        ctx.getWorkingCopy().rewrite(union, newUnion);
    } else {
        // replace union type with just ordinary type
        ctx.getWorkingCopy().rewrite(union, alts.get(0));
    }
}
项目:incubator-netbeans    文件:TreeDuplicator.java   
@Override
    public Tree visitUnionType(UnionTypeTree tree, Void p) {
        UnionTypeTree n = make.UnionType(tree.getTypeAlternatives());
//  model.setType(n, model.getType(tree));
        comments.copyComments(tree, n);
        model.setPos(n, model.getPos(tree));
        return n;
    }
项目:incubator-netbeans    文件:SemanticHighlighterBase.java   
@Override
public Void visitUnionType(UnionTypeTree node, EnumSet<UseTypes> p) {
    for (Tree tree : node.getTypeAlternatives()) {
        handlePossibleIdentifier(new TreePath(getCurrentPath(), tree), EnumSet.of(UseTypes.CLASS_USE));
    }
    return super.visitUnionType(node, p);
}
项目:incubator-netbeans    文件:DependencyCollector.java   
@Override
public Object visitUnionType(UnionTypeTree node, Object p) {
    for (Tree t : node.getTypeAlternatives()) {
        addDependency(info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), t)));
    }
    return super.visitUnionType(node, p);
}
项目:incubator-netbeans    文件:TreeNode.java   
@Override
public Void visitUnionType(UnionTypeTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();

    addCorrespondingType(below);
    addCorrespondingComments(below);
    super.visitUnionType(tree, below);

    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
项目:incubator-netbeans    文件:JoinCatches.java   
private void addDisjointType(List<Tree> to, Tree type) {
    if (type == null) return;
    if (type.getKind() == Kind.UNION_TYPE) {
        to.addAll(((UnionTypeTree) type).getTypeAlternatives());
    } else {
        to.add(type);
    }
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
@Override
public Mirror visitUnionType(UnionTypeTree node, EvaluationContext p) {
    // union type expression in a multicatch var declaration
    // unsupported, since catch is unsupported
    Assert.error(node, "unsupported");
    return null;
}
项目:javaide    文件:JavaInputAstVisitor.java   
/**
 * Formats a union type declaration in a catch clause.
 */
private void visitUnionType(VariableTree declaration) {
    UnionTypeTree type = (UnionTypeTree) declaration.getType();
    builder.open(ZERO);
    sync(declaration);
    visitAndBreakModifiers(
            declaration.getModifiers(), Direction.HORIZONTAL, Optional.<BreakTag>absent());
    List<? extends Tree> union = type.getTypeAlternatives();
    boolean first = true;
    for (int i = 0; i < union.size() - 1; i++) {
        if (!first) {
            builder.breakOp(" ");
            token("|");
            builder.space();
        } else {
            first = false;
        }
        scan(union.get(i), null);
    }
    builder.breakOp(" ");
    token("|");
    builder.space();
    Tree last = union.get(union.size() - 1);
    declareOne(
            DeclarationKind.NONE,
            Direction.HORIZONTAL,
            Optional.<ModifiersTree>absent(),
            last,
            VarArgsOrNot.NO, // VarArgsOrNot.valueOf(declaration.isVarargs()),
            ImmutableList.<AnnotationTree>of(), // declaration.varargsAnnotations(),
            declaration.getName(),
            "",
            // declaration.extraDimensions(),
            "=",
            Optional.fromNullable(declaration.getInitializer()),
            Optional.<String>absent(),
            Optional.<ExpressionTree>absent(),
            Optional.<TypeWithDims>absent());
    builder.close();
}
项目:error-prone    文件:ErrorProneScanner.java   
@Override
public Void visitUnionType(UnionTypeTree tree, VisitorState visitorState) {
  VisitorState state = visitorState.withPath(getCurrentPath());
  for (UnionTypeTreeMatcher matcher : unionTypeMatchers) {
    if (!isSuppressed(matcher, state)) {
      try {
        reportMatch(matcher.matchUnionType(tree, state), tree, state);
      } catch (Throwable t) {
        handleError(matcher, t);
      }
    }
  }
  return super.visitUnionType(tree, state);
}
项目:checker-framework    文件:TypeFromTree.java   
@Override
public AnnotatedTypeMirror visitUnionType(UnionTypeTree node,
        AnnotatedTypeFactory f) {
    AnnotatedTypeMirror type = f.type(node);

    if (type.getKind() == TypeKind.TYPEVAR)
        return forTypeVariable(type, f);

    return type;
}
项目:incubator-netbeans    文件:Flow.java   
public Boolean visitUnionType(UnionTypeTree node, ConstructorData p) {
    super.visitUnionType(node, p);
    return null;
}
项目:incubator-netbeans    文件:ExpectedTypeResolver.java   
@Override
public List<? extends TypeMirror> visitUnionType(UnionTypeTree node, Object p) {
    return null;
}
项目:javaide    文件:JavaInputAstVisitor.java   
@Override
public Void visitUnionType(UnionTypeTree node, Void unused) {
    throw new IllegalStateException("expected manual descent into union types");
}
项目:oblivion-netbeans-plugin    文件:ApexTreeVisitorAdapter.java   
@Override
public R visitUnionType(UnionTypeTree utt, P p) {
    return null;
}
项目:oblivion-netbeans-plugin    文件:TreeFinder.java   
@Override
public List<T> visitUnionType(UnionTypeTree node, T p) {
    return checkForCriteria(node);
}
项目:error-prone    文件:UTemplater.java   
@Override
public UUnionType visitUnionType(UnionTypeTree tree, Void v) {
  return UUnionType.create(templateTypeExpressions(tree.getTypeAlternatives()));
}
项目:error-prone    文件:UUnionType.java   
@Override
public Choice<Unifier> visitUnionType(UnionTypeTree node, Unifier unifier) {
  return unifyList(unifier, getTypeAlternatives(), node.getTypeAlternatives());
}
项目:checker-framework    文件:CFGBuilder.java   
@Override
public Node visitUnionType(UnionTypeTree tree, Void p) {
    assert false : "UnionTypeTree is unexpected in AST to CFG translation";
    return null;
}
项目:checker-framework    文件:PurityChecker.java   
@Override
public PurityResult visitUnionType(UnionTypeTree node, PurityResult p) {
    assert false : "this type of tree is unexpected here";
    return null;
}
项目:bazel    文件:CFGBuilder.java   
@Override
public Node visitUnionType(UnionTypeTree tree, Void p) {
    assert false : "UnionTypeTree is unexpected in AST to CFG translation";
    return null;
}
项目:error-prone    文件:BugChecker.java   
Description matchUnionType(UnionTypeTree tree, VisitorState state);