當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeMaker.TypeArray方法代碼示例

本文整理匯總了Java中com.sun.tools.javac.tree.TreeMaker.TypeArray方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeMaker.TypeArray方法的具體用法?Java TreeMaker.TypeArray怎麽用?Java TreeMaker.TypeArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.tools.javac.tree.TreeMaker的用法示例。


在下文中一共展示了TreeMaker.TypeArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeType

import com.sun.tools.javac.tree.TreeMaker; //導入方法依賴的package包/類
public static JCTree.JCExpression makeType(String type, JavacNode node, TreeMaker maker) {
    if (type.startsWith("[L")) {
        return maker.TypeArray(chainDotsString(node, type.substring(2, type.length() - 1)));
    } else if (type.startsWith("[")) {
        return maker.TypeArray(chainDotsString(node, type.substring(1, type.length() - 1)));
    } else if (JCBooleanType.type.equals(type)) {
        return node.getTreeMaker().Type(JCBooleanType.booleanType());
    }
    return chainDotsString(node, type);
}
 
開發者ID:aalmiray,項目名稱:griffon2,代碼行數:11,代碼來源:HandlerUtils.java

示例2: cloneType0

import com.sun.tools.javac.tree.TreeMaker; //導入方法依賴的package包/類
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;
}
 
開發者ID:redundent,項目名稱:lombok,代碼行數:51,代碼來源:JavacHandlerUtil.java


注:本文中的com.sun.tools.javac.tree.TreeMaker.TypeArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。