本文整理匯總了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;
}