本文整理汇总了Java中javax.lang.model.type.TypeKind.UNION属性的典型用法代码示例。如果您正苦于以下问题:Java TypeKind.UNION属性的具体用法?Java TypeKind.UNION怎么用?Java TypeKind.UNION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.lang.model.type.TypeKind
的用法示例。
在下文中一共展示了TypeKind.UNION属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitThrow
public Void visitThrow(ThrowTree node, Set<TypeMirror> p) {
super.visitThrow(node, p);
TypeMirror tm = info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
if (tm != null) {
if (tm.getKind() == TypeKind.DECLARED)
p.add(tm);
else if (tm.getKind() == TypeKind.UNION)
p.addAll(((UnionType)tm).getAlternatives());
}
return null;
}
示例2: getLub
@Override
public TypeMirror getLub(CatchTree tree) {
JCCatch ct = (JCCatch) tree;
JCVariableDecl v = ct.param;
if (v.type != null && v.type.getKind() == TypeKind.UNION) {
UnionClassType ut = (UnionClassType) v.type;
return ut.getLub();
} else {
return v.type;
}
}
示例3: getLub
@Override @DefinedBy(Api.COMPILER_TREE)
public TypeMirror getLub(CatchTree tree) {
JCCatch ct = (JCCatch) tree;
JCVariableDecl v = ct.param;
if (v.type != null && v.type.getKind() == TypeKind.UNION) {
UnionClassType ut = (UnionClassType) v.type;
return ut.getLub();
} else {
return v.type;
}
}
示例4: findUncaughtExceptions
private List<? extends TypeMirror> findUncaughtExceptions(CompilationInfo info, TreePath path, List<? extends TypeMirror> exceptions) {
List<TypeMirror> result = new ArrayList<TypeMirror>();
result.addAll(exceptions);
Tree lastTree = null;
while (path != null) {
Tree currentTree = path.getLeaf();
if (currentTree.getKind() == Tree.Kind.METHOD) {
TypeMirror tm = info.getTrees().getTypeMirror(path);
if (tm != null && tm.getKind() == TypeKind.EXECUTABLE) {
for (TypeMirror mirr : ((ExecutableType) tm).getThrownTypes()) {
for (Iterator<TypeMirror> it = result.iterator(); it.hasNext();)
if (info.getTypes().isSameType(it.next(), mirr))
it.remove();
}
break;
}
}
if (currentTree.getKind() == Tree.Kind.LAMBDA_EXPRESSION) {
// no checked exceptions can be thrown out of Lambda, #243106
break;
}
if (currentTree.getKind() == Kind.TRY) {
TryTree tt = (TryTree) currentTree;
if (tt.getBlock() == lastTree) {
for (CatchTree c : tt.getCatches()) {
TreePath catchPath = new TreePath(new TreePath(path, c), c.getParameter());
VariableElement variable = (VariableElement) info.getTrees().getElement(catchPath);
if (variable == null) {
continue;
}
TypeMirror variableType = variable.asType();
if (variableType.getKind() == TypeKind.UNION) {
result.removeAll(((UnionType)variableType).getAlternatives());
} else {
result.remove(variableType);
}
}
}
}
lastTree = path.getLeaf();
path = path.getParentPath();
}
List<TypeMirror> filtered = new ArrayList<>();
OUTER: for (Iterator<TypeMirror> sourceIt = result.iterator(); sourceIt.hasNext(); ) {
TypeMirror sourceType = sourceIt.next();
for (Iterator<TypeMirror> filteredIt = filtered.iterator(); filteredIt.hasNext(); ) {
TypeMirror filteredType = filteredIt.next();
if (info.getTypes().isSubtype(sourceType, filteredType)) {
sourceIt.remove();
continue OUTER;
}
if (info.getTypes().isSubtype(filteredType, sourceType)) {
filteredIt.remove();
break;
}
}
filtered.add(sourceType);
}
return filtered;
}
示例5: getKind
@Override
public TypeKind getKind() {
return TypeKind.UNION;
}