本文整理匯總了Java中com.sun.tools.javac.tree.TreeMaker.TypeIdent方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeMaker.TypeIdent方法的具體用法?Java TreeMaker.TypeIdent怎麽用?Java TreeMaker.TypeIdent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.tools.javac.tree.TreeMaker
的用法示例。
在下文中一共展示了TreeMaker.TypeIdent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createCanEqual
import com.sun.tools.javac.tree.TreeMaker; //導入方法依賴的package包/類
private JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source) {
/* public boolean canEqual(final java.lang.Object other) {
* return other instanceof Outer.Inner.MyType;
* }
*/
TreeMaker maker = typeNode.getTreeMaker();
JCModifiers mods = maker.Modifiers(Flags.PUBLIC, List.<JCAnnotation>nil());
JCExpression returnType = maker.TypeIdent(CTC_BOOLEAN);
Name canEqualName = typeNode.toName("canEqual");
JCExpression objectType = chainDots(typeNode, "java", "lang", "Object");
Name otherName = typeNode.toName("other");
List<JCVariableDecl> params = List.of(maker.VarDef(maker.Modifiers(Flags.FINAL), otherName, objectType, null));
JCBlock body = maker.Block(0, List.<JCStatement>of(
maker.Return(maker.TypeTest(maker.Ident(otherName), createTypeReference(typeNode)))));
return recursiveSetGeneratedBy(maker.MethodDef(mods, canEqualName, returnType, List.<JCTypeParameter>nil(), params, List.<JCExpression>nil(), body, null), source);
}
示例2: primitiveToJCTree
import com.sun.tools.javac.tree.TreeMaker; //導入方法依賴的package包/類
private static JCExpression primitiveToJCTree(TypeKind kind, TreeMaker maker) throws TypeNotConvertibleException {
switch (kind) {
case BYTE:
return maker.TypeIdent(CTC_BYTE);
case CHAR:
return maker.TypeIdent(CTC_CHAR);
case SHORT:
return maker.TypeIdent(CTC_SHORT);
case INT:
return maker.TypeIdent(CTC_INT);
case LONG:
return maker.TypeIdent(CTC_LONG);
case FLOAT:
return maker.TypeIdent(CTC_FLOAT);
case DOUBLE:
return maker.TypeIdent(CTC_DOUBLE);
case BOOLEAN:
return maker.TypeIdent(CTC_BOOLEAN);
case VOID:
return maker.TypeIdent(CTC_VOID);
case NULL:
case NONE:
case OTHER:
default:
throw new TypeNotConvertibleException("Nulltype");
}
}