本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCTypeApply类的典型用法代码示例。如果您正苦于以下问题:Java JCTypeApply类的具体用法?Java JCTypeApply怎么用?Java JCTypeApply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JCTypeApply类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCTypeApply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diffTypeApply
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
protected int diffTypeApply(JCTypeApply oldT, JCTypeApply newT, int[] bounds) {
int localPointer = bounds[0];
int[] clazzBounds = getBounds(oldT.clazz);
copyTo(localPointer, clazzBounds[0]);
localPointer = diffTree(oldT.clazz, newT.clazz, clazzBounds);
if (!listsMatch(oldT.arguments, newT.arguments)) {
int pos = oldT.arguments.nonEmpty() ? getOldPos(oldT.arguments.head) : endPos(oldT.clazz);
copyTo(localPointer, pos);
boolean printBrace = false;
localPointer = diffParameterList(
oldT.arguments,
newT.arguments,
printBrace ? new JavaTokenId[] { JavaTokenId.LT, JavaTokenId.GT } : null,
pos,
Measure.ARGUMENT
);
}
copyTo(localPointer, bounds[1]);
return bounds[1];
}
示例2: unpack
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
private static void unpack(StringBuilder sb, JCExpression expr) {
if (expr instanceof JCIdent) {
sb.append(((JCIdent) expr).name.toString());
return;
}
if (expr instanceof JCFieldAccess) {
JCFieldAccess jcfa = (JCFieldAccess) expr;
unpack(sb, jcfa.selected);
sb.append(".").append(jcfa.name.toString());
return;
}
if (expr instanceof JCTypeApply) {
sb.setLength(0);
sb.append("ERR:");
sb.append("@Builder(toBuilder=true) is not supported if returning a type with generics applied to an intermediate.");
sb.append("__ERR__");
return;
}
sb.setLength(0);
sb.append("ERR:");
sb.append("Expected a type of some sort, not a " + expr.getClass().getName());
sb.append("__ERR__");
}
示例3: visitVariable
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
@Override
public Pair<ASTRecord, Integer> visitVariable(VariableTree node, Insertion ins) {
Name name = node.getName();
JCVariableDecl jn = (JCVariableDecl) node;
JCTree jt = jn.getType();
Criteria criteria = ins.getCriteria();
dbug.debug("TypePositionFinder.visitVariable: %s %s%n", jt, jt.getClass());
if (name != null && criteria.isOnFieldDeclaration()) {
return Pair.of(astRecord(node), jn.getStartPosition());
}
if (jt instanceof JCTypeApply) {
JCExpression type = ((JCTypeApply) jt).clazz;
return pathAndPos(type);
}
return Pair.of(astRecord(node), jn.pos);
}
示例4: visitNewClass
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
@Override
public Pair<ASTRecord, Integer> visitNewClass(NewClassTree node, Insertion ins) {
JCNewClass na = (JCNewClass) node;
JCExpression className = na.clazz;
// System.out.printf("classname %s (%s)%n", className, className.getClass());
while (! (className.getKind() == Tree.Kind.IDENTIFIER)) { // IdentifierTree
if (className instanceof JCAnnotatedType) {
className = ((JCAnnotatedType) className).underlyingType;
} else if (className instanceof JCTypeApply) {
className = ((JCTypeApply) className).clazz;
} else if (className instanceof JCFieldAccess) {
// This occurs for fully qualified names, e.g. "new java.lang.Object()".
// I'm not quite sure why the field "selected" is taken, but "name" would
// be a type mismatch. It seems to work, see NewPackage test case.
className = ((JCFieldAccess) className).selected;
} else {
throw new Error(String.format("unrecognized JCNewClass.clazz (%s): %s%n" +
" surrounding new class tree: %s%n", className.getClass(), className, node));
}
// System.out.printf("classname %s (%s)%n", className, className.getClass());
}
return visitIdentifier((IdentifierTree) className, ins);
}
示例5: visitClass
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
@Override
public Object visitClass (ClassTree classTree, Trees trees) {
Tree extendTree = classTree.getExtendsClause();
if (extendTree instanceof JCTypeApply) { //generic classes case
JCTypeApply generic = (JCTypeApply) extendTree;
extendTree = generic.clazz;
}
if (extendTree instanceof JCIdent) {
JCIdent tree = (JCIdent) extendTree;
Scope members = tree.sym.members();
if (checkScope(members))
return super.visitClass(classTree, trees);
if (checkSuperTypes((ClassType) tree.type))
return super.visitClass(classTree, trees);
}
callSuperUsed = false;
return super.visitClass(classTree, trees);
}
示例6: visitTypeReferencePart
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
@Override
public boolean visitTypeReferencePart(TypeReferencePart node) {
JCIdent ident = (JCIdent) toTree(node.astIdentifier());
List<JCExpression> typeArguments = toList(JCExpression.class, node.astTypeArguments());
if (typeArguments.isEmpty()) {
return set(node, ident);
} else {
JCTypeApply typeApply = treeMaker.TypeApply(ident, typeArguments);
Position jcOpenBracketPos = getConversionPositionInfo(node, "<");
if (jcOpenBracketPos == null) {
setPos(posOfStructure(node, "<", true), node.getPosition().getEnd(), typeApply);
} else {
setPos(jcOpenBracketPos.getStart(), node.getPosition().getEnd(), typeApply);
}
return set(node, typeApply);
}
}
示例7: map
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
@Override
JCNewClass map(JCNewClass oldTree, JCNewClass newTree) {
if (newTree.clazz.hasTag(TYPEAPPLY)) {
((JCTypeApply)newTree.clazz).arguments = List.nil();
}
return newTree;
}
示例8: visitTypeApply
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
public void visitTypeApply(JCTypeApply that) {
try {
print("JCTypeApply:");
} catch (Exception e) {
}
super.visitTypeApply(that);
}
示例9: visitTypeApply
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
public void visitTypeApply(JCTypeApply tree) {
try {
printExpr(tree.clazz);
print("<");
printExprs(tree.arguments);
print(">");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例10: visitParameterizedType
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
@Override
public Pair<ASTRecord, Integer> visitParameterizedType(ParameterizedTypeTree node, Insertion ins) {
Tree parent = parent(node);
dbug.debug("TypePositionFinder.visitParameterizedType %s parent=%s%n",
node, parent);
Integer pos = getBaseTypePosition(((JCTypeApply) node).getType()).b;
return Pair.of(astRecord(node), pos);
}
示例11: plainTypeReference
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
private JCExpression plainTypeReference(TypeReference node) {
if (node.isPrimitive() || node.isVoid() || node.astParts().size() == 1) {
int end = node.getPosition().getEnd();
if (node.astArrayDimensions() > 0) {
end = node.astParts().last().getPosition().getEnd();
}
if (end == node.getPosition().getStart()) end = node.getPosition().getEnd();
Identifier identifier = node.astParts().first().astIdentifier();
int typeTag = primitiveTypeTag(identifier.astValue());
if (typeTag > 0) return setPos(node.getPosition().getStart(), end, treeMaker.TypeIdent(typeTag));
}
JCExpression current = null;
for (TypeReferencePart part : node.astParts()) {
JCExpression expr = (JCExpression) toTree(part);
if (current == null) {
current = expr;
continue;
}
if (expr instanceof JCIdent) {
current = treeMaker.Select(current, ((JCIdent)expr).name);
setPos(posOfStructure(part, ".", true), part.getPosition().getEnd(), current);
} else if (expr instanceof JCTypeApply) {
JCTypeApply apply = (JCTypeApply)expr;
apply.clazz = treeMaker.Select(current, ((JCIdent)apply.clazz).name);
setPos(posOfStructure(part, ".", true), part.astIdentifier().getPosition().getEnd(), apply.clazz);
current = apply;
} else {
throw new IllegalStateException("Didn't expect a " + expr.getClass().getName() + " in " + node);
}
}
//TODO add a lot more tests involving 'void', apparently we're missing a bunch.
return current;
}
示例12: visitTypeApply
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
@Override public void visitTypeApply(JCTypeApply node) {
TypeReference ref = (TypeReference) toTree(node.clazz, FlagKey.TYPE_REFERENCE);
TypeReferencePart last = ref.astParts().last();
fillList(node.arguments, last.rawTypeArguments(), FlagKey.TYPE_REFERENCE);
setPos(node, ref);
setConversionPositionInfo(last, "<", getPosition(node));
set(node, ref);
}
示例13: visitTypeApply
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
public void visitTypeApply(JCTypeApply tree) {
try {
printExpr(tree.clazz);
print("<");
printExprs(tree.arguments);
print(">");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例14: methodReturns
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
public static Matcher<MethodTree> methodReturns(final Type returnType) {
return new Matcher<MethodTree>() {
@Override
public boolean matches(MethodTree methodTree, VisitorState state) {
Tree returnTree = methodTree.getReturnType();
Type methodReturnType = null;
if (returnTree == null) {
// This is a constructor, it has no return type.
return false;
}
switch (returnTree.getKind()) {
case ARRAY_TYPE:
methodReturnType = ((JCArrayTypeTree)returnTree).type;
break;
case PRIMITIVE_TYPE:
methodReturnType = ((JCPrimitiveTypeTree)returnTree).type;
break;
case PARAMETERIZED_TYPE:
methodReturnType = ((JCTypeApply)returnTree).type;
break;
default:
return false;
}
return state.getTypes().isSameType(methodReturnType, returnType);
}
};
}
示例15: matchTypeApply
import com.sun.tools.javac.tree.JCTree.JCTypeApply; //导入依赖的package包/类
private boolean matchTypeApply(JCTypeApply t1, JCTypeApply t2) {
return treesMatch(t1.clazz, t2.clazz) &&
listsMatch(t1.arguments, t2.arguments);
}